ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::builtin::train::kernel::PermuteLayer Class Reference

#include <PermuteLayer.h>

Collaboration diagram for onert::backend::builtin::train::kernel::PermuteLayer:

Public Member Functions

 PermuteLayer (const std::vector< ITensor * > &src_tensors, const std::vector< ITensor * > &dst_tensors, const std::vector< ITensor * > &input_back_prop_tensors, const std::vector< ITensor * > &output_back_prop_tensors, const std::vector< ir::PermuteType > &types, bool ignore_forward_in_training, const std::shared_ptr< ExternalContext > &external_context)
 
void optimize () override
 
void forward (bool training) override
 
void backward () override
 
- Public Member Functions inherited from onert::backend::builtin::kernel::PermuteLayer
 PermuteLayer (const std::vector< ITensor * > &src_tensors, const std::vector< ITensor * > &dst_tensors, const std::vector< ir::PermuteType > &types, const std::shared_ptr< ExternalContext > &external_context)
 
void run () override
 
- Public Member Functions inherited from onert::exec::IPermuteFunction
virtual void prepare () override
 
- Public Member Functions inherited from onert::exec::IFunction
virtual ~IFunction ()=default
 
- Public Member Functions inherited from onert::exec::train::ITrainableFunction
virtual ~ITrainableFunction ()=default
 
virtual std::optional< backend::train::LayerScopeTensorsregisterLayerScopeTensors ()
 

Additional Inherited Members

- Protected Member Functions inherited from onert::exec::IPermuteFunction
void permute (backend::ITensor *src_tensor, backend::ITensor *dst_tensor, size_t rank, std::vector< size_t > &src_offsets, std::vector< size_t > &dst_offsets, const ir::PermuteType &permute_type)
 
const std::type_info & underlying_type (ir::DataType type) const
 
- Protected Attributes inherited from onert::exec::IPermuteFunction
std::vector< backend::ITensor * > _src_tensors
 
std::vector< backend::ITensor * > _dst_tensors
 
std::vector< std::vector< size_t > > _src_tensors_offsets
 
std::vector< std::vector< size_t > > _dst_tensors_offsets
 
std::vector< ir::PermuteType_permute_types
 
std::unordered_map< const backend::ITensor *, std::vector< uint8_t > > _buffers_map
 

Detailed Description

Definition at line 35 of file PermuteLayer.h.

Constructor & Destructor Documentation

◆ PermuteLayer()

onert::backend::builtin::train::kernel::PermuteLayer::PermuteLayer ( const std::vector< ITensor * > &  src_tensors,
const std::vector< ITensor * > &  dst_tensors,
const std::vector< ITensor * > &  input_back_prop_tensors,
const std::vector< ITensor * > &  output_back_prop_tensors,
const std::vector< ir::PermuteType > &  types,
bool  ignore_forward_in_training,
const std::shared_ptr< ExternalContext > &  external_context 
)

Definition at line 32 of file PermuteLayer.cc.

39 : builtin::kernel::PermuteLayer{src_tensors, dst_tensors, types, external_context},
40 _input_back_prop_tensors{input_back_prop_tensors},
41 _output_back_prop_tensors{output_back_prop_tensors},
42 _ignore_forward_in_training{ignore_forward_in_training}
43{
44 assert(input_back_prop_tensors.size() == output_back_prop_tensors.size());
45 assert(src_tensors.size() == dst_tensors.size());
46}

Member Function Documentation

◆ backward()

void onert::backend::builtin::train::kernel::PermuteLayer::backward ( )
overridevirtual

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

Definition at line 63 of file PermuteLayer.cc.

64{
65 for (uint32_t i = 0; i < _output_back_prop_tensors.size(); ++i)
66 {
67 auto src_back_prop = _output_back_prop_tensors.at(i);
68 auto dst_back_prop = _input_back_prop_tensors.at(i);
69
70 // NOTE The back propagation tensors corresponding to inputs/outputs of model are nullptr
71 // because permuting those tensors is meaningless
72 if (src_back_prop && dst_back_prop)
73 {
74 const auto rank = src_back_prop->getShape().rank();
75 auto output_offsets = _dst_tensors_offsets.at(i);
76 auto input_offsets = _src_tensors_offsets.at(i);
77 auto permute_type = _permute_types.at(i);
78
79 exec::IPermuteFunction::permute(src_back_prop, dst_back_prop, rank, output_offsets,
80 input_offsets, permute_type);
81 }
82 }
83}
std::vector< std::vector< size_t > > _dst_tensors_offsets
std::vector< ir::PermuteType > _permute_types
void permute(backend::ITensor *src_tensor, backend::ITensor *dst_tensor, size_t rank, std::vector< size_t > &src_offsets, std::vector< size_t > &dst_offsets, const ir::PermuteType &permute_type)
std::vector< std::vector< size_t > > _src_tensors_offsets

References onert::exec::IPermuteFunction::_dst_tensors_offsets, onert::exec::IPermuteFunction::_permute_types, onert::exec::IPermuteFunction::_src_tensors_offsets, and onert::exec::IPermuteFunction::permute().

◆ forward()

void onert::backend::builtin::train::kernel::PermuteLayer::forward ( bool  training)
overridevirtual

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

Definition at line 55 of file PermuteLayer.cc.

56{
57 if (_ignore_forward_in_training)
58 return;
59
61}

References onert::backend::builtin::kernel::PermuteLayer::run().

◆ optimize()

void onert::backend::builtin::train::kernel::PermuteLayer::optimize ( )
overridevirtual

Reimplemented from onert::backend::builtin::kernel::PermuteLayer.

Definition at line 48 of file PermuteLayer.cc.

49{
51
52 // TODO Calculate offsets of back propagation tensors if necessary
53}

References onert::backend::builtin::kernel::PermuteLayer::optimize().


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