| 451 | } |
| 452 | |
| 453 | string HloAliasAnalysis::ToString() const { |
| 454 | string out = absl::StrCat("HloAliasAnalysis, module ", module_->name(), "\n"); |
| 455 | StrAppend(&out, " Buffers at each position:\n"); |
| 456 | for (const HloComputation* computation : module_->computations()) { |
| 457 | for (const HloInstruction* instruction : computation->instructions()) { |
| 458 | StrAppend(&out, " ", instruction->name(), ":\n"); |
| 459 | if (instruction->shape().IsTuple()) { |
| 460 | ShapeUtil::ForEachSubshape( |
| 461 | instruction->shape(), |
| 462 | [&out, &instruction, this](const Shape&, const ShapeIndex& index) { |
| 463 | StrAppend(&out, " tuple index ", index.ToString(), ":\n"); |
| 464 | for (const HloBuffer* buffer : |
| 465 | ComputeBuffersAt(instruction, index)) { |
| 466 | StrAppend(&out, " ", buffer->ToString(), "\n"); |
| 467 | } |
| 468 | }); |
| 469 | } else { |
| 470 | for (const HloBuffer* buffer : |
| 471 | ComputeBuffersAt(instruction, /*index=*/{})) { |
| 472 | StrAppend(&out, " ", buffer->ToString(), "\n"); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | StrAppend(&out, " Buffers:\n"); |
| 479 | for (const HloBuffer& buffer : buffers()) { |
| 480 | StrAppend(&out, " ", buffer.ToString(), "\n"); |
| 481 | StrAppend(&out, " positions:\n"); |
| 482 | for (const HloPosition& position : buffer.ComputePositions()) { |
| 483 | StrAppend(&out, " ", position.ToString(), "\n"); |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | return out; |
| 488 | } |
| 489 | |
| 490 | /* static */ |
| 491 | StatusOr<std::unique_ptr<HloAliasAnalysis>> HloAliasAnalysis::Run( |
no test coverage detected