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

Method ToString

tensorflow/compiler/xla/service/indexed_array_analysis.cc:40–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38} // namespace
39
40string IndexedArrayAnalysis::ToString(Array* root, bool print_constants) {
41 switch (root->kind()) {
42 case Array::kUnknown: {
43 auto* unknown_tensor = root->as<UnknownArray>();
44 return absl::StrCat("%", unknown_tensor->instruction().name());
45 }
46
47 case Array::kConstant: {
48 if (print_constants) {
49 string contents = root->as<ConstantArray>()->literal()->ToString();
50 return absl::StrCat("(constant ", ShapeUtil::HumanString(root->shape()),
51 " ", contents, ")");
52 }
53 return absl::StrCat("(constant ", ShapeUtil::HumanString(root->shape()),
54 ")");
55 }
56
57 case Array::kReshaped: {
58 ReshapedArray* reshaped_array = root->as<ReshapedArray>();
59 return absl::StrCat(
60 "(reshape ", ToString(reshaped_array->operand(), print_constants),
61 " to ", ShapeUtil::HumanString(reshaped_array->shape()), ")");
62 }
63
64 case Array::kScalarIndexedConstant:
65 case Array::kScalarIndexed: {
66 auto* indexed_array = root->as<ScalarIndexedArray>();
67 string name = root->kind() == Array::kScalarIndexedConstant
68 ? "scalar-indexed-const"
69 : "scalar-indexed";
70 return absl::StrCat(
71 "(", name, " ", ToString(indexed_array->source(), print_constants),
72 " ", ToString(indexed_array->indices(), print_constants), " ",
73 indexed_array->source_dim(), "->[",
74 StrJoin(indexed_array->output_dims(), ","), "])");
75 }
76 }
77}
78
79StatusOr<Analysis::Array*> IndexedArrayAnalysis::GetArrayFor(
80 const HloInstruction* instr) {

Callers 1

RunMethod · 0.45

Calls 12

sourceMethod · 0.80
source_dimMethod · 0.80
output_dimsMethod · 0.80
ToStringFunction · 0.70
nameMethod · 0.65
StrCatFunction · 0.50
kindMethod · 0.45
instructionMethod · 0.45
literalMethod · 0.45
shapeMethod · 0.45
operandMethod · 0.45
indicesMethod · 0.45

Tested by

no test coverage detected