39 const int8_t *filter_data,
const int32_t *bias_data,
42 cmsis_nn_dw_conv_params conv_params;
46 assert(conv_params.dilation.h == 1);
47 assert(conv_params.dilation.w == 1);
53 conv_params.padding.h = params.
pad_h;
54 conv_params.padding.w = params.
pad_w;
59 cmsis_nn_per_channel_quant_params quant_params;
61 quant_params.shift =
const_cast<int32_t *
>(
64 assert(conv_params.activation.min <= conv_params.activation.max);
65 const int batch_size = input_shape.
dims(0);
66 const int input_depth = input_shape.
dims(3);
67 const int output_depth = filter_shape.
dims(0);
69 cmsis_nn_dims input_dims;
70 input_dims.n = batch_size;
71 input_dims.h = input_shape.
dims(1);
72 input_dims.w = input_shape.
dims(2);
73 input_dims.c = input_depth;
75 cmsis_nn_dims filter_dims;
76 filter_dims.n = output_depth;
77 filter_dims.h = filter_shape.
dims(1);
78 filter_dims.w = filter_shape.
dims(2);
79 filter_dims.c = input_depth;
81 cmsis_nn_dims bias_dims;
85 bias_dims.c = output_depth;
87 cmsis_nn_dims output_dims;
88 output_dims.n = batch_size;
91 output_dims.c = output_depth;
93 auto buf_size = arm_depthwise_conv_wrapper_s8_get_buffer_size(&conv_params, &input_dims,
94 &filter_dims, &output_dims);
96 auto buffer = std::make_unique<int8_t[]>(buf_size);
97 assert(buffer !=
nullptr);
100 ctx.buf = buffer.get();
103 auto res = arm_depthwise_conv_wrapper_s8(&ctx, &conv_params, &quant_params, &input_dims,
104 input_data, &filter_dims, filter_data, &bias_dims,
105 bias_data, &output_dims, output_data);
107 assert(res == ARM_CMSIS_NN_SUCCESS);
108 if (res != ARM_CMSIS_NN_SUCCESS)
OMStatus DepthwiseConvPerChannel(const core::ConvQuant ¶ms, const core::OMRuntimeShape &input_shape, const int8_t *input_data, const core::OMRuntimeShape &filter_shape, const int8_t *filter_data, const int32_t *bias_data, const core::OMRuntimeShape &output_shape, int8_t *output_data)