xref: /aosp_15_r20/external/tensorflow/tensorflow/compiler/mlir/xla/xla_mlir_translate.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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_MLIR_XLA_XLA_MLIR_TRANSLATE_H_
17 #define TENSORFLOW_COMPILER_MLIR_XLA_XLA_MLIR_TRANSLATE_H_
18 
19 #include <memory>
20 
21 #include "tensorflow/compiler/xla/statusor.h"
22 
23 namespace llvm {
24 class StringRef;
25 }  // namespace llvm
26 
27 namespace mlir {
28 class MLIRContext;
29 class ModuleOp;
30 template <typename OpTy>
31 class OwningOpRef;
32 }  // namespace mlir
33 
34 namespace xla {
35 
36 // Converts a HloModuleProto stored in the file with the given `input_filename`
37 // into a MLIR module. Creates MLIR entities into the given MLIR `context`.
38 // If import_all_computation is set to true, imports all computations
39 // irrespective if transitively called from entry computation.
40 mlir::OwningOpRef<mlir::ModuleOp> HloToMlirHloTranslateFunction(
41     llvm::StringRef input, mlir::MLIRContext* context,
42     bool import_all_computations = false);
43 
44 // Converts a HloModule stored in text form for a file with the given
45 // `input_filename` into a MLIR module. Creates MLIR entities into the given
46 // MLIR `context`.
47 // If import_all_computation is set to true, imports all computations
48 // irrespective if transitively called from entry computation.
49 mlir::OwningOpRef<mlir::ModuleOp> HloTextToMlirHloTranslateFunction(
50     llvm::StringRef input, mlir::MLIRContext* context,
51     bool import_all_computations = false);
52 
53 }  // namespace xla
54 
55 #endif  // TENSORFLOW_COMPILER_MLIR_XLA_XLA_MLIR_TRANSLATE_H_
56