aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Blake Hechtman <blakehechtman@google.com>2018-06-04 14:20:46 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-06-04 14:23:34 -0700
commit204fcd9a002aa8678c42d076553e38d69e8724a6 (patch)
treee34a6407f3f0a15cb9652f77efbb330fd35471e6
parent279b899642c22734a5bd3b375a2fa9f84aa4738c (diff)
[XLA:GPU] Propagate layouts in a better order for performance and fusion.
PiperOrigin-RevId: 199193181
-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));