3030#ifndef _MLI_KRN_CONV2D_CHW_H_
3131#define _MLI_KRN_CONV2D_CHW_H_
3232
33- #include < assert.h>
34- #include < stdio.h>
35-
3633#include " mli_config.h"
3734#include " mli_debug.h"
3835#include " mli_helpers_api.h"
3936#include " mli_prv_dsp.h"
4037#include " mli_krn_dotprod_chw.h"
4138
42- #if 0 /* when debugging, set this to 1 to get more asserts */
43- #define MY_ASSERT(a) assert(a)
44- #else
45- #define MY_ASSERT (a ) (void )(a)
46- #endif
47-
4839#ifdef DEBUG_CONV2D
4940#define CONV2D_DBG_PRINT (out_ch_idx, H_idx, W_idx, out_val ) \
5041 MLI_PRINTF (" MLI_CONV2D: [%d, %d, %d] out_val = %d\n " , out_ch_idx, H_idx, W_idx , (int )out_val)
@@ -591,8 +582,8 @@ static inline void __attribute__ ((always_inline)) conv2d_chw_nopad_k1x1_str1 (
591582 const int clmn_begin = perception_area->clmn_beg ;
592583 const int clmn_end = perception_area->clmn_end ;
593584
594- assert (kernel_height == 1 );
595- assert (kernel_width == 1 );
585+ MLI_ASSERT (kernel_height == 1 );
586+ MLI_ASSERT (kernel_width == 1 );
596587
597588 for (int out_ch_idx = 0 ; out_ch_idx < out_ch; out_ch_idx++) {
598589 for (int H_idx = row_begin; H_idx < row_end; H_idx++) {
@@ -703,8 +694,8 @@ static inline void __attribute__ ((always_inline)) conv2d_chw_nopad_k1x1_str1 (
703694 const int clmn_begin = perception_area->clmn_beg ;
704695 const int clmn_end = perception_area->clmn_end ;
705696
706- assert (kernel_height == 1 );
707- assert (kernel_width == 1 );
697+ MLI_ASSERT (kernel_height == 1 );
698+ MLI_ASSERT (kernel_width == 1 );
708699
709700 for (int out_ch_idx = 0 ; out_ch_idx < out_ch; out_ch_idx++) {
710701 for (int H_idx = row_begin; H_idx < row_end; H_idx++) {
@@ -838,8 +829,8 @@ static inline void __attribute__ ((always_inline)) conv2d_row_str1 (
838829
839830 MLI_PTR (io_T) __restrict o_ptr = out_ftrs + out_ch_idx * out_width * out_height + H_idx * out_width + clmn_begin;
840831
841- assert (stride_width == 1 );
842- assert (H_idx < out_height);
832+ MLI_ASSERT (stride_width == 1 );
833+ MLI_ASSERT (H_idx < out_height);
843834
844835 /* for large kernel sizes use a loop for the first part of the run-in
845836 * for the rest of the run-in and for small kernel sizes, use the
@@ -979,7 +970,7 @@ static inline void __attribute__ ((always_inline)) conv2d_chw_str1 (
979970 int left_comp = -MIN ((clmn_begin * stride_width) - padding_left, 0 );
980971 int right_comp = -MIN (in_width - ((clmn_end * stride_width) - padding_left + kernel_width - 1 ), 0 );
981972
982- assert (stride_width == 1 );
973+ MLI_ASSERT (stride_width == 1 );
983974
984975 for (int out_ch_idx = 0 ; out_ch_idx < out_ch; out_ch_idx++) {
985976 int H_idx = 0 ;
@@ -1155,16 +1146,16 @@ static inline void __attribute__ ((always_inline)) conv2d_row_anystride (
11551146 out_ch_idx * out_width * out_height +
11561147 H_idx * out_width + clmn_begin;
11571148
1158- assert (H_idx < out_height);
1149+ MLI_ASSERT (H_idx < out_height);
11591150
11601151 /* for large kernel sizes use a loop for the first part of the run-in
11611152 * for the rest of the run-in and for small kernel sizes, use the
11621153 * unrolled part below.
11631154 */
11641155 if (pad_left > 0 ) {
11651156 for (; W_input_idx < left_comp; W_input_idx += stride_width) {
1166- MY_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1167- MY_ASSERT (weights_offset == -MIN (W_idx * stride_width - pad_left, 0 ));
1157+ MLI_EXTRA_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1158+ MLI_EXTRA_ASSERT (weights_offset == -MIN (W_idx * stride_width - pad_left, 0 ));
11681159
11691160 convolution (in_ptr, w_ptr + weights_offset, o_ptr, biases[out_ch_idx], bias_shift,
11701161 out_shift, val_min_limit, val_max_limit, in_width, in_height, kernel_w, kernel_h,
@@ -1186,8 +1177,8 @@ static inline void __attribute__ ((always_inline)) conv2d_row_anystride (
11861177
11871178 if ((kernel_w & 1 ) == 0 ) {
11881179 for (; W_input_idx < clmn_end * stride_width - right_comp; W_input_idx += stride_width) {
1189- MY_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1190- MY_ASSERT (W_input_idx + kernel_w - pad_left <= in_width);
1180+ MLI_EXTRA_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1181+ MLI_EXTRA_ASSERT (W_input_idx + kernel_w - pad_left <= in_width);
11911182
11921183 convolution_even (in_ptr, w_ptr, o_ptr, biases[out_ch_idx], bias_shift,
11931184 out_shift, val_min_limit, val_max_limit, in_width, in_height, kernel_w, kernel_h, kernel_w,
@@ -1200,8 +1191,8 @@ static inline void __attribute__ ((always_inline)) conv2d_row_anystride (
12001191
12011192 } else if ((kernel_w & 3 ) == 3 ) {
12021193 for (; W_input_idx < clmn_end * stride_width - right_comp; W_input_idx += stride_width) {
1203- MY_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1204- MY_ASSERT (W_input_idx + kernel_w - pad_left <= in_width);
1194+ MLI_EXTRA_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1195+ MLI_EXTRA_ASSERT (W_input_idx + kernel_w - pad_left <= in_width);
12051196
12061197 convolution_unroll4_plus3 (in_ptr, w_ptr, o_ptr, biases[out_ch_idx], bias_shift,
12071198 out_shift, val_min_limit, val_max_limit, in_width, in_height, kernel_w, kernel_h, kernel_w,
@@ -1214,8 +1205,8 @@ static inline void __attribute__ ((always_inline)) conv2d_row_anystride (
12141205
12151206 } else if ((kernel_w & 3 ) == 1 ) {
12161207 for (; W_input_idx < clmn_end * stride_width - right_comp; W_input_idx += stride_width) {
1217- MY_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1218- MY_ASSERT (W_input_idx + kernel_w - pad_left <= in_width);
1208+ MLI_EXTRA_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1209+ MLI_EXTRA_ASSERT (W_input_idx + kernel_w - pad_left <= in_width);
12191210
12201211 convolution_unroll4_plus1 (in_ptr, w_ptr, o_ptr, biases[out_ch_idx], bias_shift,
12211212 out_shift, val_min_limit, val_max_limit, in_width, in_height, kernel_w, kernel_h, kernel_w,
@@ -1228,8 +1219,8 @@ static inline void __attribute__ ((always_inline)) conv2d_row_anystride (
12281219
12291220 } else {
12301221 for (; W_input_idx < clmn_end * stride_width - right_comp; W_input_idx += stride_width) {
1231- MY_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1232- MY_ASSERT (W_input_idx + kernel_w - pad_left <= in_width);
1222+ MLI_EXTRA_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1223+ MLI_EXTRA_ASSERT (W_input_idx + kernel_w - pad_left <= in_width);
12331224
12341225 convolution (in_ptr, w_ptr, o_ptr, biases[out_ch_idx], bias_shift,
12351226 out_shift, val_min_limit, val_max_limit, in_width, in_height, kernel_w, kernel_h, kernel_w,
@@ -1246,7 +1237,7 @@ static inline void __attribute__ ((always_inline)) conv2d_row_anystride (
12461237 if (pad_right > 0 ) {
12471238 for (; W_input_idx < (clmn_end * stride_width); W_input_idx += stride_width) {
12481239 int clmns = kernel_w - MAX (W_input_idx + kernel_w - pad_left - in_width, 0 );
1249- MY_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
1240+ MLI_EXTRA_ASSERT ((in_ptr - in_ptr_start) == MAX (W_idx * stride_width - pad_left, 0 ));
12501241
12511242 convolution (in_ptr, w_ptr, o_ptr, biases[out_ch_idx], bias_shift,
12521243 out_shift, val_min_limit, val_max_limit, in_width, in_height, kernel_w, kernel_h, clmns, rows, in_ch);
0 commit comments