1 /* Copyright 2019 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 #ifndef TENSORFLOW_COMPILER_XLA_TOOLS_PREPARE_REFERENCE_MODULE_H_ 17 #define TENSORFLOW_COMPILER_XLA_TOOLS_PREPARE_REFERENCE_MODULE_H_ 18 19 #include <functional> 20 #include <memory> 21 22 #include "tensorflow/compiler/xla/service/hlo_module.h" 23 #include "tensorflow/compiler/xla/service/hlo_module_config.h" 24 #include "tensorflow/compiler/xla/service/hlo_runner_interface.h" 25 #include "tensorflow/compiler/xla/statusor.h" 26 #include "tensorflow/stream_executor/lib/status.h" 27 #include "tensorflow/stream_executor/platform.h" 28 29 namespace xla { 30 31 // A helper function that takes a HloModule, derives a HloModuleConfig from it 32 // which disables fast-math und sets the DebugOptions from flags, then runs the 33 // deoptimization pipeline (or calls 'module_modifier_hook' if provided). This 34 // is meant to produce a reference module that is comparable to our custom test 35 // platforms. 36 StatusOr<std::unique_ptr<HloModule>> PrepareReferenceModule( 37 const HloModule& test_module, HloRunnerInterface* test_runner, 38 const std::function<void(HloModuleConfig*)>& config_modifier_hook = {}, 39 const std::function<Status(const HloModule&, HloRunnerInterface*, 40 HloModule*)>& module_modifier_hook = {}); 41 42 } // namespace xla 43 44 #endif // TENSORFLOW_COMPILER_XLA_TOOLS_PREPARE_REFERENCE_MODULE_H_ 45