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

Method HumanStringWithLayout

tensorflow/compiler/xla/shape_util.cc:494–522  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

492}
493
494/* static */ string ShapeUtil::HumanStringWithLayout(const Shape& shape) {
495 if (shape.IsTuple()) {
496 string text = "(";
497 const char* prefix = "";
498 for (const Shape& elem_shape : shape.tuple_shapes()) {
499 StrAppend(&text, prefix, HumanStringWithLayout(elem_shape));
500 prefix = ", ";
501 }
502 text += ")";
503 return text;
504 }
505 string result = StrCat(
506 primitive_util::LowercasePrimitiveTypeName(shape.element_type()), "[");
507 for (int i = 0; i < shape.dimensions().size(); i++) {
508 StrAppend(&result, (i > 0) ? "," : "",
509 shape.is_dynamic_dimension(i) ? "<=" : "", shape.dimensions(i));
510 }
511 result += "]";
512 if (IsScalar(shape)) {
513 string layout_str = LayoutUtil::HumanString(shape.layout());
514 // Don't print "{}" as layout for scalars.
515 if (layout_str != "{}") {
516 StrAppend(&result, layout_str);
517 }
518 } else if (shape.IsArray() && LayoutUtil::HasLayout(shape)) {
519 StrAppend(&result, LayoutUtil::HumanString(shape.layout()));
520 }
521 return result;
522}
523
524/* static */ string ShapeUtil::HumanString(const ProgramShape& program_shape) {
525 std::vector<string> parameters;

Callers

nothing calls this directly

Calls 11

is_dynamic_dimensionMethod · 0.80
StrAppendFunction · 0.50
StrCatFunction · 0.50
IsScalarFunction · 0.50
IsTupleMethod · 0.45
tuple_shapesMethod · 0.45
element_typeMethod · 0.45
sizeMethod · 0.45
dimensionsMethod · 0.45
layoutMethod · 0.45
IsArrayMethod · 0.45

Tested by

no test coverage detected