34 if (tensor ==
nullptr)
37 assert(!tensor->is_dynamic() &&
"Dynamic tensor is not supported yet");
39 const ir::Shape &shape = tensor->get_info().shape();
40 auto rank = shape.rank();
43 for (
int i = 0; i < rank; ++i)
45 data[i] = shape.dim(i);
55 assert(output !=
nullptr);
56 assert(input_backprop !=
nullptr);
61 return input_backprop;
64 assert(output_backprop !=
nullptr);
71 getShape(input_backprop), getBuffer<float>(input_backprop),
72 getShape(output_backprop), getBuffer<float>(output_backprop));
76 getShape(input_backprop), getBuffer<float>(input_backprop),
77 getShape(output_backprop), getBuffer<float>(output_backprop));
81 throw std::runtime_error(
"Unsupported activation type yet");
83 return output_backprop;
91 float *input_backprop_buffer =
reinterpret_cast<float *
>(input_backprop->
buffer());
94 float *bias_grad_buffer = getBuffer<float>(bias_grad);
97 bias_grad_buffer, bias_grad_shape);
109 throw std::runtime_error(
"Unsupported LossReductionType");
A tensor class that is portable for other backends.
virtual uint8_t * buffer() const =0
void biasReductionHelper(float *input_backprop_buffer, const Shape &input_backprop_shape, float *bias_grad_buffer, const Shape &bias_grad_shape)
void ReLUGrad(const Shape &output_shape, const float *output_data, const Shape &incoming_shape, const float *incoming_data, const Shape &grad_shape, float *grad_data)
void ReLU6Grad(const Shape &output_shape, const float *output_data, const Shape &incoming_shape, const float *incoming_data, const Shape &grad_shape, float *grad_data)
void biasGrad(const IPortableTensor *input_backprop, IPortableTensor *bias_grad)
backpropagate bias
const IPortableTensor * backpropActivation(const ir::Activation &activation, const IPortableTensor *output, const IPortableTensor *input_backprop, IPortableTensor *output_backprop)
backpropagate acitvation
nnfw::cker::Shape getShape(const IPortableTensor *tensor)
Get shape of tensor.
nnfw::cker::train::LossReductionType convertLossReductionType(ir::train::LossReductionType type)
convert loss reduction type