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

#include <PadLayer.h>

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

Public Member Functions

 PadLayer ()
 
template<typename T >
void depad ()
 
void configureBackward (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::PadLayer
 PadLayer ()
 
template<typename T >
void padImpl (const T *constant_value_data)
 
void configure (const IPortableTensor *input, const IPortableTensor *pad, const IPortableTensor *value, IPortableTensor *output)
 
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::PadLayer
const IPortableTensor_input
 
const IPortableTensor_pad
 
const IPortableTensor_value
 
IPortableTensor_output
 
ConstDataPtr _constantValueData
 

Detailed Description

Definition at line 37 of file PadLayer.h.

Constructor & Destructor Documentation

◆ PadLayer()

onert::backend::train::ops::PadLayer::PadLayer ( )

Definition at line 30 of file PadLayer.cc.

30 : cpu::ops::PadLayer(), _back_prop_input{nullptr}, _back_prop_output{nullptr}
31{
32 // DO NOTHING
33}

Member Function Documentation

◆ backward()

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

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

Definition at line 55 of file PadLayer.cc.

56{
57 switch (_back_prop_output->data_type())
58 {
59 case OperandType::FLOAT32:
60 depad<float>();
61 break;
62 case OperandType::QUANT_UINT8_ASYMM:
63 depad<uint8_t>();
64 break;
65 case OperandType::QUANT_INT8_ASYMM:
66 depad<int8_t>();
67 break;
68 default:
69 throw std::runtime_error{"Pad: unsupported data type"};
70 }
71}
ir::DataType data_type() const override final

References onert::backend::IPortableTensor::data_type().

◆ configureBackward()

void onert::backend::train::ops::PadLayer::configureBackward ( IPortableTensor back_prop_input,
const IPortableTensor back_prop_output 
)

Definition at line 46 of file PadLayer.cc.

48{
49 _back_prop_input = back_prop_input;
50 _back_prop_output = back_prop_output;
51}

◆ depad()

template<typename T >
void onert::backend::train::ops::PadLayer::depad ( )

Definition at line 35 of file PadLayer.cc.

36{
37 assert(_pad->data_type() == onert::ir::DataType::INT32);
38 assert(_pad->buffer());
39 const auto pad_data = reinterpret_cast<const int32_t *>(_pad->buffer());
40 auto pad_rank = _pad->getShape().dim(0);
41 nnfw::cker::train::Depad<T>(pad_data, pad_rank, getShape(_back_prop_output),
42 getBuffer<T>(_back_prop_output), getShape(_back_prop_input),
43 getBuffer<T>(_back_prop_input));
44}
ir::Shape getShape() const override final
Get ir::Shape of tensor.
virtual uint8_t * buffer() const =0
const IPortableTensor * _pad
Definition PadLayer.h:51
nnfw::cker::Shape getShape(const IPortableTensor *tensor)
Get shape of tensor.

References onert::backend::cpu::ops::PadLayer::_pad, onert::backend::ITensor::buffer(), onert::backend::IPortableTensor::data_type(), onert::backend::IPortableTensor::getShape(), and onert::backend::train::ops::getShape().

◆ forward()

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

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