1 /* Copyright 2021 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_PJRT_MLIR_TO_HLO_H_ 17 #define TENSORFLOW_COMPILER_XLA_PJRT_MLIR_TO_HLO_H_ 18 19 #include "absl/strings/string_view.h" 20 #include "mlir/IR/BuiltinOps.h" // from @llvm-project 21 #include "tensorflow/compiler/xla/client/xla_computation.h" 22 #include "tensorflow/compiler/xla/status.h" 23 24 namespace xla { 25 26 // Converts an MHLO/CHLO module string to an mlir::Module. 27 StatusOr<mlir::OwningOpRef<mlir::ModuleOp>> ParseMlirModuleString( 28 absl::string_view mlir_module_str, mlir::MLIRContext& context); 29 30 // Converts an CHLO/MHLO module to XLA HLO. 31 Status MlirToXlaComputation(mlir::ModuleOp module, 32 XlaComputation& xla_computation, 33 bool use_tuple_args, bool return_tuple); 34 35 // Converts an MHLO/CHLO module string to an XLA computation. 36 Status ParseMlirModuleStringAndConvertToXlaComputation( 37 absl::string_view mlir_module_str, XlaComputation& xla_computation, 38 bool use_tuple_args, bool return_tuple); 39 40 } // namespace xla 41 42 #endif // TENSORFLOW_COMPILER_XLA_PJRT_MLIR_TO_HLO_H_ 43