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

#include <PackLayer.h>

Collaboration diagram for onert::backend::cpu::ops::PackLayer:

Public Member Functions

 PackLayer ()
 
template<typename T >
void packImpl ()
 
void configure (const std::vector< const IPortableTensor * > &inputs, int32_t axis, IPortableTensor *output)
 
void run () override
 
- Public Member Functions inherited from onert::exec::IFunction
virtual ~IFunction ()=default
 
virtual void prepare ()
 

Detailed Description

Definition at line 33 of file PackLayer.h.

Constructor & Destructor Documentation

◆ PackLayer()

onert::backend::cpu::ops::PackLayer::PackLayer ( )

Definition at line 32 of file PackLayer.cc.

32 : _inputs(), _output(nullptr), _axis(0)
33{
34 // DO NOTHING
35}

Member Function Documentation

◆ configure()

void onert::backend::cpu::ops::PackLayer::configure ( const std::vector< const IPortableTensor * > &  inputs,
int32_t  axis,
IPortableTensor output 
)

Definition at line 65 of file PackLayer.cc.

67{
68 assert(inputs.size() > 0);
69 assert(output != nullptr);
70
71 _inputs = inputs;
72 _axis = axis;
73 _output = output;
74}

◆ packImpl()

template<typename T >
void onert::backend::cpu::ops::PackLayer::packImpl ( )

Definition at line 37 of file PackLayer.cc.

38{
39 uint32_t num_inputs = _inputs.size();
40 nnfw::cker::PackParams op_params;
41 op_params.axis = _axis;
42 op_params.inputs_count = num_inputs;
43
44 std::vector<nnfw::cker::Shape *> inputDimsPtr;
45 std::vector<nnfw::cker::Shape> inputDims;
46 inputDimsPtr.reserve(num_inputs);
47 inputDims.reserve(num_inputs);
48
49 for (uint32_t i = 0; i < num_inputs; i++)
50 {
51 inputDims.push_back(getShape(_inputs[i]));
52 inputDimsPtr.push_back(&inputDims[i]);
53 }
54
55 std::vector<const T *> inputPtrs;
56
57 for (const auto input : _inputs)
58 {
59 inputPtrs.emplace_back(getBuffer<T>(input));
60 }
61
62 nnfw::cker::Pack<T>(op_params, inputPtrs.data(), getShape(_output), getBuffer<T>(_output));
63}
nnfw::cker::Shape getShape(const IPortableTensor *tensor)
uint16_t inputs_count
Definition Types.h:129

References nnfw::cker::PackParams::axis, onert::backend::cpu::ops::getShape(), and nnfw::cker::PackParams::inputs_count.

◆ run()

void onert::backend::cpu::ops::PackLayer::run ( )
overridevirtual

Implements onert::exec::IFunction.

Definition at line 76 of file PackLayer.cc.

77{
78 if (_output->data_type() == OperandType::FLOAT32)
79 {
80 packImpl<float>();
81 }
82 else if (_output->data_type() == OperandType::INT32)
83 {
84 packImpl<int32_t>();
85 }
86 else
87 {
88 throw std::runtime_error{"Pack: unsupported data type"};
89 }
90}
ir::DataType data_type() const override final

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

Referenced by package.infer.session::inference().


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