59 const tflite::DepthwiseParams ¶ms,
const int32_t *output_multiplier,
60 const int32_t *output_shift,
const tflite::RuntimeShape &input_shape,
const int8_t *input_data,
61 const tflite::RuntimeShape &filter_shape,
const int8_t *filter_data,
62 const tflite::RuntimeShape &bias_shape,
const int32_t *bias_data,
63 const tflite::RuntimeShape &
output_shape, int8_t *output_data,
64 const tflite::RuntimeShape &scratchpad_shape, int8_t *scratchpad_data)
68 cmsis_nn_dw_conv_params dw_conv_params;
69 dw_conv_params.dilation.h = params.dilation_height_factor;
70 dw_conv_params.dilation.w = params.dilation_width_factor;
71 assert(dw_conv_params.dilation.h == 1);
72 assert(dw_conv_params.dilation.w == 1);
74 dw_conv_params.input_offset = params.input_offset;
75 dw_conv_params.output_offset = params.output_offset;
76 dw_conv_params.stride.h = params.stride_height;
77 dw_conv_params.stride.w = params.stride_width;
78 dw_conv_params.padding.h = params.padding_values.height;
79 dw_conv_params.padding.w = params.padding_values.width;
81 dw_conv_params.activation.min = params.quantized_activation_min;
82 dw_conv_params.activation.max = params.quantized_activation_max;
83 dw_conv_params.ch_mult = params.depth_multiplier;
85 cmsis_nn_per_channel_quant_params quant_params;
86 int32_t output_multiplier = params.output_multiplier;
87 int32_t output_shift = params.output_shift;
89 quant_params.multiplier = &output_multiplier;
90 quant_params.shift = &output_shift;
92 assert(dw_conv_params.activation.min <= dw_conv_params.activation.max);
93 const int batch_size = tflite::MatchingDim(input_shape, 0,
output_shape, 0);
94 const int output_depth = tflite::MatchingDim(filter_shape, 3,
output_shape, 3);
97 assert(bias_shape.FlatSize() == output_depth);
100 cmsis_nn_dims input_dims;
101 input_dims.n = batch_size;
102 input_dims.h = input_shape.Dims(1);
103 input_dims.w = input_shape.Dims(2);
104 input_dims.c = input_shape.Dims(3);
106 cmsis_nn_dims filter_dims;
107 filter_dims.n = filter_shape.Dims(0);
108 filter_dims.h = filter_shape.Dims(1);
109 filter_dims.w = filter_shape.Dims(2);
110 filter_dims.c = output_depth;
112 cmsis_nn_dims bias_dims;
116 bias_dims.c = output_depth;
118 cmsis_nn_dims output_dims;
119 output_dims.n = batch_size;
122 output_dims.c = output_depth;
124 cmsis_nn_context ctx;
125 ctx.buf = scratchpad_data;
126 ctx.size = scratchpad_shape.Dims(0);
128 auto res = arm_depthwise_conv_wrapper_s8(&ctx, &dw_conv_params, &quant_params, &input_dims,
129 input_data, &filter_dims, filter_data, &bias_dims,
130 bias_data, &output_dims, output_data);
131 assert(res == ARM_MATH_SUCCESS);
135 tflite::reference_integer_ops::DepthwiseConvPerChannel(
136 params, output_multiplier, output_shift, input_shape, input_data, filter_shape, filter_data,
void DepthwiseConvPerChannel< int8_t >(const tflite::DepthwiseParams ¶ms, const int32_t *output_multiplier, const int32_t *output_shift, const tflite::RuntimeShape &input_shape, const int8_t *input_data, const tflite::RuntimeShape &filter_shape, const int8_t *filter_data, const tflite::RuntimeShape &bias_shape, const int32_t *bias_data, const tflite::RuntimeShape &output_shape, int8_t *output_data, const tflite::RuntimeShape &scratchpad_shape, int8_t *scratchpad_data)
void DepthwiseConvPerChannel(const DepthwiseConvParams ¶ms, const int32_t *output_multiplier, const int32_t *output_shift, const Shape &input_shape, const int8_t *input_data, const Shape &filter_shape, const int8_t *filter_data, const Shape &bias_shape, const int32_t *bias_data, const Shape &output_shape, int8_t *output_data, ruy::Context *ruy_context)