MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / LoadGraphFromProto

Method LoadGraphFromProto

tensorflow/core/kernels/hexagon/graph_transferer.cc:91–196  ·  view source on GitHub ↗

* graph loading functions * - LoadGraphFromProto * - LoadGraphFromProptoFile * These functions read a graph definition and store parameters * of node to transfer the graph to SOC. */

Source from the content-addressed store, hash-verified

89 * of node to transfer the graph to SOC.
90 */
91Status GraphTransferer::LoadGraphFromProto(
92 const IRemoteFusedGraphOpsDefinitions& ops_definitions,
93 const GraphDef& graph_def,
94 const std::vector<std::pair<string, Tensor>>& input_node_info_list,
95 const std::vector<string>& output_node_names,
96 const bool shape_inference_for_unknown_shape) {
97 Graph graph(OpRegistry::Global());
98 ShapeRefiner shape_refiner(graph.versions(), graph.op_registry());
99 Status status = ImportGraphDef({}, graph_def, &graph, &shape_refiner);
100 if (!status.ok()) {
101 return status;
102 }
103
104 if (shape_inference_for_unknown_shape) {
105 status = RemoteFusedGraphExecuteUtils::PropagateShapeInference(
106 graph_def, input_node_info_list, &graph, &shape_refiner);
107 if (!status.ok()) {
108 return status;
109 }
110 }
111
112 TF_RETURN_IF_ERROR(TransformGraphToAddAggregatedInputNode(
113 input_node_info_list, &graph, &shape_refiner));
114
115 std::unordered_multimap<string, const Node*> op_name_to_node_multimap(
116 graph.num_nodes());
117 for (const Node* const node : graph.nodes()) {
118 if (node == nullptr) {
119 continue;
120 }
121 CacheNode(*node);
122 }
123
124 for (const Node* const node : graph.nodes()) {
125 if (node == nullptr) {
126 continue;
127 }
128 VLOG(1) << "<Node> " << node->name();
129 for (const Node* const input_node : node->in_nodes()) {
130 const string& name = input_node->name();
131 op_name_to_node_multimap.emplace(name, node);
132 VLOG(1) << "Add dependency: " << name << " -> " << node->name();
133 }
134 }
135
136 for (const Node* const node : graph.nodes()) {
137 if (node == nullptr) {
138 continue;
139 }
140 status = RegisterNodeIfAllInputsAreCached(
141 ops_definitions, shape_refiner, *node, false, input_node_info_list,
142 output_node_names);
143 if (!status.ok()) {
144 LOG(ERROR) << "Failed to transfer graph " << status;
145 return status;
146 }
147 }
148

Callers 2

InitMethod · 0.80
TEST_FFunction · 0.80

Calls 15

ParseTensorNameFunction · 0.85
add_shapeMethod · 0.80
nameMethod · 0.65
ImportGraphDefFunction · 0.50
StrCatFunction · 0.50
StatusClass · 0.50
versionsMethod · 0.45
op_registryMethod · 0.45
okMethod · 0.45
num_nodesMethod · 0.45
nodesMethod · 0.45
in_nodesMethod · 0.45

Tested by 1

TEST_FFunction · 0.64