ONE - On-device Neural Engine
Loading...
Searching...
No Matches
exo::ConstGenConverter Class Reference

#include <ConstGenConverter.h>

Collaboration diagram for exo::ConstGenConverter:

Public Member Functions

const char * name (void) const final
 
bool convert (loco::ConstGen *constgen) final
 
- Public Member Functions inherited from exo::CanonicalNodeConverter< loco::ConstGen >
bool run (loco::Graph *graph)
 Run the pass.
 
- Public Member Functions inherited from logo::Pass
virtual ~Pass ()=default
 

Additional Inherited Members

Detailed Description

Definition at line 27 of file ConstGenConverter.h.

Member Function Documentation

◆ convert()

bool exo::ConstGenConverter::convert ( loco::ConstGen constgen)
finalvirtual

Implements exo::CanonicalNodeConverter< loco::ConstGen >.

Definition at line 29 of file ConstGenConverter.cpp.

30{
31 auto *graph = constgen->graph();
32
33 auto tfl_const = graph->nodes()->create<locoex::TFLConst>();
34 {
35 if (constgen->dtype() == loco::DataType::FLOAT32)
36 {
37 tfl_const->dtype(loco::DataType::FLOAT32);
38
39 tfl_const->rank(constgen->rank());
40 for (uint32_t axis = 0; axis < constgen->rank(); axis++)
41 tfl_const->dim(axis) = constgen->dim(axis);
42
43 auto size = constgen->size<loco::DataType::FLOAT32>();
44 tfl_const->size<loco::DataType::FLOAT32>(size);
45
46 for (uint32_t i = 0; i < size; ++i)
47 {
48 tfl_const->at<loco::DataType::FLOAT32>(i) = constgen->at<loco::DataType::FLOAT32>(i);
49 }
50 }
51 else
52 INTERNAL_EXN_V("Unsupported DataType", oops::to_uint32(constgen->dtype()));
53 }
54
55 loco::replace(constgen).with(tfl_const);
56
57 return true;
58}
#define INTERNAL_EXN_V(msg, val)
@ brief throw internal exception with message and value
Definition InternalExn.h:28
uint32_t size(void) const
Return the number of reserved elements.
Definition Nodes.cpp:185
const DataTypeImpl< DT >::Type & at(uint32_t n) const
Get the element at a given position @require at(n) is valid only when n < size()
Definition Nodes.cpp:198
Graph * graph(void)
Definition Node.h:70
void with(Node *into) const
Definition Node.cpp:66
Class to build tensor data.
Definition TFLNodes.h:198
Subst< SubstQualifier::Default > replace(Node *node)
Definition Node.cpp:82
uint32_t to_uint32(T a)
Definition InternalExn.h:33
int32_t size[5]
Definition Slice.cpp:35

References loco::ConstGen::at(), loco::Node::graph(), INTERNAL_EXN_V, loco::replace(), loco::ConstGen::size(), size, oops::to_uint32(), and loco::Subst< SubstQualifier::Default >::with().

◆ name()

const char * exo::ConstGenConverter::name ( void  ) const
inlinefinalvirtual

Reimplemented from exo::CanonicalNodeConverter< loco::ConstGen >.

Definition at line 30 of file ConstGenConverter.h.

30{ return "exo::ConstGenConverter"; }

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