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

Function NodePositionIfSameNode

tensorflow/core/grappler/utils.h:127–139  ·  view source on GitHub ↗

Returns the trailing position number (or zero if no number is present) if NodeName(input_name) is equal to node_name. Returns -1 for control inputs. Returns -2 if input_name is empty or NodeName(input_name) is not equal to node_name.

Source from the content-addressed store, hash-verified

125// Returns -2 if input_name is empty or NodeName(input_name) is not equal to
126// node_name.
127inline int NodePositionIfSameNode(absl::string_view input_name,
128 absl::string_view node_name) {
129 bool is_control = absl::StartsWith(input_name, "^");
130 if (is_control) input_name.remove_prefix(1);
131 if (input_name.empty() || node_name.empty() ||
132 input_name.size() < node_name.size()) {
133 return -2;
134 }
135 TensorId id = ParseTensorName(input_name);
136 if (id.first != node_name) return -2;
137 if (is_control) return -1;
138 return id.second;
139}
140
141// Returns the node name and position in a single call.
142inline StringPiece ParseNodeNameAsStringPiece(absl::string_view name,

Callers 2

TEST_FFunction · 0.85
DedupComputationsMethod · 0.85

Calls 4

StartsWithFunction · 0.85
ParseTensorNameFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.68