From 2859f8986d6b46babdb20b203c06a30a0493533a Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 2 Jan 2019 22:53:40 +0100 Subject: [PATCH] [tensor] set buffer, remove old comments --- src/ai/tensor.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ai/tensor.c b/src/ai/tensor.c index f56e5fd8..2c2c9401 100644 --- a/src/ai/tensor.c +++ b/src/ai/tensor.c @@ -5,6 +5,7 @@ aubio_tensor_t *new_aubio_tensor(uint_t ndim, uint_t *shape) { aubio_tensor_t *c = AUBIO_NEW(aubio_tensor_t); + uint_t items_per_row = 1; uint_t i; if ((sint_t)ndim <= 0) goto failure; @@ -13,18 +14,16 @@ aubio_tensor_t *new_aubio_tensor(uint_t ndim, uint_t *shape) } c->ndim = ndim; - uint_t items_per_row = 1; - //c->shape = AUBIO_ARRAY(uint_t, ndim); c->shape[0] = shape[0]; for (i = 1; i < ndim; i++) { c->shape[i] = shape[i]; items_per_row *= shape[i]; } c->size = items_per_row * shape[0]; + c->buffer = AUBIO_ARRAY(smpl_t, c->size); c->data = AUBIO_ARRAY(smpl_t*, shape[0]); - c->data[0] = AUBIO_ARRAY(smpl_t, c->size); - for (i = 1; i < c->shape[0]; i++) { - c->data[i] = c->data[0] + i * items_per_row; + for (i = 0; i < c->shape[0]; i++) { + c->data[i] = c->buffer + i * items_per_row; } return c; @@ -36,15 +35,12 @@ failure: void del_aubio_tensor(aubio_tensor_t *c) { - AUBIO_ASSERT(c); if (c->data) { if (c->data[0]) { AUBIO_FREE(c->data[0]); } AUBIO_FREE(c->data); } - //if (c->shape) - // AUBIO_FREE(c->shape); AUBIO_FREE(c); } -- 2.11.0