[ai] only compile _debug function in debug mode
authorPaul Brossier <piem@piem.org>
Mon, 27 Dec 2021 00:38:56 +0000 (19:38 -0500)
committerPaul Brossier <piem@piem.org>
Wed, 29 Dec 2021 16:52:03 +0000 (11:52 -0500)
src/ai/batchnorm.c
src/ai/conv1d.c
src/ai/conv2d.c
src/ai/dense.c
src/ai/maxpool1d.c
src/ai/maxpool2d.c

index 7aba3d5..78278e4 100644 (file)
@@ -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;
 }
index 586c521..1c2c13d 100644 (file)
@@ -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,
index 586dad7..50a74ec 100644 (file)
@@ -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,
index a012ba1..49efc2b 100644 (file)
@@ -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;
 }
index beeee0e..5877739 100644 (file)
@@ -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;
 }
index cb25fec..c48ee53 100644 (file)
@@ -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;
 }