ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 27 of file OneHotLayer.h.

Constructor & Destructor Documentation

◆ OneHotLayer()

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

Definition at line 30 of file OneHotLayer.h.

31 : _indices(nullptr), _depth(nullptr), _on_value(nullptr), _off_value(nullptr), _output(nullptr),
32 _axis(-1)
33 {
34 // DO NOTHING
35 }

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 34 of file OneHotLayer.cc.

37{
38 _indices = indices;
39 _output = output;
40 _depth = depth;
41 _on_value = on_value;
42 _off_value = off_value;
43 _axis = axis;
44}

◆ oneHotImpl()

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

Definition at line 26 of file OneHotLayer.cc.

27{
28 // It assumes index is int32_t type.
29 nnfw::cker::OneHot<T, int32_t>(
30 *getBuffer<int32_t>(_depth), *getBuffer<T>(_on_value), *getBuffer<T>(_off_value), _axis,
31 getShape(_indices), getBuffer<int32_t>(_indices), getShape(_output), getBuffer<T>(_output));
32}
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 46 of file OneHotLayer.cc.

47{
48 if (_output->data_type() == OperandType::FLOAT32)
49 {
50 oneHotImpl<float>();
51 }
52 else
53 {
54 throw std::runtime_error{"OneHot: unsupported data type"};
55 }
56}
ir::DataType data_type() const override final

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


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