39class TFMaxPoolGraphUpdate final :
public GraphUpdate
43 : _maxpool_node(node), _input_name(name)
54void TFMaxPoolGraphUpdate::input(
const SymbolTable *node_table)
const
57 _maxpool_node->input(input_node);
73 if (!(data_layout ==
"NHWC" || data_layout ==
"NCHW"))
75 throw oops::UserExn(
"MaxPool Unsupported data_format", node.name());
80 if (ksize.size() != 4)
83 throw oops::UserExn(
"MaxPool ksize requires rank 4", node.name());
88 if (strides.size() != 4)
91 throw oops::UserExn(
"MaxPool strides requires rank 4", node.name());
99 assert(context !=
nullptr);
106 ::std::string node_name = node.name();
110 auto maxPool_node = graph->nodes()->create<
TFMaxPool>();
111 maxPool_node->
name(node.name());
112 maxPool_node->data_layout(data_layout);
116 maxPool_node->padding(padding);
121 assert(ksize.size() == 4);
122 maxPool_node->ksize(ksize);
127 assert(strides.size() == 4);
128 maxPool_node->strides(strides);
132 tensor_names->
enroll(output_name, maxPool_node);
135 auto update = std::make_unique<TFMaxPoolGraphUpdate>(maxPool_node,
TensorName(node.input(0)));
Logical unit of computation.
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.
bool validate(const tensorflow::NodeDef &) const final
void build(const tensorflow::NodeDef &, GraphBuilderContext *) const final
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)
FeatureShapeUpdater update(loco::FeatureShape &feature_shape)
bool has_attrs(const tensorflow::NodeDef &node, const std::vector< std::string > &attr_names)
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