32constexpr uint32_t inputTensorIdx = 0;
33constexpr uint32_t weightTensorIdx = 1;
34constexpr uint32_t biasTensorIdx = 2;
49 uint16_t op_index =
args.kernel_index;
51 const circle::Tensor *
input;
52 const circle::Tensor *weight;
53 const circle::Tensor *
output;
55 int32_t weight_tensor_index = -1;
58 uint8_t *dloss_dinput_data;
61 uint8_t *dloss_dweight_data;
64 uint8_t *dloss_dbias_data;
67 uint8_t *dloss_doutput_data;
69 const circle::Conv2DOptions *
options;
76 weight = runtime_kernel.
inputs[weightTensorIdx];
78 assert(input !=
nullptr);
79 assert(weight !=
nullptr);
81 assert(output !=
nullptr);
83 weight_tensor_index = runtime_kernel.
inputs_index[weightTensorIdx];
84 assert(weight_tensor_index != -1);
91 weight_data = runtime_kernel.
inputs_data[weightTensorIdx];
92 bias_data = runtime_kernel.
inputs_data[biasTensorIdx];
97 assert(weight_data !=
nullptr);
104 dloss_dinput_data = runtime_kernel.
inputs_data[inputTensorIdx];
105 dloss_dweight_data = runtime_kernel.
inputs_data[weightTensorIdx];
106 dloss_dbias_data = runtime_kernel.
inputs_data[biasTensorIdx];
110 assert(dloss_dweight_data !=
nullptr);
111 assert(dloss_doutput_data !=
nullptr);
122 switch (
options->fused_activation_function())
124 case circle::ActivationFunctionType_NONE:
127 case circle::ActivationFunctionType_RELU:
129 assert(output_data !=
nullptr);
131 utils::castOutputData<float>(dloss_doutput_data),
output_shape);
136 assert(
false &&
"Unsupported activation type");
141 const int input_width = input_shape.dims(3);
142 const int input_height = input_shape.dims(2);
149 params.stride_h =
options->stride_h();
150 params.dilation_width_factor =
options->dilation_w_factor();
151 params.dilation_height_factor =
options->dilation_h_factor();
155 if (
args.is_trainable_layer)
160 assert(input_data !=
nullptr);
165 weight_shape = dynamic_shapes;
169 output_shape, utils::castInputData<float>(dloss_doutput_data),
170 weight_shape, utils::castOutputData<float>(dloss_dweight_data),
171 args.train_rank_type);
175 if (dloss_dbias_data)
177 assert(bias_data !=
nullptr);
178 if (bias_data ==
nullptr)
182 utils::castOutputData<float>(dloss_dbias_data));
187 if (
args.is_last_layer ==
false)
189 assert(dloss_dinput_data !=
nullptr);
191 output_shape, utils::castInputData<float>(dloss_doutput_data), input_shape,
192 utils::castOutputData<float>(dloss_dinput_data));
int32_t dims(int i) const
OMRuntimeShape getDynamicRuntimeShape(uint16_t tensor_index)
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]
int32_t inputs_index[maxInputSize]
const circle::Tensor * inputs[maxInputSize]
const luci_interpreter::RuntimeShape output_shape
constexpr uint32_t outputTensorIdx
void ReluInputGrad(const float *input_relu_data, float *dloss_doutput_data, const core::OMRuntimeShape &dloss_doutput_shape)
void Conv2DWeightGrad(const core::FloatConv2D ¶ms, const core::OMRuntimeShape &input_shape, const float *input_data, const core::OMRuntimeShape &dloss_doutput_shape, const float *dloss_doutput_data, const core::OMRuntimeShape &dloss_dweight_shape, float *dloss_dweight_data, core::OpTrainableRankType rank)
void Conv2DInputGrad(const core::FloatConv2D ¶ms, const core::OMRuntimeShape &weight_shape, const float *weight_data, const core::OMRuntimeShape &dloss_doutput_shape, const float *dloss_doutput_data, const core::OMRuntimeShape &dloss_dinput_shape, float *dloss_dinput_data)
void Conv2DBiasGrad(const core::OMRuntimeShape &dloss_doutput_shape, const float *dloss_doutput_data, float *dloss_dbias_data)