aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/layout_assignment_test.cc
diff options
context:
space:
mode:
authorGravatar Sanjoy Das <sanjoy@google.com>2018-02-27 11:57:09 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-02-27 12:01:12 -0800
commitd429fe193f4c235cde8223804ea888c2eaa5ce68 (patch)
tree1b1d5fba701043ecd38e64866d42c039153618a7 /tensorflow/compiler/xla/service/layout_assignment_test.cc
parent207af365eb719fa7af3b56e1723fe3f67b0c4f0f (diff)
Improve our handling of bitcasts.
- Do not fuse bitcasts in the CPU backend. Fused instructions lose their layout and a bitcast is meaningless without a layout. We were explicitly testing for this so I've changed the corresponding tests to use a reshape instead. - Fail the layout assignment if we see a bitcast. bitcasts are inherently layout sensitive and so a bitcast instruction present in the IR before layout assignment is a bug. PiperOrigin-RevId: 187210151
Diffstat (limited to 'tensorflow/compiler/xla/service/layout_assignment_test.cc')
-rw-r--r--tensorflow/compiler/xla/service/layout_assignment_test.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/layout_assignment_test.cc b/tensorflow/compiler/xla/service/layout_assignment_test.cc
index 62feb7c1e9..4b1c9bad41 100644
--- a/tensorflow/compiler/xla/service/layout_assignment_test.cc
+++ b/tensorflow/compiler/xla/service/layout_assignment_test.cc
@@ -796,5 +796,26 @@ TEST_F(LayoutAssignmentTest, ConditionalAsymmetricLayout) {
EXPECT_THAT(false_result->opcode(), HloOpcode::kCopy);
}
+TEST_F(LayoutAssignmentTest, InternalErrorOnBitcast) {
+ auto builder = HloComputation::Builder(TestName());
+ auto constant0 = builder.AddInstruction(
+ HloInstruction::CreateConstant(Literal::CreateR2WithLayout<float>(
+ {{1.0, 2.0}, {3.0, 4.0}}, LayoutUtil::MakeLayout({0, 1}))));
+ builder.AddInstruction(HloInstruction::CreateUnary(
+ constant0->shape(), HloOpcode::kBitcast, constant0));
+ auto module = CreateNewModule();
+ module->AddEntryComputation(builder.Build());
+
+ ComputationLayout computation_layout(
+ module->entry_computation()->ComputeProgramShape());
+ LayoutAssignment layout_assignment(&computation_layout);
+ Status error_status = layout_assignment.Run(module.get()).status();
+ EXPECT_FALSE(error_status.ok());
+ EXPECT_THAT(
+ error_status.error_message(),
+ ::testing::HasSubstr(
+ "Unexpected bitcast operation seen during layout assignment"));
+}
+
} // namespace
} // namespace xla