ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::train::ops::ConvolutionLayer Class Reference

#include <ConvolutionLayer.h>

Collaboration diagram for onert::backend::train::ops::ConvolutionLayer:

Public Member Functions

 ConvolutionLayer ()
 
 ~ConvolutionLayer ()
 
void configureBackward (const IPortableTensor *weights, IPortableTensor *back_prop_input, IPortableTensor *grad_weights, IPortableTensor *grad_bias, const IPortableTensor *back_prop_output, const ir::Activation activation)
 
void forward (bool training) override
 
void backward () override
 
- Public Member Functions inherited from onert::exec::train::ITrainableFunction
virtual ~ITrainableFunction ()=default
 
virtual std::optional< backend::train::LayerScopeTensorsregisterLayerScopeTensors ()
 
- Public Member Functions inherited from onert::backend::cpu::ops::ConvolutionLayer
 ConvolutionLayer ()
 
 ~ConvolutionLayer ()
 
void configure (const IPortableTensor *input, const IPortableTensor *kernel, const IPortableTensor *bias, ir::PaddingType _paddingType, const uint32_t paddingLeft, const uint32_t paddingRight, const uint32_t paddingTop, const uint32_t paddingBottom, const uint32_t strideWidth, const uint32_t strideHeight, const uint32_t dilationWidthFactor, const uint32_t dilationHeightFactor, const ir::Activation activation, IPortableTensor *output, bool is_cachable_weights)
 
void prepare () override
 
void run () override
 
- Public Member Functions inherited from onert::exec::IFunction
virtual ~IFunction ()=default
 

Additional Inherited Members

- Protected Attributes inherited from onert::backend::cpu::ops::ConvolutionLayer
const IPortableTensor_input
 
const IPortableTensor_kernel
 
const IPortableTensor_bias
 
IPortableTensor_output
 
ir::PaddingType _paddingType
 
uint32_t _paddingLeft
 
uint32_t _paddingTop
 
uint32_t _paddingRight
 
uint32_t _paddingBottom
 
uint32_t _strideWidth
 
uint32_t _strideHeight
 
uint32_t _dilationWidthFactor
 
uint32_t _dilationHeightFactor
 
ir::Activation _activation
 
std::unique_ptr< nnfw::cker::Conv_conv_kernel
 
std::unique_ptr< nnfw::cker::ConvHybridTempArena_hybrid_arena
 
bool _prepare
 
bool _is_cachable_weights
 
bool _is_hybrid
 

Detailed Description

Definition at line 34 of file ConvolutionLayer.h.

Constructor & Destructor Documentation

◆ ConvolutionLayer()

onert::backend::train::ops::ConvolutionLayer::ConvolutionLayer ( )

Definition at line 59 of file ConvolutionLayer.cc.

60 : cpu::ops::ConvolutionLayer(), _grad_weights{nullptr}, _grad_bias{nullptr},
61 _back_prop_input{nullptr}, _back_prop_output{nullptr}, _transposed_weights{nullptr}
62{
63 // DO NOTHING
64}

◆ ~ConvolutionLayer()

onert::backend::train::ops::ConvolutionLayer::~ConvolutionLayer ( )
default

Member Function Documentation

◆ backward()

void onert::backend::train::ops::ConvolutionLayer::backward ( )
overridevirtual

Implements onert::exec::train::ITrainableFunction.

Definition at line 104 of file ConvolutionLayer.cc.

105{
106 const auto data_type = _back_prop_output->data_type();
107 assert(data_type == _input->data_type());
108 switch (data_type)
109 {
110 case OperandType::FLOAT32:
111 {
112 assert(data_type == _grad_bias->data_type());
113 backwardFloat32();
114 break;
115 }
116 default:
117 throw std::runtime_error{"train ConvolutionLayer: unsupported data type"};
118 }
119}
ir::DataType data_type() const override final

References onert::backend::cpu::ops::ConvolutionLayer::_input, and onert::backend::IPortableTensor::data_type().

◆ configureBackward()

void onert::backend::train::ops::ConvolutionLayer::configureBackward ( const IPortableTensor weights,
IPortableTensor back_prop_input,
IPortableTensor grad_weights,
IPortableTensor grad_bias,
const IPortableTensor back_prop_output,
const ir::Activation  activation 
)

Definition at line 68 of file ConvolutionLayer.cc.

73{
74 _back_prop_input = back_prop_input;
75 _grad_weights = grad_weights;
76 _grad_bias = grad_bias;
77 _back_prop_output = back_prop_output;
78
80 throw std::runtime_error("train ConvolutionLayer: Unsupported dilation yet");
81
82 // TODO Optimize transposed tensors
83 _transposed_weights = createTransposedWeights<Tensor>(weights);
84 _transposed_weights->setBuffer(
85 std::make_shared<basic::Allocator>(_transposed_weights->total_size()));
86
87 _conv_back_prop_output = std::make_unique<BackPropTensor>(back_prop_output->get_info());
88 _conv_back_prop_output->setBuffer(
89 std::make_shared<basic::Allocator>(_conv_back_prop_output->total_size()));
90
91 _transposed_grad_weights = createTransposedWeights<GradientTensor>(weights);
92 _transposed_grad_weights->setBuffer(
93 std::make_shared<basic::Allocator>(_transposed_grad_weights->total_size()));
94
95 if (activation != ir::Activation::NONE)
96 {
97 _act_back_prop_output = std::make_unique<BackPropTensor>(_back_prop_output->get_info());
98 _act_back_prop_output->setBuffer(
99 std::make_shared<basic::Allocator>(_act_back_prop_output->total_size()));
100 }
101}
const ir::OperandInfo & get_info() const

References onert::backend::cpu::ops::ConvolutionLayer::_dilationHeightFactor, onert::backend::cpu::ops::ConvolutionLayer::_dilationWidthFactor, onert::backend::IPortableTensor::get_info(), and onert::ir::NONE.

◆ forward()

void onert::backend::train::ops::ConvolutionLayer::forward ( bool  training)
overridevirtual

The documentation for this class was generated from the following files: