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

Function GetNodesHasDynamicShapeMap

serving/processor/framework/util/utils.cc:60–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60std::unordered_map<std::string, bool> GetNodesHasDynamicShapeMap(const GraphDef& gdef) {
61 // NOTE(jiankeng.pt): should be optimized via topological sort algorithm later
62 std::unordered_map<std::string, bool> output_shapes;
63 for (const NodeDef& node : gdef.node()) {
64 output_shapes[node.name()] = HasDynamicShapeOutput(const_cast<NodeDef*>(&node));
65 }
66
67 // True when node has dynamic input or output, false else.
68 std::unordered_map<std::string, bool> result;
69 for (const NodeDef& node : gdef.node()) {
70 // output shapes
71 if (output_shapes[node.name()]) {
72 result[node.name()] = true;
73 } else {
74 // input shapes
75 result[node.name()] = false;
76 for (std::string in_name : node.input()) {
77 // control flow edge
78 if (in_name[0] == '^') {
79 in_name = in_name.substr(1);
80 }
81 auto offset = in_name.find(":");
82 if (offset != std::string::npos) {
83 in_name = in_name.substr(0, offset);
84 }
85 if (!output_shapes[in_name]) continue;
86 result[node.name()] = true;
87 break;
88 }
89 }
90 }
91
92 return result;
93}
94
95// Sets any parameters not specified in a node to their defaults.
96Status AddDefaultAttributes(const GraphDef& input_graph_def,

Callers 3

GetStaticGraphOpsMethod · 0.85
RunMethod · 0.85
TESTFunction · 0.85

Calls 5

HasDynamicShapeOutputFunction · 0.85
nameMethod · 0.65
nodeMethod · 0.45
inputMethod · 0.45
findMethod · 0.45

Tested by 1

TESTFunction · 0.68