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

#include <DynamicUpdateSliceLayer.h>

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

Public Member Functions

 DynamicUpdateSliceLayer ()
 
 ~DynamicUpdateSliceLayer ()
 
void configure (const IPortableTensor *operand, const IPortableTensor *update, const IPortableTensor *indices, IPortableTensor *output)
 
void run () override
 
- Public Member Functions inherited from onert::exec::IFunction
virtual ~IFunction ()=default
 
virtual void prepare ()
 

Detailed Description

Definition at line 28 of file DynamicUpdateSliceLayer.h.

Constructor & Destructor Documentation

◆ DynamicUpdateSliceLayer()

onert::backend::cpu::ops::DynamicUpdateSliceLayer::DynamicUpdateSliceLayer ( )

Definition at line 57 of file DynamicUpdateSliceLayer.cc.

58 : _operand(nullptr), _update(nullptr), _indices(nullptr), _output(nullptr)
59{
60 // DO NOTHING
61}

◆ ~DynamicUpdateSliceLayer()

onert::backend::cpu::ops::DynamicUpdateSliceLayer::~DynamicUpdateSliceLayer ( )
default

Member Function Documentation

◆ configure()

void onert::backend::cpu::ops::DynamicUpdateSliceLayer::configure ( const IPortableTensor operand,
const IPortableTensor update,
const IPortableTensor indices,
IPortableTensor output 
)

Definition at line 65 of file DynamicUpdateSliceLayer.cc.

68{
69 assert(operand != nullptr);
70 assert(update != nullptr);
71 assert(indices != nullptr);
72 assert(output != nullptr);
73
74 _operand = operand;
75 _update = update;
76 _indices = indices;
77 _output = output;
78}
FeatureShapeUpdater update(loco::FeatureShape &feature_shape)

◆ run()

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

Implements onert::exec::IFunction.

Definition at line 80 of file DynamicUpdateSliceLayer.cc.

81{
82 // Get indices data as int64 type vector
83 std::vector<int64_t> indices_data(_indices->getShape().num_elements());
84 for (size_t i = 0; i < indices_data.size(); ++i)
85 {
86 if (_indices->data_type() == OperandType::INT32)
87 {
88 indices_data[i] = static_cast<int64_t>(getBuffer<int32_t>(_indices)[i]);
89 }
90 else
91 {
92 assert(_indices->data_type() == OperandType::INT64);
93 indices_data[i] = getBuffer<int64_t>(_indices)[i];
94 }
95 }
96
97 switch (_operand->data_type())
98 {
99 case OperandType::FLOAT32:
100 nnfw::cker::DynamicUpdateSlice()(getShape(_operand), getBuffer<float>(_operand),
101 getShape(_update), getBuffer<float>(_update), indices_data,
102 getBuffer<float>(_output));
103 break;
104 case OperandType::QUANT_UINT8_ASYMM:
105 nnfw::cker::DynamicUpdateSlice()(getShape(_operand), getBuffer<uint8_t>(_operand),
106 getShape(_update), getBuffer<uint8_t>(_update), indices_data,
107 getBuffer<uint8_t>(_output));
108 break;
109 case OperandType::QUANT_INT16_SYMM:
110 nnfw::cker::DynamicUpdateSlice()(getShape(_operand), getBuffer<int8_t>(_operand),
111 getShape(_update), getBuffer<int8_t>(_update), indices_data,
112 getBuffer<int8_t>(_output));
113 break;
114 default:
115 throw std::runtime_error{"DynamicUpdateSlice: NYI - unsupported data type"};
116 break;
117 }
118}
ir::DataType data_type() const override final
ir::Shape getShape() const override final
Get ir::Shape of tensor.
nnfw::cker::Shape getShape(const IPortableTensor *tensor)

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


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