37 tensorflow::GraphDef &tf_graph_def,
loco::Graph *graph)
39 auto nodedef = std::make_unique<moco::NodeDefTable>();
40 auto tensor_names = std::make_unique<moco::SymbolTable>();
41 auto updates = std::make_unique<moco::UpdateQueue>();
54 for (
const auto &n : tf_graph_def.node())
56 nodedef->enroll(n.name(), &n);
86 for (
const auto &n : tf_graph_def.node())
88 if (
const auto *graph_builder = source.
lookup(n.op()))
90 if (!graph_builder->validate(n))
95 graph_builder->build(n, &gb_context);
114 for (
auto &update : updates->queue())
116 update->input(tensor_names.get());
122 for (
auto input : signature.
inputs())
124 auto node = tensor_names->node(input);
125 assert(node !=
nullptr);
127 auto graph_input =
graph->inputs()->create();
131 graph_input->name(
input.nodeName());
134 moco::index(placeholder_node, graph_input->index());
140 graph_input->dtype(loco::DataType::FLOAT32);
146 for (
auto output : signature.outputs())
156 auto graph_output =
graph->outputs()->create();
157 graph_output->name(
output.nodeName());
161 graph_output->dtype(loco::DataType::FLOAT32);
179 tensorflow::GraphDef &tf_graph_def)
const
185 if (_source !=
nullptr)
188 source_ptr = _source;
191 convert_graph(*source_ptr, signature, tf_graph_def, graph.get());
void index(const GraphOutputIndex &index)
Class to store context to build loco graph IR from TensorFlow.
static GraphBuilderRegistry & get()
std::unique_ptr< loco::Graph > import(const ModelSignature &, tensorflow::GraphDef &) const
Make a value visible to user.
bool valid(Graph *g, std::unique_ptr< ErrorListener > &&l=nullptr)
Validate a loco graph.
std::unique_ptr< Graph > make_graph(void)
Push * push_node(Graph *g, const GraphOutputIndex &index)
Find a Push node with a given output index.
CircleOutput * output_node(loco::Graph *g, const loco::GraphOutputIndex &index)
Find a CircleOutput node with a given output index.
loco::GraphInputIndex index(const TFPlaceholder *node)
TFPlaceholder * placeholder_node(loco::Graph *g, const loco::GraphInputIndex &idx)
FeatureShapeUpdater update(loco::FeatureShape &feature_shape)
virtual const GraphBuilder * lookup(const std::string &op) const =0
Returns registered GraphBuilder pointer for operator (nullptr if not present)
Class to store information to run a model. Normally this info comes from users via CLI params or conf...