56 const circle::Tensor *input;
57 const circle::Tensor *weight;
58 const circle::Tensor *output;
65 const circle::DepthwiseConv2DOptions *options;
73 input = runtime_kernel.
inputs[inputTensorIdx];
74 weight = runtime_kernel.
inputs[weightTensorIdx];
75 output = runtime_kernel.
outputs[outputTensorIdx];
76 assert(input !=
nullptr);
77 assert(weight !=
nullptr);
79 assert(output !=
nullptr);
81 status = runtime_kernel.
getDataFromStorage(op_index, runtime_storage, runtime_context);
85 input_data = runtime_kernel.
inputs_data[inputTensorIdx];
86 weight_data = runtime_kernel.
inputs_data[weightTensorIdx];
87 bias_data = runtime_kernel.
inputs_data[biasTensorIdx];
88 output_data = runtime_kernel.
outputs_data[outputTensorIdx];
89 assert(input_data !=
nullptr);
90 assert(weight_data !=
nullptr);
92 assert(output_data !=
nullptr);
94 options = runtime_kernel.
first_operator->builtin_options_as_DepthwiseConv2DOptions();
99 int32_t padding_h = 0;
100 int32_t padding_w = 0;
105 const int input_width = input_shape.
dims(2);
106 const int input_height = input_shape.
dims(1);
107 const int weight_width = weight_shape.
dims(2);
108 const int weight_height = weight_shape.
dims(1);
110 options->dilation_h_factor(), options->dilation_w_factor(),
111 input_height, input_width, weight_height, weight_width,
112 options->padding(), &padding_h, &padding_w);
116 switch (input->type())
119 case circle::TensorType_FLOAT32:
124 ¶ms.activation_min, ¶ms.activation_max);
125 params.stride_w = options->stride_w();
126 params.stride_h = options->stride_h();
127 params.dilation_width_factor = options->dilation_w_factor();
128 params.dilation_height_factor = options->dilation_h_factor();
129 params.depth_multiplier = options->depth_multiplier();
130 params.pad_h = padding_h;
131 params.pad_w = padding_w;
137 ¶ms, input_shape, core::utils::castInputData<float>(input_data), weight_shape,
138 core::utils::castInputData<float>(weight_data),
139 core::utils::castInputData<float>(bias_data),
output_shape,
140 core::utils::castOutputData<float>(output_data));
141 assert(status ==
Ok);
146 case circle::TensorType_INT8:
149 params.
pad_h = padding_h;
150 params.pad_w = padding_w;
151 params.depth_multiplier = options->depth_multiplier();
153 const auto padding = options->padding();
154 const auto stride_height = options->stride_h();
155 const auto stride_width = options->stride_w();
156 const auto dilation_height_factor = options->dilation_h_factor();
157 const auto dilation_width_factor = options->dilation_h_factor();
159 params.stride_height = stride_height;
160 params.stride_width = stride_width;
161 params.dilation_height_factor = dilation_height_factor;
162 params.dilation_width_factor = dilation_width_factor;
165 createConvParams(params, input, weight, output, options->fused_activation_function());
166 assert(status ==
Ok);
171 params, input_shape, core::utils::castInputData<int8_t>(input_data), weight_shape,
172 core::utils::castInputData<int8_t>(weight_data),
173 core::utils::castInputData<int32_t>(bias_data),
output_shape,
174 core::utils::castOutputData<int8_t>(output_data));
181 assert(
false &&
"Unsupported 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)