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

Function OpPortIdToArgId

tensorflow/core/grappler/graph_view.cc:24–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23namespace {
24int OpPortIdToArgId(const NodeDef& node,
25 const protobuf::RepeatedPtrField<OpDef::ArgDef>& args,
26 int port_id) {
27 for (int arg_id = 0; arg_id < args.size(); ++arg_id) {
28 if (port_id < 0) {
29 return -1;
30 } else if (port_id == 0) {
31 return arg_id;
32 }
33
34 // Default is 1 port per arg.
35 int n = 1;
36
37 const auto& arg = args.Get(arg_id);
38 if (!arg.number_attr().empty()) {
39 n = node.attr().at(arg.number_attr()).i();
40 } else if (!arg.type_list_attr().empty()) {
41 n = node.attr().at(arg.type_list_attr()).list().type_size();
42 }
43
44 if (n < 0) {
45 // This should never happen.
46 DCHECK_GE(n, 0);
47 return -1;
48 } else if (port_id < n) {
49 return arg_id;
50 }
51 port_id -= n;
52 }
53
54 return -1;
55}
56} // end namespace
57
58int OpOutputPortIdToArgId(const NodeDef& node, const OpDef& op, int port_id) {

Callers 2

OpOutputPortIdToArgIdFunction · 0.85
OpInputPortIdToArgIdFunction · 0.85

Calls 7

attrMethod · 0.80
listMethod · 0.80
sizeMethod · 0.45
GetMethod · 0.45
emptyMethod · 0.45
iMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected