| 362 | } |
| 363 | |
| 364 | string ShapeToPython(const TensorShapeProto& shape) { |
| 365 | if (shape.unknown_rank()) { |
| 366 | return "None"; |
| 367 | } |
| 368 | string python = "["; |
| 369 | for (const auto& dim : shape.dim()) { |
| 370 | if (python.size() > 1) strings::StrAppend(&python, ", "); |
| 371 | if (!dim.name().empty()) { |
| 372 | strings::StrAppend(&python, "(", StringToPython(dim.name()), ", ", |
| 373 | dim.size(), ")"); |
| 374 | } else { |
| 375 | strings::StrAppend(&python, dim.size()); |
| 376 | } |
| 377 | } |
| 378 | strings::StrAppend(&python, "]"); |
| 379 | return python; |
| 380 | } |
| 381 | |
| 382 | string TensorToPython(const TensorProto& proto) { |
| 383 | return ProtoShortDebugString(proto); |
no test coverage detected