Changeset 7e0b641
- Timestamp:
- Jan 2, 2019, 10:56:47 PM (6 years ago)
- Branches:
- feature/cnn_org, feature/crepe_org
- Children:
- dc257cc
- Parents:
- 9bffada
- Location:
- src/ai
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ai/tensor.c
r9bffada r7e0b641 81 81 } 82 82 83 uint_t aubio_tensor_get_subtensor(aubio_tensor_t *t, uint_t i, 84 aubio_tensor_t *st) 85 { 86 uint_t j; 87 if (!t || !st) return AUBIO_FAIL; 88 if (i >= t->shape[0]) { 89 AUBIO_ERR("tensor: index %d out of range, only %d subtensors\n", 90 i, t->shape[0]); 91 return AUBIO_FAIL; 92 } 93 if(t->ndim > 1) { 94 st->ndim = t->ndim - 1; 95 for (j = 0; j < st->ndim; j++) { 96 st->shape[j] = t->shape[j + 1]; 97 } 98 for (j = st->ndim; j < AUBIO_TENSOR_MAXDIM; j++) { 99 st->shape[j] = 0; 100 } 101 st->size = t->size / t->shape[0]; 102 } else { 103 st->ndim = 1; 104 st->shape[0] = 1; 105 st->size = 1; 106 } 107 // st was allocated on the stack, row indices are lost 108 st->data = NULL; 109 st->buffer = &t->buffer[0] + st->size * i; 110 return AUBIO_OK; 111 } 112 83 113 smpl_t aubio_tensor_max(aubio_tensor_t *t) 84 114 { -
src/ai/tensor.h
r9bffada r7e0b641 59 59 uint_t aubio_fmat_as_tensor(fmat_t *o, aubio_tensor_t *c); 60 60 61 uint_t aubio_tensor_get_subtensor(aubio_tensor_t *t, uint_t i, 62 aubio_tensor_t *st); 63 61 64 smpl_t aubio_tensor_max(aubio_tensor_t *t); 62 65
Note: See TracChangeset
for help on using the changeset viewer.