aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/layout_assignment.cc
diff options
context:
space:
mode:
authorGravatar HyoukJoong Lee <hyouklee@google.com>2017-12-08 17:28:52 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-12-08 17:34:28 -0800
commit3457d1222b7e3171153297fb522cc3f729fc11b2 (patch)
tree55f9919ee7a53e30232f973f3e7cc300de031fe8 /tensorflow/compiler/xla/service/layout_assignment.cc
parentd85eec050f83e25b4d70fefd0f04dbf69c20f904 (diff)
Clear existing layouts before running the layout assignment.
PiperOrigin-RevId: 178449701
Diffstat (limited to 'tensorflow/compiler/xla/service/layout_assignment.cc')
-rw-r--r--tensorflow/compiler/xla/service/layout_assignment.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/layout_assignment.cc b/tensorflow/compiler/xla/service/layout_assignment.cc
index 7eda7c2284..af726271ae 100644
--- a/tensorflow/compiler/xla/service/layout_assignment.cc
+++ b/tensorflow/compiler/xla/service/layout_assignment.cc
@@ -1328,6 +1328,20 @@ Status LayoutAssignment::RunOnComputation(
<< ")";
VLOG(2) << " ComputationLayout = " << computation_layout.ToString();
+ // Clear existing layouts of the instructions. All layouts must be assigned by
+ // the LayoutAssignment pass, except for Infeed, Outfeed, Parameters and the
+ // computation result. The latter two are specified in computation_layout, so
+ // we only need to keep the existing layouts for Infeed and Outfeed. Clearing
+ // the layouts here avoids hiding potential bugs in the layout assignment pass
+ // that may accidently use the existing layout.
+ for (HloInstruction* instruction : computation->instructions()) {
+ if (instruction->opcode() == HloOpcode::kInfeed ||
+ instruction->opcode() == HloOpcode::kOutfeed) {
+ continue;
+ }
+ LayoutUtil::ClearLayout(instruction->mutable_shape());
+ }
+
// Construct LayoutConstraints with all layout constraints of the computation.
LayoutConstraints constraints(points_to_analysis, computation);