ONE - On-device Neural Engine
Loading...
Searching...
No Matches
circle-input-names.cpp File Reference
#include <iostream>
#include <crew/PConfigJson.h>
#include <luci/CircleNodeSummaryBuilders.h>
#include <luci/IR/CircleNodes.lst>

Go to the source code of this file.

Data Structures

struct  is_VariadicArity< T >
 
struct  is_VariadicArity< CircleConcatenation >
 
struct  is_VariadicArity< CircleCustom >
 
struct  is_VariadicArity< CirclePack >
 
struct  is_VariadicArity< CircleAddN >
 
struct  is_VariadicArity< CircleIf >
 
struct  is_VariadicArity< CircleWhile >
 
struct  is_VariadicOut< T >
 
struct  is_VariadicOut< CircleCustom >
 
struct  is_VariadicOut< CircleIf >
 
struct  is_VariadicOut< CircleWhile >
 
class  MockSymbolTable
 

Macros

#define CIRCLE_NODE(OPCODE, CLASS)
 
#define CIRCLE_NODE(OPCODE, CLASS)
 
#define CIRCLE_NODE(OP, CIRCLE_OP)
 
#define CIRCLE_VNODE(_1, _2)
 

Functions

template<typename CircleOp , typename std::enable_if_t< is_VariadicArity< CircleOp >::value &&is_VariadicOut< CircleOp >::value > * = nullptr>
auto CircleNodeCreator ()
 
void add_fused_actfn_option (CircleNode *node)
 
void add_padding_option (CircleNode *node)
 
void add_mode_option (CircleNode *node)
 
void fill_dummies_for_summary_creation (CircleNode *node)
 
locop::NodeSummary create_circle_node_summary (CircleNode *node)
 
void get_input_names_from_summary (CircleNode *node, locop::NodeSummary &s, crew::JsonExport &json_export)
 
int main (void)
 

Macro Definition Documentation

◆ CIRCLE_NODE [1/3]

#define CIRCLE_NODE (   OP,
  CIRCLE_OP 
)
Value:
{ \
auto node = CircleNodeCreator<CIRCLE_OP>(); \
fill_dummies_for_summary_creation(&node); \
auto summary = create_circle_node_summary(&node); \
get_input_names_from_summary(&node, summary, json_export); \
}
locop::NodeSummary create_circle_node_summary(CircleNode *node)

◆ CIRCLE_NODE [2/3]

#define CIRCLE_NODE (   OPCODE,
  CLASS 
)
Value:
case luci::CircleOpcode::OPCODE: \
{ \
auto node_ = dynamic_cast<CLASS *>(node); \
node_->padding(Padding::SAME); \
break; \
}

◆ CIRCLE_NODE [3/3]

#define CIRCLE_NODE (   OPCODE,
  CLASS 
)
Value:
case luci::CircleOpcode::OPCODE: \
{ \
auto node_ = dynamic_cast<CLASS *>(node); \
auto mode_ = node_->mode(); \
node_->mode(decltype(mode_)(1)); \
break; \
}

◆ CIRCLE_VNODE

#define CIRCLE_VNODE (   _1,
  _2 
)

Function Documentation

◆ add_fused_actfn_option()

void add_fused_actfn_option ( CircleNode node)

Definition at line 66 of file circle-input-names.cpp.

67{
68 auto node_ = dynamic_cast<CircleNodeMixin<CircleNodeTrait::FusedActFunc> *>(node);
69 if (node_)
70 {
71 node_->fusedActivationFunction(luci::FusedActFunc::RELU);
72 }
73}

References luci::RELU.

Referenced by fill_dummies_for_summary_creation().

◆ add_mode_option()

void add_mode_option ( CircleNode node)

Definition at line 104 of file circle-input-names.cpp.

105{
106 switch (node->opcode())
107 {
108#define CIRCLE_NODE(OPCODE, CLASS) \
109 case luci::CircleOpcode::OPCODE: \
110 { \
111 auto node_ = dynamic_cast<CLASS *>(node); \
112 auto mode_ = node_->mode(); \
113 node_->mode(decltype(mode_)(1)); \
114 break; \
115 }
116 CIRCLE_NODE(MIRROR_PAD, CircleMirrorPad)
118#undef CIRCLE_NODE
119 default:
120 {
121 break;
122 }
123 }
124 return;
125}
#define CIRCLE_NODE(OPCODE, CLASS)
MIRROR_PAD in Circle.
ROPE in Circle.
Definition CircleRoPE.h:33
virtual CircleOpcode opcode(void) const =0

