| 42 | } |
| 43 | |
| 44 | void 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 | } |
nothing calls this directly
no test coverage detected