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

#include <PoolLayer.h>

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

Public Member Functions

 PoolLayer ()
 
void configureBackward (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 kernelWidth, const uint32_t kernelHeight, const ir::Activation activation, const PoolType op_type, IPortableTensor *output, IPortableTensor *back_prop_input, const IPortableTensor *back_prop_output)
 
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::PoolLayer
 PoolLayer ()
 
void configure (const IPortableTensor *input, 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 kernelWidth, const uint32_t kernelHeight, const ir::Activation activation, IPortableTensor *output, const PoolType op_type)
 
void run () override
 
- Public Member Functions inherited from onert::exec::IFunction
virtual ~IFunction ()=default
 
virtual void prepare ()
 

Additional Inherited Members

- Protected Attributes inherited from onert::backend::cpu::ops::PoolLayer
const IPortableTensor_input
 
IPortableTensor_output
 

Detailed Description

Definition at line 51 of file PoolLayer.h.

Constructor & Destructor Documentation

◆ PoolLayer()

onert::backend::train::ops::PoolLayer::PoolLayer ( )

Definition at line 188 of file PoolLayer.cc.

189 : cpu::ops::PoolLayer(), _back_prop_input(nullptr), _back_prop_output(nullptr), _kernel(nullptr)
190{
191 // DO NOTHING
192}

Member Function Documentation

◆ backward()

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

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

Definition at line 240 of file PoolLayer.cc.

240{ _kernel->backward(_back_prop_output, _back_prop_input); }

◆ configureBackward()

void onert::backend::train::ops::PoolLayer::configureBackward ( 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  kernelWidth,
const uint32_t  kernelHeight,
const ir::Activation  activation,
const PoolType  op_type,
IPortableTensor output,
IPortableTensor back_prop_input,
const IPortableTensor back_prop_output 
)

Definition at line 194 of file PoolLayer.cc.

201{
202 _back_prop_output = back_prop_output;
203 _back_prop_input = back_prop_input;
204
205 if (output->data_type() != OperandType::FLOAT32)
206 {
207 throw std::runtime_error("PoolLayer : Unsupported data type for training");
208 }
209
210 // ready training kernel
211 switch (op_type)
212 {
213 case PoolType::kMax:
214 _kernel = std::make_unique<MaxPool2D>(paddingLeft, paddingRight, paddingTop, paddingBottom,
215 strideWidth, strideHeight, kernelWidth, kernelHeight,
216 activation, output);
217 break;
218 case PoolType::kAvg:
219 _kernel = std::make_unique<AveragePool2D>(paddingLeft, paddingRight, paddingTop,
220 paddingBottom, strideWidth, strideHeight,
221 kernelWidth, kernelHeight, activation, output);
222 break;
223 default:
224 throw std::runtime_error("PoolLayer: Unsupported pool type");
225 }
226}

References onert::backend::train::ops::kAvg, and onert::backend::train::ops::kMax.

◆ forward()

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

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

Definition at line 228 of file PoolLayer.cc.

229{
230 if (training)
231 {
232 _kernel->forward(_input, _output);
233 }
234 else
235 {
237 }
238}
const IPortableTensor * _input
Definition PoolLayer.h:57

References onert::backend::cpu::ops::PoolLayer::_input, onert::backend::cpu::ops::PoolLayer::_output, and onert::backend::cpu::ops::PoolLayer::run().


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