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

#include <OneHotLayer.h>

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

Public Member Functions

 OneHotLayer ()
 
template<typename T >
void oneHotImpl ()
 
void configure (const IPortableTensor *indices, const IPortableTensor *depth, const IPortableTensor *on_value, const IPortableTensor *off_value, IPortableTensor *output, int32_t axis)
 
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 OneHotLayer.h.

Constructor & Destructor Documentation

◆ OneHotLayer()

onert::backend::cpu::ops::OneHotLayer::OneHotLayer ( )
inline

Definition at line 36 of file OneHotLayer.h.

37 : _indices(nullptr), _depth(nullptr), _on_value(nullptr), _off_value(nullptr), _output(nullptr),
38 _axis(-1)
39 {
40 // DO NOTHING
41 }

Member Function Documentation

◆ configure()

void onert::backend::cpu::ops::OneHotLayer::configure ( const IPortableTensor indices,
const IPortableTensor depth,
const IPortableTensor on_value,
const IPortableTensor off_value,
IPortableTensor output,
int32_t  axis 
)

Definition at line 40 of file OneHotLayer.cc.

43{
44 _indices = indices;
45 _output = output;
46 _depth = depth;
47 _on_value = on_value;
48 _off_value = off_value;
49 _axis = axis;
50}

◆ oneHotImpl()

template<typename T >
void onert::backend::cpu::ops::OneHotLayer::oneHotImpl ( )

Definition at line 32 of file OneHotLayer.cc.

33{
34 // It assumes index is int32_t type.
35 nnfw::cker::OneHot<T, int32_t>(
36 *getBuffer<int32_t>(_depth), *getBuffer<T>(_on_value), *getBuffer<T>(_off_value), _axis,
37 getShape(_indices), getBuffer<int32_t>(_indices), getShape(_output), getBuffer<T>(_output));
38}
nnfw::cker::Shape getShape(const IPortableTensor *tensor)

References onert::backend::cpu::ops::getShape().

◆ run()

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

Implements onert::exec::IFunction.

Definition at line 52 of file OneHotLayer.cc.

53{
54 if (_output->data_type() == OperandType::FLOAT32)
55 {
56 oneHotImpl<float>();
57 }
58 else
59 {
60 throw std::runtime_error{"OneHot: unsupported data type"};
61 }
62}
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: