ONE - On-device Neural Engine
Loading...
Searching...
No Matches
locoex::COpCall Class Referencefinal

Class to calls custom operation. More...

#include <COpCall.h>

Collaboration diagram for locoex::COpCall:

Public Member Functions

 COpCall (unsigned arity)
 
void op (const std::string &op)
 
const std::string & op ()
 
void name (const std::string &name)
 
const std::string & name ()
 
void input (uint32_t nth, loco::Node *node)
 
loco::Nodeinput (uint32_t nth) const
 
void attr (const std::string &attr_name, std::unique_ptr< COpAttrData > &&attr_data)
 Store [attr_name, attr_data].
 
template<COpAttrType AT>
const AttrTypeTrait< AT >::Type * attr (const std::string &attr_name) const
 Retrieve attr_data stored with attr_name.
 
std::vector< std::string > attr_names () const
 get all the names of attr
 
- Public Member Functions inherited from locoex::VariadicArityNode< COpNode >
 VariadicArityNode (uint32_t arity)
 
virtual ~VariadicArityNode ()=default
 
uint32_t arity (void) const final
 
loco::Nodearg (uint32_t n) const final
 
void drop (void) final
 
- Public Member Functions inherited from locoex::COpNode
virtual ~COpNode ()=default
 
const loco::Dialectdialect (void) const final
 Return "Dialect" identifier that this node belongs to.
 
uint32_t opnum (void) const final
 
- 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 locoex::VariadicArityNode< COpNode >
loco::Useat (uint32_t n) const
 

Detailed Description

Class to calls custom operation.

Definition at line 35 of file COpCall.h.

Constructor & Destructor Documentation

◆ COpCall()

locoex::COpCall::COpCall ( unsigned  arity)
inline

Definition at line 40 of file COpCall.h.

40: VariadicArityNode<COpNode>(arity) {}
uint32_t arity(void) const final
Return the number of arguments.

Member Function Documentation

◆ attr() [1/2]

template<COpAttrType AT>
const AttrTypeTrait< AT >::Type * locoex::COpCall::attr ( const std::string &  attr_name) const

Retrieve attr_data stored with attr_name.

Definition at line 25 of file COpCall.cpp.

26{
27 COpAttrData *attr_data;
28 auto found = _attrs.find(attr_name);
29 if (found != _attrs.end())
30 {
31 attr_data = found->second.get();
32 return dynamic_cast<const typename AttrTypeTrait<AT>::Type *>(attr_data);
33 }
34 else
35 throw std::runtime_error("Cannot find requested attr");
36}

◆ attr() [2/2]

void locoex::COpCall::attr ( const std::string &  attr_name,
std::unique_ptr< COpAttrData > &&  attr_data 
)

Store [attr_name, attr_data].

Definition at line 38 of file COpCall.cpp.

39{
40 if (_attrs.find(attr_name) == _attrs.end())
41 _attrs[attr_name] = std::move(attr_data);
42 else
43 throw std::runtime_error("Attr already inserted");
44}

◆ attr_names()

std::vector< std::string > locoex::COpCall::attr_names ( ) const

get all the names of attr

Definition at line 46 of file COpCall.cpp.

47{
48 std::vector<std::string> attr_names;
49
50 for (auto it = _attrs.cbegin(); it != _attrs.cend(); ++it)
51 {
52 attr_names.emplace_back(it->first);
53 }
54
55 return attr_names;
56}
std::vector< std::string > attr_names() const
get all the names of attr
Definition COpCall.cpp:46

References attr_names().

Referenced by attr_names().

◆ input() [1/2]

loco::Node * locoex::COpCall::input ( uint32_t  nth) const
inline

Definition at line 50 of file COpCall.h.

50{ return at(nth)->node(); }
Node * node(void) const
Definition Use.h:58
loco::Use * at(uint32_t n) const

References locoex::VariadicArityNode< COpNode >::at(), and loco::Use::node().

◆ input() [2/2]

void locoex::COpCall::input ( uint32_t  nth,
loco::Node node 
)
inline

Definition at line 49 of file COpCall.h.

49{ at(nth)->node(node); }

References locoex::VariadicArityNode< COpNode >::at(), and loco::Use::node().

◆ name() [1/2]

const std::string & locoex::COpCall::name ( )
inline

Definition at line 47 of file COpCall.h.

47{ return _name; }

Referenced by name().

◆ name() [2/2]

void locoex::COpCall::name ( const std::string &  name)
inline

Definition at line 46 of file COpCall.h.

46{ _name.assign(name); }
const std::string & name()
Definition COpCall.h:47

References name().

◆ op() [1/2]

const std::string & locoex::COpCall::op ( )
inline

Definition at line 44 of file COpCall.h.

44{ return _op; }

Referenced by op().

◆ op() [2/2]

void locoex::COpCall::op ( const std::string &  op)
inline

Definition at line 43 of file COpCall.h.

43{ _op.assign(op); }
const std::string & op()
Definition COpCall.h:44

References op().

Referenced by moco::tf::COpCallGraphBuilder::build().


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