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

Method PrintNodeInfo

tensorflow/python/grappler/model_analyzer.cc:44–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void ModelAnalyzer::PrintNodeInfo(const NodeDef* node,
45 const GraphProperties& properties, bool debug,
46 std::ostream& os) const {
47 os << node->name() << " [" << node->op() << "]" << std::endl;
48 if (properties.HasOutputProperties(node->name())) {
49 const std::vector<OpInfo::TensorProperties>& props =
50 properties.GetOutputProperties(node->name());
51 for (int i = 0; i < props.size(); ++i) {
52 const OpInfo::TensorProperties& prop = props[i];
53 os << "\t"
54 << "output " << i << " (" << DataTypeString(prop.dtype())
55 << ") has shape ";
56 if (prop.shape().unknown_rank()) {
57 os << "?";
58 } else {
59 os << "[";
60 for (int i = 0; i < prop.shape().dim_size(); ++i) {
61 if (i > 0) {
62 os << ", ";
63 }
64 if (prop.shape().dim(i).size() >= 0) {
65 // Print the actual dimension.
66 os << prop.shape().dim(i).size();
67 } else if (prop.shape().dim(i).size() == -1) {
68 // We don't know anything about the dimension.
69 os << "?";
70 } else {
71 // Symbolic dimension.
72 os << "x" << -prop.shape().dim(i).size();
73 }
74 }
75 os << "]";
76 }
77 os << std::endl;
78 }
79 }
80
81 if (debug) {
82 const OpRegistrationData* op_reg_data;
83 Status status = OpRegistry::Global()->LookUp(node->op(), &op_reg_data);
84 if (!status.ok()) {
85 os << "\tCouldn't find op registration for " << node->op() << std::endl;
86 } else if (!op_reg_data->shape_inference_fn) {
87 os << "\tCouldn't find shape function for op " << node->op() << std::endl;
88 } else if (properties.HasInputProperties(node->name())) {
89 const std::vector<OpInfo::TensorProperties>& props =
90 properties.GetInputProperties(node->name());
91 for (int i = 0; i < props.size(); ++i) {
92 const OpInfo::TensorProperties& prop = props[i];
93 if (prop.has_value()) {
94 os << "\t"
95 << "input " << i << " (" << DataTypeString(prop.dtype())
96 << ") has known value" << std::endl;
97 }
98 }
99 }
100 }
101}

Callers

nothing calls this directly

Calls 14

HasOutputPropertiesMethod · 0.80
unknown_rankMethod · 0.80
HasInputPropertiesMethod · 0.80
nameMethod · 0.65
DataTypeStringFunction · 0.50
opMethod · 0.45
sizeMethod · 0.45
dtypeMethod · 0.45
shapeMethod · 0.45
dim_sizeMethod · 0.45
dimMethod · 0.45
LookUpMethod · 0.45

Tested by

no test coverage detected