1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15
16 #include <utility>
17
18 #include "tensorflow/compiler/xla/service/gpu/tests/gpu_codegen_test.h"
19 #include "tensorflow/compiler/xla/service/hlo_instruction.h"
20 #include "tensorflow/compiler/xla/service/hlo_module_config.h"
21
22 namespace xla {
23 namespace gpu {
24
25 namespace {
26
27 // WARNING: This tests must be alone in its file! Otherwise, the
28 // error isn't caught. We expect and CUDA_ERROR_ILLEGAL_ADDRESS to be
29 // thrown with the old buggy code.
30 class CopyAloneNoOptTest : public GpuCodegenTest {
GetDebugOptionsForTest()31 DebugOptions GetDebugOptionsForTest() override {
32 DebugOptions debug_options = GpuCodegenTest::GetDebugOptionsForTest();
33 // The test MultiOutputStore contain a MOF fusion and XLA optimizer pass
34 // doesn't like this.
35 debug_options.set_xla_disable_all_hlo_passes(true);
36 return debug_options;
37 }
38 };
39
TEST_F(CopyAloneNoOptTest,CopyTranspose)40 TEST_F(CopyAloneNoOptTest, CopyTranspose) {
41 const char* hlo_text = R"(
42 HloModule mod
43 ENTRY main {
44 %param = f32[8,32,32,32,16]{4,3,2,1,0} parameter(0)
45 ROOT %copy = f32[8,32,32,32,16]{3,2,1,4,0} copy(f32[8,32,32,32,16]{4,3,2,1,0} %param)
46 }
47 )";
48 TF_ASSERT_OK_AND_ASSIGN(std::unique_ptr<VerifiedHloModule> optimized_module,
49 ParseAndReturnVerifiedModule(hlo_text));
50
51 EXPECT_TRUE(RunAndCompare(hlo_text, ErrorSpec{1e-5, 1e-5}));
52
53 CompileAndOptionallyVerifyPtx(std::move(optimized_module),
54 R"(
55 CHECK-NOT: ld.global.nc.v2
56 )");
57 }
58
59 } // namespace
60 } // namespace gpu
61 } // namespace xla
62