Changeset 17189b2
- Timestamp:
- Dec 29, 2021, 5:52:00 PM (3 years ago)
- Branches:
- feature/crepe
- Children:
- 3c754d5
- Parents:
- 461a89f
- git-author:
- Paul Brossier <piem@piem.org> (01/28/19 22:56:27)
- git-committer:
- Paul Brossier <piem@piem.org> (12/29/21 17:52:00)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ai/tensor.c
r461a89f r17189b2 138 138 } 139 139 140 uint_t aubio_tensor_have_same_s ize(aubio_tensor_t *t, aubio_tensor_t *s)140 uint_t aubio_tensor_have_same_shape(aubio_tensor_t *a, aubio_tensor_t *b) 141 141 { 142 142 uint_t n; 143 if (!t || !s) return 0;144 if ( t->ndim != s->ndim) return 0;145 if (t->size != s->size)return 0;146 n = t->ndim;147 while (n--) {148 if ( t->shape[n] != s->shape[n]) {143 AUBIO_ASSERT(a && b); 144 if (a->ndim != b->ndim) { 145 return 0; 146 } 147 for (n = 0; n < a->ndim; n++) { 148 if (a->shape[n] != b->shape[n]) { 149 149 return 0; 150 150 } -
tests/src/ai/test-tensor.c
r461a89f r17189b2 124 124 aubio_tensor_t *b = new_aubio_tensor(3, dims); 125 125 126 assert (!aubio_tensor_have_same_s ize(a, b));126 assert (!aubio_tensor_have_same_shape(a, b)); 127 127 128 128 del_aubio_tensor(b); 129 129 dims[2] += 1; 130 130 b = new_aubio_tensor(4, dims); 131 assert (!aubio_tensor_have_same_s ize(a, b));131 assert (!aubio_tensor_have_same_shape(a, b)); 132 132 del_aubio_tensor(b); 133 133 dims[2] -= 1; … … 136 136 dims[1] += 1; 137 137 b = new_aubio_tensor(4, dims); 138 assert (!aubio_tensor_have_same_s ize(a, b));138 assert (!aubio_tensor_have_same_shape(a, b)); 139 139 del_aubio_tensor(b); 140 140 … … 142 142 dims[1] -= 1; 143 143 b = new_aubio_tensor(4, dims); 144 assert (aubio_tensor_have_same_s ize(a, b));145 146 assert (!aubio_tensor_have_same_s ize(NULL, b));147 assert (!aubio_tensor_have_same_s ize(a, NULL));144 assert (aubio_tensor_have_same_shape(a, b)); 145 146 assert (!aubio_tensor_have_same_shape(NULL, b)); 147 assert (!aubio_tensor_have_same_shape(a, NULL)); 148 148 149 149 del_aubio_tensor(a); … … 321 321 PRINT_MSG("testing 4d tensors\n"); 322 322 assert (test_4d() == 0); 323 PRINT_MSG("testing aubio_tensor_have_same_s ize\n");323 PRINT_MSG("testing aubio_tensor_have_same_shape\n"); 324 324 assert (test_sizes() == 0); 325 325 PRINT_MSG("testing new_aubio_tensor with wrong arguments\n");
Note: See TracChangeset
for help on using the changeset viewer.