36class TFBiasAddGraphUpdate final :
public GraphUpdate
39 TFBiasAddGraphUpdate(
TFBiasAdd *biasadd, std::vector<TensorName> &names)
40 : _biasadd(biasadd), _names(names)
48 std::vector<TensorName> _names;
51void TFBiasAddGraphUpdate::input(
const SymbolTable *node_table)
const
53 assert(_names.size() == 2);
55 auto value_node = node_table->
node(_names[0]);
56 auto bias_node = node_table->
node(_names[1]);
57 assert(value_node !=
nullptr);
58 assert(bias_node !=
nullptr);
60 _biasadd->value(value_node);
61 _biasadd->bias(bias_node);
71 if (node.input_size() != 2)
88 if (!(data_layout ==
"NHWC" || data_layout ==
"NCHW"))
90 throw oops::UserExn(
"BiasAdd Unsupported data_format", node.name());
98 assert(context !=
nullptr);
106 auto tf_bias_add = graph->nodes()->create<
TFBiasAdd>();
107 tf_bias_add->
name(node.name());
108 tf_bias_add->data_layout(data_layout);
112 tensor_names->
enroll(output_name, tf_bias_add);
114 std::vector<TensorName> input_names;
115 input_names.push_back(
TensorName(node.input(0)));
116 input_names.push_back(
TensorName(node.input(1)));
118 auto update = std::make_unique<TFBiasAddGraphUpdate>(tf_bias_add, input_names);
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.
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)
NodeName name(void) const