28 if (tensor ==
nullptr)
31 assert(!tensor->is_dynamic() &&
"Dynamic tensor is not supported yet");
33 const ir::Shape &shape = tensor->get_info().shape();
34 auto rank = shape.rank();
37 for (
int i = 0; i < rank; ++i)
39 data[i] = shape.dim(i);
49 assert(output !=
nullptr);
50 assert(input_backprop !=
nullptr);
55 return input_backprop;
58 assert(output_backprop !=
nullptr);
65 getShape(input_backprop), getBuffer<float>(input_backprop),
66 getShape(output_backprop), getBuffer<float>(output_backprop));
70 getShape(input_backprop), getBuffer<float>(input_backprop),
71 getShape(output_backprop), getBuffer<float>(output_backprop));
75 throw std::runtime_error(
"Unsupported activation type yet");
77 return output_backprop;
85 float *input_backprop_buffer =
reinterpret_cast<float *
>(input_backprop->
buffer());
88 float *bias_grad_buffer = getBuffer<float>(bias_grad);
91 bias_grad_buffer, bias_grad_shape);
103 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