aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tensorflow/compiler/xla/service/gpu/gpu_layout_assignment.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/tensorflow/compiler/xla/service/gpu/gpu_layout_assignment.cc b/tensorflow/compiler/xla/service/gpu/gpu_layout_assignment.cc
index 178457721a..8bf62dde8b 100644
--- a/tensorflow/compiler/xla/service/gpu/gpu_layout_assignment.cc
+++ b/tensorflow/compiler/xla/service/gpu/gpu_layout_assignment.cc
@@ -159,7 +159,13 @@ Status GpuLayoutAssignment::AddBackendConstraintsToDnnConvCustomCall(
Status GpuLayoutAssignment::AddBackendConstraints(
LayoutConstraints* constraints) {
- for (auto* instruction : constraints->computation()->instructions()) {
+ // Add convolution constraints in reverse postorder that the earliest
+ // convolution layout propagates first. This reduces the likelihood of fusion
+ // nodes with copies.
+ auto post_order = constraints->computation()->MakeInstructionPostOrder();
+ for (auto iterator = post_order.rbegin(); iterator != post_order.rend();
+ ++iterator) {
+ HloInstruction* instruction = *iterator;
if (IsCustomCallToDnnConvolution(*instruction)) {
TF_RETURN_IF_ERROR(
AddBackendConstraintsToDnnConvCustomCall(instruction, constraints));