ONE - On-device Neural Engine
Loading...
Searching...
No Matches
moco::TFConst Class Referencefinal

IR for tf.constant. More...

#include <TFConst.h>

Collaboration diagram for moco::TFConst:

Public Member Functions

 TFConst ()=default
 
template<loco::DataType DT>
uint32_t size (void) const
 
template<loco::DataType DT>
void size (uint32_t size)
 
template<loco::DataType DT>
const loco::DataTypeImpl< DT >::Type & at (uint32_t n) const
 
template<loco::DataType DT>
loco::DataTypeImpl< DT >::Type & at (uint32_t n)
 
- Public Member Functions inherited from moco::FixedArityNode< 0, TFNodeImpl< TFOpcode::Const > >
 FixedArityNode ()
 
virtual ~FixedArityNode ()=default
 
unsigned arity (void) const final
 
loco::Nodearg (uint32_t n) const final
 
void drop (void) final
 
- Public Member Functions inherited from moco::TFNodeImpl< TFOpcode::Const >
virtual ~TFNodeImpl ()=default
 
uint32_t opnum (void) const final
 
TFOpcode opcode (void) const final
 
- Public Member Functions inherited from moco::TFNode
virtual ~TFNode ()=default
 
const loco::Dialectdialect (void) const final
 Return "Dialect" identifier that this node belongs to.
 
template<typename T >
accept (TFNodeVisitorBase< T > *) const
 
template<typename T >
accept (TFNodeMutableVisitorBase< T > *)
 
NodeName name (void) const
 
void name (const NodeName &name)
 
- Public Member Functions inherited from loco::Node
 Node ()=default
 
 Node (const Node &)=delete
 
 Node (Node &&)=delete
 
virtual ~Node ()
 
Graphgraph (void)
 
const Graphgraph (void) const
 
- Public Member Functions inherited from loco::AnnotatedItem< NodeAnnotation >
 AnnotatedItem ()=default
 
virtual ~AnnotatedItem ()=default
 
const T * annot (void) const
 Retrieve a stored annotation of type T.
 
void annot (std::unique_ptr< T > &&p)
 Attach or remove a new annotation of type T.
 

Additional Inherited Members

- Protected Member Functions inherited from moco::FixedArityNode< 0, TFNodeImpl< TFOpcode::Const > >
loco::Useat (unsigned n) const
 

Detailed Description

IR for tf.constant.

Note
TFConst corresponds to the following GraphDef
Implementation for this class came from Canonical ConstGen Read comments in loco::ConstGen for details

Definition at line 64 of file TFConst.h.

Constructor & Destructor Documentation

◆ TFConst()

moco::TFConst::TFConst ( )
default

Member Function Documentation

◆ at() [1/2]

template<loco::DataType DT>
loco::DataTypeImpl< DT >::Type & moco::TFConst::at ( uint32_t  n)

Definition at line 45 of file TFConst.cpp.

46{
47 assert(dtype() == DT);
48 assert(n < size<DT>());
49 return *(reinterpret_cast<typename loco::DataTypeImpl<DT>::Type *>(_data.data()) + n);
50}
C++ scalar type corresponding to each DataType.

◆ at() [2/2]

template<loco::DataType DT>
const loco::DataTypeImpl< DT >::Type & moco::TFConst::at ( uint32_t  n) const

Definition at line 38 of file TFConst.cpp.

39{
40 assert(dtype() == DT);
41 assert(n < size<DT>());
42 return *(reinterpret_cast<const typename loco::DataTypeImpl<DT>::Type *>(_data.data()) + n);
43}

Referenced by moco::scalar_from_const< float >(), and moco::scalar_from_const< int32_t >().

◆ size() [1/2]

template<loco::DataType DT>
void moco::TFConst::size ( uint32_t  size)

Definition at line 31 of file TFConst.cpp.

32{
33 assert(dtype() == DT);
34 _data.resize(l * sizeof(typename loco::DataTypeImpl<DT>::Type));
35}

◆ size() [2/2]

template<loco::DataType DT>
uint32_t moco::TFConst::size ( void  ) const

Definition at line 24 of file TFConst.cpp.

25{
26 assert(dtype() == DT);
27 assert(_data.size() % sizeof(typename loco::DataTypeImpl<DT>::Type) == 0);
28 return _data.size() / sizeof(typename loco::DataTypeImpl<DT>::Type);
29}

Referenced by moco::ConstGraphBuilder::build().


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