42 TFConv2DGraphUpdate(
TFConv2D *node, std::vector<TensorName> names) : _node(node), _names(names) {}
48 std::vector<TensorName> _names;
51void TFConv2DGraphUpdate::input(
const SymbolTable *node_table)
const
53 assert(_names.size() == 2);
56 auto filter_node = node_table->
node(_names[1]);
57 assert(input_node !=
nullptr);
58 assert(filter_node !=
nullptr);
60 _node->input(input_node);
61 _node->filter(filter_node);
71 if (node.input_size() != 2)
80 if (!(data_layout ==
"NHWC" || data_layout ==
"NCHW"))
82 throw oops::UserExn(
"Conv2D Unsupported data_format", node.name());
90 if (!std::all_of(dilation.begin(), dilation.end(), [](std::int64_t dil) { return dil == 1; }))
100 assert(context !=
nullptr);
107 std::string conv2d_name = node.name();
109 auto conv2d = graph->nodes()->create<
TFConv2D>();
110 conv2d->
name(node.name());
114 assert(data_layout ==
"NHWC" || data_layout ==
"NCHW");
115 conv2d->data_layout(data_layout);
119 conv2d->strides(strides);
122 assert(padding ==
"VALID" || padding ==
"SAME");
123 conv2d->padding(padding);
127 tensor_names->
enroll(output_name, conv2d);
129 std::vector<TensorName> input_names;
130 input_names.push_back(
TensorName(node.input(0)));
131 input_names.push_back(
TensorName(node.input(1)));
134 auto tfconv2d_update = std::make_unique<TFConv2DGraphUpdate>(conv2d, input_names);
136 updates->
enroll(std::move(tfconv2d_update));
void build(const tensorflow::NodeDef &, GraphBuilderContext *) const final
bool validate(const tensorflow::NodeDef &) const final
Class to store context to build loco graph IR from TensorFlow.
SymbolTable * tensor_names()
Interface to connect the graph.
virtual void input(const SymbolTable *) const =0
Do the graph input connections using the SymbolTable.
Class to store and query loco::Node* with string name key.
void enroll(const TensorName &tensor_name, loco::Node *node)
Registers a name with corresponding loco::Node *.
loco::Node * node(const TensorName &tensor_name) const
Queries enrolled(registered) with name and return node if found Will throw runtime_error if not found...
Class to store GraphUpdate objects.
void enroll(std::unique_ptr< GraphUpdate > &&update)
Registers GraphUpdate objects.
CircleInput * input_node(loco::Graph *g, const loco::GraphInputIndex &index)
Find a Pull node with a given input index.
std::string str_toupper(std::string s)
bool has_attrs(const tensorflow::NodeDef &node, const std::vector< std::string > &attr_names)
bool has_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
const std::string & get_string_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
std::vector< int64_t > as_int64_list(const tensorflow::AttrValue_ListValue &lv)
const tensorflow::AttrValue_ListValue & get_list_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
NodeName name(void) const