From: Paul Brossier Date: Mon, 27 Dec 2021 00:38:56 +0000 (-0500) Subject: [ai] only compile _debug function in debug mode X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=be3164d630ca74d2600d38773e360e16bed16703;p=aubio.git [ai] only compile _debug function in debug mode --- diff --git a/src/ai/batchnorm.c b/src/ai/batchnorm.c index 7aba3d53..78278e43 100644 --- a/src/ai/batchnorm.c +++ b/src/ai/batchnorm.c @@ -31,8 +31,10 @@ struct _aubio_batchnorm_t { fvec_t *moving_variance; }; +#if defined(DEBUG) static void aubio_batchnorm_debug(aubio_batchnorm_t *c, aubio_tensor_t *input_tensor); +#endif aubio_batchnorm_t *new_aubio_batchnorm(void) { @@ -58,6 +60,7 @@ void del_aubio_batchnorm(aubio_batchnorm_t* c) { AUBIO_FREE(c); } +#if defined(DEBUG) void aubio_batchnorm_debug(aubio_batchnorm_t *c, aubio_tensor_t *input_tensor) { AUBIO_DBG("batchnorm: %15s -> %s (%d params) (4 * (%d,))\n", @@ -65,6 +68,7 @@ void aubio_batchnorm_debug(aubio_batchnorm_t *c, aubio_tensor_t *input_tensor) aubio_tensor_get_shape_string(input_tensor), // same output shape c->n_outputs, 4 * c->n_outputs); } +#endif uint_t aubio_batchnorm_get_output_shape(aubio_batchnorm_t *c, aubio_tensor_t *input, uint_t *shape) @@ -92,7 +96,9 @@ uint_t aubio_batchnorm_get_output_shape(aubio_batchnorm_t *c, return AUBIO_FAIL; } +#if defined(DEBUG) aubio_batchnorm_debug(c, input); +#endif return AUBIO_OK; } diff --git a/src/ai/conv1d.c b/src/ai/conv1d.c index 586c521d..1c2c13d4 100644 --- a/src/ai/conv1d.c +++ b/src/ai/conv1d.c @@ -50,8 +50,10 @@ struct _aubio_conv1d_t { #endif }; +#if defined(DEBUG) static void aubio_conv1d_debug(aubio_conv1d_t *c, aubio_tensor_t *input_tensor); +#endif aubio_conv1d_t *new_aubio_conv1d(uint_t n_filters, uint_t kernel_shape[1]) { @@ -175,11 +177,14 @@ uint_t aubio_conv1d_get_output_shape(aubio_conv1d_t *c, shape[0] = output_shape[0]; shape[1] = output_shape[1]; +#if defined(DEBUG) aubio_conv1d_debug(c, input_tensor); +#endif return AUBIO_OK; } +#if defined(DEBUG) void aubio_conv1d_debug(aubio_conv1d_t *c, aubio_tensor_t *input_tensor) { // print some info @@ -195,6 +200,7 @@ void aubio_conv1d_debug(aubio_conv1d_t *c, aubio_tensor_t *input_tensor) c->stride_shape[0], -c->padding_start); } +#endif uint_t aubio_conv1d_check_output_shape(aubio_conv1d_t *c, aubio_tensor_t *input_tensor, diff --git a/src/ai/conv2d.c b/src/ai/conv2d.c index 586dad71..50a74ece 100644 --- a/src/ai/conv2d.c +++ b/src/ai/conv2d.c @@ -49,7 +49,9 @@ struct _aubio_conv2d_t { #endif }; +#if defined(DEBUG) static void aubio_conv2d_debug(aubio_conv2d_t *c, aubio_tensor_t *input_tensor); +#endif aubio_conv2d_t *new_aubio_conv2d(uint_t n_filters, uint_t kernel_shape[2]) { @@ -202,11 +204,14 @@ uint_t aubio_conv2d_get_output_shape(aubio_conv2d_t *c, } #endif +#if defined(DEBUG) aubio_conv2d_debug(c, input_tensor); +#endif return AUBIO_OK; } +#if defined(DEBUG) void aubio_conv2d_debug(aubio_conv2d_t *c, aubio_tensor_t *input_tensor) { // print some info @@ -227,6 +232,7 @@ void aubio_conv2d_debug(aubio_conv2d_t *c, aubio_tensor_t *input_tensor) c->stride_shape[0], c->stride_shape[1], -c->padding_start[0], -c->padding_start[1]); } +#endif uint_t aubio_conv2d_check_output_shape(aubio_conv2d_t *c, aubio_tensor_t *input_tensor, diff --git a/src/ai/dense.c b/src/ai/dense.c index a012ba1e..49efc2b5 100644 --- a/src/ai/dense.c +++ b/src/ai/dense.c @@ -52,6 +52,7 @@ void del_aubio_dense(aubio_dense_t *c) { AUBIO_FREE(c); } +#if defined(DEBUG) void aubio_dense_debug(aubio_dense_t *c, aubio_tensor_t *input_tensor) { uint_t n_params = input_tensor->shape[0] * c->n_units + c->n_units; @@ -60,6 +61,7 @@ void aubio_dense_debug(aubio_dense_t *c, aubio_tensor_t *input_tensor) aubio_tensor_get_shape_string(input_tensor), c->n_units, n_params, c->n_units, c->weights->height, c->weights->length, c->bias->length); } +#endif uint_t aubio_dense_get_output_shape(aubio_dense_t *c, aubio_tensor_t *input, uint_t *shape) @@ -76,7 +78,9 @@ uint_t aubio_dense_get_output_shape(aubio_dense_t *c, c->bias = new_fvec(c->n_units); if (!c->bias) return AUBIO_FAIL; +#if defined(DEBUG) aubio_dense_debug(c, input); +#endif return AUBIO_OK; } diff --git a/src/ai/maxpool1d.c b/src/ai/maxpool1d.c index beeee0e4..58777397 100644 --- a/src/ai/maxpool1d.c +++ b/src/ai/maxpool1d.c @@ -30,8 +30,10 @@ struct _aubio_maxpool1d_t { uint_t stride; }; +#if defined(DEBUG) static void aubio_maxpool1d_debug(aubio_maxpool1d_t *c, aubio_tensor_t *input_tensor); +#endif aubio_maxpool1d_t *new_aubio_maxpool1d(uint_t pool_size[1]) { @@ -55,6 +57,7 @@ void del_aubio_maxpool1d(aubio_maxpool1d_t* c) { AUBIO_FREE(c); } +#if defined(DEBUG) void aubio_maxpool1d_debug(aubio_maxpool1d_t *c, aubio_tensor_t *input_tensor) { AUBIO_DBG("maxpool1d: %15s -> (%d, %d) (no params)" @@ -62,6 +65,7 @@ void aubio_maxpool1d_debug(aubio_maxpool1d_t *c, aubio_tensor_t *input_tensor) input_tensor->shape[0] / c->pool_size, input_tensor->shape[1], c->pool_size); } +#endif uint_t aubio_maxpool1d_get_output_shape(aubio_maxpool1d_t *c, aubio_tensor_t *input, uint_t *shape) @@ -72,7 +76,9 @@ uint_t aubio_maxpool1d_get_output_shape(aubio_maxpool1d_t *c, shape[0] = input->shape[0] / c->pool_size; shape[1] = input->shape[1]; +#if defined(DEBUG) aubio_maxpool1d_debug(c, input); +#endif return AUBIO_OK; } diff --git a/src/ai/maxpool2d.c b/src/ai/maxpool2d.c index cb25fec9..c48ee537 100644 --- a/src/ai/maxpool2d.c +++ b/src/ai/maxpool2d.c @@ -30,8 +30,10 @@ struct _aubio_maxpool2d_t { uint_t stride[2]; }; +#if defined(DEBUG) static void aubio_maxpool2d_debug(aubio_maxpool2d_t *c, aubio_tensor_t *input_tensor); +#endif aubio_maxpool2d_t *new_aubio_maxpool2d(uint_t pool_size[2]) { @@ -58,6 +60,7 @@ void del_aubio_maxpool2d(aubio_maxpool2d_t* c) { AUBIO_FREE(c); } +#if defined(DEBUG) void aubio_maxpool2d_debug(aubio_maxpool2d_t *c, aubio_tensor_t *input_tensor) { AUBIO_DBG("maxpool2d: %15s -> (%d, %d, %d)" @@ -69,6 +72,7 @@ void aubio_maxpool2d_debug(aubio_maxpool2d_t *c, aubio_tensor_t *input_tensor) c->pool_size[0], c->pool_size[1]); } +#endif uint_t aubio_maxpool2d_get_output_shape(aubio_maxpool2d_t *c, aubio_tensor_t *input, uint_t *shape) @@ -80,7 +84,9 @@ uint_t aubio_maxpool2d_get_output_shape(aubio_maxpool2d_t *c, shape[1] = input->shape[1] / c->pool_size[1]; shape[2] = input->shape[2]; +#if defined(DEBUG) aubio_maxpool2d_debug(c, input); +#endif return AUBIO_OK; }