References CIRCLE_NODE, and luci::CircleNode::opcode().

Referenced by fill_dummies_for_summary_creation().

◆ add_padding_option()

void add_padding_option ( CircleNode node)

Definition at line 77 of file circle-input-names.cpp.

78{
79 switch (node->opcode())
80 {
81#define CIRCLE_NODE(OPCODE, CLASS) \
82 case luci::CircleOpcode::OPCODE: \
83 { \
84 auto node_ = dynamic_cast<CLASS *>(node); \
85 node_->padding(Padding::SAME); \
86 break; \
87 }
93 CIRCLE_NODE(TRANSPOSE_CONV, CircleTransposeConv)
94#undef CIRCLE_NODE
95 default:
96 {
97 break;
98 }
99 }
100 return;
101}
AVERAGE_POOL_2D in Circle.
CONV_2D in Circle.
DEPTHWISE_CONV_2D in Circle.
L2_POOL_2D in Circle.
MAX_POOL_2D in Circle.
TRANSPOSE_CONV in Circle.

References AVERAGE_POOL_2D, CIRCLE_NODE, CONV_2D, DEPTHWISE_CONV_2D, L2_POOL_2D, MAX_POOL_2D, and luci::CircleNode::opcode().

Referenced by fill_dummies_for_summary_creation().

◆ CircleNodeCreator()

template<typename CircleOp , typename std::enable_if_t< is_VariadicArity< CircleOp >::value &&is_VariadicOut< CircleOp >::value > * = nullptr>
auto CircleNodeCreator ( )

Definition at line 43 of file circle-input-names.cpp.

44{
45 return CircleOp(1, 1);
46}

◆ create_circle_node_summary()

locop::NodeSummary create_circle_node_summary ( CircleNode node)

Definition at line 142 of file circle-input-names.cpp.

143{
145 MockSymbolTable tbl;
146 CircleNodeSummaryBuilder builder;
147
148 builder.build(node, &tbl, s);
149 return s;
150}

References luci::CircleNodeSummaryBuilder::build().

◆ fill_dummies_for_summary_creation()

void fill_dummies_for_summary_creation ( CircleNode node)

Definition at line 128 of file circle-input-names.cpp.

129{
131 add_padding_option(node);
132 add_mode_option(node);
133}
void add_padding_option(CircleNode *node)
void add_fused_actfn_option(CircleNode *node)
void add_mode_option(CircleNode *node)

References add_fused_actfn_option(), add_mode_option(), and add_padding_option().

◆ get_input_names_from_summary()

void get_input_names_from_summary ( CircleNode node,
locop::NodeSummary s,
crew::JsonExport json_export 
)

Definition at line 153 of file circle-input-names.cpp.

155{
156 std::vector<std::string> arg_names;
157 for (int i = 0; i < node->arity(); i++)
158 {
159 auto args = s.args().at(i);
160 // args : pair(name, value)
161 arg_names.emplace_back(args.first);
162 }
163
164 // s.opname() : "Circle.Opname""
165 auto opname = s.opname().substr(7);
166 // "Opname" : ["arg1", "arg2",...],"
167 json_export.key_val(opname, arg_names, true);
168}
void key_val(const std::string &key, const std::string &value, bool cont)
virtual uint32_t arity(void) const =0
Return the number of arguments.
args
Definition infer.py:21

References loco::Node::arity(), and crew::JsonExport::key_val().

◆ main()

int main ( void  )

Definition at line 170 of file circle-input-names.cpp.

171{
172 std::stringstream ss;
173 crew::JsonExport json_export(ss);
174 // "{"
175 json_export.open_brace();
176#define CIRCLE_NODE(OP, CIRCLE_OP) \
177 { \
178 auto node = CircleNodeCreator<CIRCLE_OP>(); \
179 fill_dummies_for_summary_creation(&node); \
180 auto summary = create_circle_node_summary(&node); \
181 get_input_names_from_summary(&node, summary, json_export); \
182 }
183#define CIRCLE_VNODE(_1, _2)
184#include <luci/IR/CircleNodes.lst>
185#undef CIRCLE_NODE
186#undef CIRCLE_VNODE
187 // Remove last comma from stringstream 'ss'
188 ss.seekp(-2, std::ios_base::end) << '\n';
189 // "}"
190 json_export.close_brace(false);
191 std::cout << ss.str();
192
193 return 0;
194}

References crew::JsonExport::close_brace(), and crew::JsonExport::open_brace().

Referenced by utils::safemain().