Changeset 4b2d174


Ignore:
Timestamp:
Jan 28, 2019, 10:56:27 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/crepe_org
Children:
ddd124a
Parents:
1df9cd1
Message:

[tensor] rewrite and rename have_same_shape

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/ai/tensor.c

    r1df9cd1 r4b2d174  
    138138}
    139139
    140 uint_t aubio_tensor_have_same_size(aubio_tensor_t *t, aubio_tensor_t *s)
     140uint_t aubio_tensor_have_same_shape(aubio_tensor_t *a, aubio_tensor_t *b)
    141141{
    142142  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]) {
    149149      return 0;
    150150    }
  • TabularUnified tests/src/ai/test-tensor.c

    r1df9cd1 r4b2d174  
    124124  aubio_tensor_t *b = new_aubio_tensor(3, dims);
    125125
    126   assert (!aubio_tensor_have_same_size(a, b));
     126  assert (!aubio_tensor_have_same_shape(a, b));
    127127
    128128  del_aubio_tensor(b);
    129129  dims[2] += 1;
    130130  b = new_aubio_tensor(4, dims);
    131   assert (!aubio_tensor_have_same_size(a, b));
     131  assert (!aubio_tensor_have_same_shape(a, b));
    132132  del_aubio_tensor(b);
    133133  dims[2] -= 1;
     
    136136  dims[1] += 1;
    137137  b = new_aubio_tensor(4, dims);
    138   assert (!aubio_tensor_have_same_size(a, b));
     138  assert (!aubio_tensor_have_same_shape(a, b));
    139139  del_aubio_tensor(b);
    140140
     
    142142  dims[1] -= 1;
    143143  b = new_aubio_tensor(4, dims);
    144   assert (aubio_tensor_have_same_size(a, b));
    145 
    146   assert (!aubio_tensor_have_same_size(NULL, b));
    147   assert (!aubio_tensor_have_same_size(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));
    148148
    149149  del_aubio_tensor(a);
     
    321321  PRINT_MSG("testing 4d tensors\n");
    322322  assert (test_4d() == 0);
    323   PRINT_MSG("testing aubio_tensor_have_same_size\n");
     323  PRINT_MSG("testing aubio_tensor_have_same_shape\n");
    324324  assert (test_sizes() == 0);
    325325  PRINT_MSG("testing new_aubio_tensor with wrong arguments\n");
Note: See TracChangeset for help on using the changeset viewer.