diff options
author | Bixia Zheng <bixia@google.com> | 2018-10-05 11:49:19 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-10-05 11:54:17 -0700 |
commit | 03b4161326897453fa6b2803b873954607f7623b (patch) | |
tree | 26753b2411e13844541948aa59a293cd47cf7229 /tensorflow/compiler/xla/service/cpu | |
parent | 496bc1589831da2f00e6d49b12c68b97301730d4 (diff) |
[XLA] Extend the HLO verifier to check that non-layout-changing instructions
preserve operand layouts.
Add an std::function member to the HloVerifier for a backend to specify the
function object used to determine whether an instruction can change layouts.
Use the function object to find out the non-layout-changing instructions and
check that such instructions should produce results with the same layouts as
its operands.
Add test cases.
PiperOrigin-RevId: 215941282
Diffstat (limited to 'tensorflow/compiler/xla/service/cpu')
-rw-r--r-- | tensorflow/compiler/xla/service/cpu/cpu_compiler.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc index 5834f67285..68c715a086 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc +++ b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc @@ -327,8 +327,13 @@ Status CpuCompiler::RunHloPassesAfterLayoutAssn( { auto& pass = pipeline.AddPass<HloPassFix<HloPassPipeline>>( "simplification after layout assignement"); - pass.AddInvariantChecker<HloVerifier>(/*layout_sensitive=*/true, - /*allow_mixed_precision=*/false); + // TODO(b/117156505): When the bug is fixed, the CPU backend should not + // produce layout changing elementwise operations. We will then pass + // LayoutAssignment::InstructionCanChangeLayout to the HLO verifier to + // enable stricter verification. + pass.AddInvariantChecker<HloVerifier>( + /*layout_sensitive=*/true, + /*allow_mixed_precision=*/false); pass.AddPass<HloPassFix<AlgebraicSimplifier>>( /*is_layout_sensitive=*/true, [](const Shape&, const Shape&) { return true; }, |