| 260 | } |
| 261 | |
| 262 | string HloToIrBindings::ToString() const { |
| 263 | string s = StrCat("** HloToIrBindings **\n"); |
| 264 | StrAppend(&s, " is_nested_=", is_nested_, "\n"); |
| 265 | StrAppend(&s, |
| 266 | " temp_buffer_base_=", llvm_ir::DumpToString(*temp_buffer_base_), |
| 267 | "\n"); |
| 268 | |
| 269 | if (base_ptrs_.empty()) { |
| 270 | return s; |
| 271 | } |
| 272 | |
| 273 | // Iterate over all computations in the module in topological order, and print |
| 274 | // out the base pointers we have in each computation in topological order. |
| 275 | for (const HloComputation* computation : |
| 276 | base_ptrs_.begin()->first->GetModule()->MakeComputationPostOrder()) { |
| 277 | bool is_first = true; |
| 278 | for (const HloInstruction* instr : |
| 279 | computation->MakeInstructionPostOrder()) { |
| 280 | auto it = base_ptrs_.find(instr); |
| 281 | if (it == base_ptrs_.end()) { |
| 282 | continue; |
| 283 | } |
| 284 | if (is_first) { |
| 285 | StrAppend(&s, " Base pointers for computation ", computation->name(), |
| 286 | ":\n"); |
| 287 | is_first = false; |
| 288 | } |
| 289 | StrAppend(&s, " ", instr->ToString()); |
| 290 | |
| 291 | const ShapeTree<llvm::Value*>& shape_tree = it->second; |
| 292 | if (!instr->shape().IsTuple()) { |
| 293 | const llvm::Value* val = shape_tree.begin()->second; |
| 294 | StrAppend(&s, " -> ", llvm_ir::DumpToString(*val), "\n"); |
| 295 | continue; |
| 296 | } |
| 297 | |
| 298 | StrAppend(&s, "\n"); |
| 299 | for (auto shape_it = shape_tree.begin(); shape_it != shape_tree.end(); |
| 300 | ++shape_it) { |
| 301 | llvm::Value* val = shape_it->second; |
| 302 | StrAppend(&s, " ", shape_it->first.ToString(), " -> ", |
| 303 | (val != nullptr ? llvm_ir::DumpToString(*val) : "null"), |
| 304 | "\n"); |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | return s; |
| 309 | } |
| 310 | |
| 311 | } // namespace gpu |
| 312 | } // namespace xla |
no test coverage detected