27#include "PALDepthwiseConv2D.h"
36constexpr uint32_t inputTensorIdx = 0;
37constexpr uint32_t weightTensorIdx = 1;
38constexpr uint32_t biasTensorIdx = 2;
46onert_micro::execute::execute_kernel_CircleDepthwiseConv2D(
const OMExecuteArgs &execute_args)
52 const circle::Tensor *
input;
53 const circle::Tensor *weight;
54 const circle::Tensor *
output;
61 const circle::DepthwiseConv2DOptions *
options;
70 weight = runtime_kernel.
inputs[weightTensorIdx];
72 assert(input !=
nullptr);
73 assert(weight !=
nullptr);
75 assert(output !=
nullptr);
77 status = runtime_kernel.
getDataFromStorage(op_index, runtime_storage, runtime_context);
82 weight_data = runtime_kernel.
inputs_data[weightTensorIdx];
83 bias_data = runtime_kernel.
inputs_data[biasTensorIdx];
85 assert(input_data !=
nullptr);
86 assert(weight_data !=
nullptr);
88 assert(output_data !=
nullptr);
95 int32_t padding_h = 0;
96 int32_t padding_w = 0;
101 const int input_width = input_shape.dims(2);
102 const int input_height = input_shape.dims(1);
103 const int weight_width = weight_shape.dims(2);
104 const int weight_height = weight_shape.dims(1);
107 input_height, input_width, weight_height, weight_width,
108 options->padding(), &padding_h, &padding_w);
112 switch (
input->type())
115 case circle::TensorType_FLOAT32:
120 ¶ms.activation_min, ¶ms.activation_max);
121 params.stride_w =
options->stride_w();
122 params.stride_h =
options->stride_h();
123 params.dilation_width_factor =
options->dilation_w_factor();
124 params.dilation_height_factor =
options->dilation_h_factor();
125 params.depth_multiplier =
options->depth_multiplier();
126 params.pad_h = padding_h;
127 params.pad_w = padding_w;
133 ¶ms, input_shape, core::utils::castInputData<float>(input_data), weight_shape,
134 core::utils::castInputData<float>(weight_data),
135 core::utils::castInputData<float>(bias_data),
output_shape,
136 core::utils::castOutputData<float>(output_data));
137 assert(status ==
Ok);
142 case circle::TensorType_INT8:
145 params.
pad_h = padding_h;
146 params.pad_w = padding_w;
147 params.depth_multiplier =
options->depth_multiplier();
149 const auto padding =
options->padding();
150 const auto stride_height =
options->stride_h();
151 const auto stride_width =
options->stride_w();
152 const auto dilation_height_factor =
options->dilation_h_factor();
153 const auto dilation_width_factor =
options->dilation_h_factor();
155 params.stride_height = stride_height;
156 params.stride_width = stride_width;
157 params.dilation_height_factor = dilation_height_factor;
158 params.dilation_width_factor = dilation_width_factor;
162 assert(status ==
Ok);
167 params, input_shape, core::utils::castInputData<int8_t>(input_data), weight_shape,
168 core::utils::castInputData<int8_t>(weight_data),
169 core::utils::castInputData<int32_t>(bias_data),
output_shape,
170 core::utils::castOutputData<int8_t>(output_data));
177 assert(
false &&
"Unsupported type.");
uint8_t * outputs_data[maxOutputSize]
const circle::Operator * first_operator
OMStatus getDataFromStorage(uint16_t op_index, core::OMRuntimeStorage &storage, core::OMRuntimeContext &context)
uint8_t * inputs_data[maxInputSize]
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
const luci_interpreter::RuntimeShape output_shape
constexpr uint32_t outputTensorIdx
OMStatus DepthwiseConv2D< float >(const core::FloatConv2D *params, const core::OMRuntimeShape &input_shape, const float *input_data, const core::OMRuntimeShape &filter_shape, const float *filter_data, const float *bias_data, const core::OMRuntimeShape &output_shape, float *output_data)
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)
OMStatus calculateActivationRange(circle::ActivationFunctionType activation, T *activation_min, T *activation_max)
OMStatus createConvParams(core::ConvQuant ¶ms, const circle::Tensor *input, const circle::Tensor *filter, const circle::Tensor *output, circle::ActivationFunctionType act_type)
void computePaddingHeightWidth(int32_t stride_height, int32_t stride_width, int32_t dilation_rate_height, int32_t dilation_rate_width, int32_t in_height, int32_t in_width, int32_t filter_height, int32_t filter_width, circle::Padding padding, int32_t *padding_h, int32_t *padding_w)
core::OMRuntimeContext & runtime_context
core::OMRuntimeStorage & runtime_storage