Skip to content

Commit 5cf4806

Browse files
mkupersttensorflower-gardener
authored andcommitted
[XLA] Refactor CallInliner to use VisitNodesWithReturn.
No functional change. PiperOrigin-RevId: 763896079
1 parent 53094b6 commit 5cf4806

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

third_party/xla/xla/service/call_inliner.cc

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,30 +315,24 @@ absl::StatusOr<bool> CallInliner::Run(
315315
std::unique_ptr<CallGraph> call_graph = CallGraph::Build(module);
316316
// Because call graph nodes are visited in post-order (callees before callers)
317317
// we'll always inline kCalls into their callers in the appropriate order.
318-
bool did_mutate = false;
319-
TF_RETURN_IF_ERROR(
320-
call_graph->VisitNodes([&](const CallGraphNode& node) -> absl::Status {
318+
TF_ASSIGN_OR_RETURN(
319+
bool did_mutate,
320+
call_graph->VisitNodesWithReturn([&](const CallGraphNode& node)
321+
-> absl::StatusOr<bool> {
321322
if (!HloInstruction::IsThreadIncluded(
322323
node.computation()->execution_thread(), execution_threads)) {
323-
return absl::OkStatus();
324+
return false;
324325
};
325-
bool did_node_mutate = false;
326326
if (module->has_schedule()) {
327327
HloInstructionSequence& sequence =
328328
module->schedule().GetOrCreateSequence(node.computation());
329-
TF_ASSIGN_OR_RETURN(did_node_mutate,
330-
InlineAndLegalize(*call_graph, node.computation(),
331-
sequence.instructions()));
332-
} else {
333-
TF_ASSIGN_OR_RETURN(
334-
did_node_mutate,
335-
InlineAndLegalize(
336-
*call_graph, node.computation(),
337-
node.computation()->MakeInstructionPostOrder()));
329+
return InlineAndLegalize(*call_graph, node.computation(),
330+
sequence.instructions());
338331
}
339-
did_mutate |= did_node_mutate;
340332

341-
return absl::OkStatus();
333+
return InlineAndLegalize(
334+
*call_graph, node.computation(),
335+
node.computation()->MakeInstructionPostOrder());
342336
}));
343337
if (did_mutate) {
344338
// Run DCE to remove called computations which are now becoming unused.

0 commit comments

Comments
 (0)