- Timestamp:
- Dec 29, 2021, 5:51:46 PM (3 years ago)
- Branches:
- feature/cnn, feature/crepe
- Children:
- 533187f
- Parents:
- 2859f89
- git-author:
- Paul Brossier <piem@piem.org> (01/02/19 22:54:21)
- git-committer:
- Paul Brossier <piem@piem.org> (12/29/21 17:51:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ai/tensor.c
r2859f89 r0d9ef90 46 46 47 47 uint_t aubio_tensor_as_fvec(aubio_tensor_t *c, fvec_t *o) { 48 if (c->ndim != 1) return AUBIO_FAIL; 49 if (c->shape[0] <= 0) return AUBIO_FAIL; 50 o->length = c->shape[0]; 48 if (!c || !o) return AUBIO_FAIL; 49 o->length = c->size; 51 50 o->data = c->data[0]; 52 51 return AUBIO_OK; … … 54 53 55 54 uint_t aubio_fvec_as_tensor(fvec_t *o, aubio_tensor_t *c) { 56 if ( o == NULL) return AUBIO_FAIL;55 if (!o || !c) return AUBIO_FAIL; 57 56 c->ndim = 1; 58 57 c->shape[0] = o->length; 59 58 c->data = &o->data; 59 c->buffer = o->data; 60 60 c->size = o->length; 61 61 return AUBIO_OK; … … 63 63 64 64 uint_t aubio_tensor_as_fmat(aubio_tensor_t *c, fmat_t *o) { 65 if (c->ndim != 2) return AUBIO_FAIL; 66 if (c->shape[0] <= 0) return AUBIO_FAIL; 67 if (c->shape[1] <= 0) return AUBIO_FAIL; 65 if (!c || !o) return AUBIO_FAIL; 68 66 o->height = c->shape[0]; 69 o->length = c->s hape[1];67 o->length = c->size / c->shape[0]; 70 68 o->data = c->data; 71 69 return AUBIO_OK; … … 73 71 74 72 uint_t aubio_fmat_as_tensor(fmat_t *o, aubio_tensor_t *c) { 75 if (o == NULL) return AUBIO_FAIL; 76 if (c == NULL) return AUBIO_FAIL; 73 if (!o || !c) return AUBIO_FAIL; 77 74 c->ndim = 2; 78 75 c->shape[0] = o->height; … … 80 77 c->size = o->height * o->length; 81 78 c->data = o->data; 79 c->buffer = o->data[0]; 82 80 return AUBIO_OK; 83 81 }
Note: See TracChangeset
for help on using the changeset viewer.