• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2018 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 "tensorflow/compiler/xla/service/gpu/tests/gpu_codegen_test.h"
17 #include "absl/memory/memory.h"
18 #include "tensorflow/compiler/xla/debug_options_flags.h"
19 #include "tensorflow/compiler/xla/service/gpu/gpu_executable.h"
20 #include "tensorflow/compiler/xla/tests/filecheck.h"
21 #include "tensorflow/core/platform/logging.h"
22 
23 namespace xla {
24 namespace gpu {
25 
CreateNewUnverifiedModuleWithFTZ(bool ftz)26 std::unique_ptr<HloModule> GpuCodegenTest::CreateNewUnverifiedModuleWithFTZ(
27     bool ftz) {
28   HloModuleConfig config;
29   auto debug_options = GetDebugOptionsFromFlags();
30   debug_options.set_xla_gpu_ftz(ftz);
31   debug_options.set_xla_gpu_max_kernel_unroll_factor(1);
32   // TODO(b/38354253): Change tests to use Parameters instead of Constants.
33   debug_options.add_xla_disable_hlo_passes("constant_folding");
34   config.set_debug_options(debug_options);
35 
36   return absl::make_unique<HloModule>(TestName(), config);
37 }
38 
CompileAndVerifyPtx(std::unique_ptr<HloModule> hlo_module,const string & pattern)39 void GpuCodegenTest::CompileAndVerifyPtx(std::unique_ptr<HloModule> hlo_module,
40                                          const string& pattern) {
41   std::unique_ptr<Executable> executable =
42       std::move(CompileToExecutable(std::move(hlo_module)).ValueOrDie());
43   string ptx_str(static_cast<GpuExecutable*>(executable.get())->ptx());
44   StatusOr<bool> filecheck_result = RunFileCheck(ptx_str, pattern);
45   ASSERT_TRUE(filecheck_result.ok());
46   EXPECT_TRUE(filecheck_result.ValueOrDie());
47 }
48 
49 }  // namespace gpu
50 }  // namespace xla
51