static */
| 468 | } |
| 469 | |
| 470 | /* static */ string ShapeUtil::HumanString(const Shape& shape) { |
| 471 | if (shape.IsTuple()) { |
| 472 | string text = "("; |
| 473 | const char* prefix = ""; |
| 474 | for (const Shape& elem_shape : shape.tuple_shapes()) { |
| 475 | StrAppend(&text, prefix, HumanString(elem_shape)); |
| 476 | prefix = ", "; |
| 477 | } |
| 478 | text += ")"; |
| 479 | return text; |
| 480 | } |
| 481 | std::vector<string> dim_elements; |
| 482 | for (int i = 0; i < shape.dimensions_size(); ++i) { |
| 483 | if (shape.is_dynamic_dimension(i)) { |
| 484 | dim_elements.push_back(StrCat("<=", shape.dimensions(i))); |
| 485 | } else { |
| 486 | dim_elements.push_back(StrCat(shape.dimensions(i))); |
| 487 | } |
| 488 | } |
| 489 | return StrCat( |
| 490 | primitive_util::LowercasePrimitiveTypeName(shape.element_type()), "[", |
| 491 | absl::StrJoin(dim_elements, ","), "]"); |
| 492 | } |
| 493 | |
| 494 | /* static */ string ShapeUtil::HumanStringWithLayout(const Shape& shape) { |
| 495 | if (shape.IsTuple()) { |
nothing calls this directly
no test coverage detected