| 116 | bool show_backend_config = true; |
| 117 | |
| 118 | HloInstruction* FindInstruction(const HloModule& module, string node_name) { |
| 119 | if (absl::StartsWith(node_name, "%")) { |
| 120 | node_name.erase(node_name.begin()); |
| 121 | } |
| 122 | for (const auto& computation : module.computations()) { |
| 123 | auto instrs = computation->instructions(); |
| 124 | auto it = absl::c_find_if(instrs, [&](const HloInstruction* instr) { |
| 125 | // Try with and without "%" at the beginning of the node name. |
| 126 | return EqualsIgnoreCase(instr->name(), node_name) || |
| 127 | EqualsIgnoreCase(instr->name(), absl::StrCat("%", node_name)); |
| 128 | }); |
| 129 | if (it != instrs.end()) { |
| 130 | return *it; |
| 131 | } |
| 132 | } |
| 133 | return nullptr; |
| 134 | } |
| 135 | |
| 136 | HloComputation* FindComputation(const HloModule& module, |
| 137 | const string& comp_name) { |