xref: /aosp_15_r20/external/tensorflow/tensorflow/compiler/mlir/tfr/ir/tfr_ops.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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 #ifndef TENSORFLOW_COMPILER_MLIR_TFR_IR_TFR_OPS_H_
17 #define TENSORFLOW_COMPILER_MLIR_TFR_IR_TFR_OPS_H_
18 
19 #include "llvm/ADT/StringSet.h"
20 #include "mlir/Dialect/Func/IR/FuncOps.h"  // from @llvm-project
21 #include "mlir/Dialect/Shape/IR/Shape.h"  // from @llvm-project
22 #include "mlir/IR/BuiltinOps.h"  // from @llvm-project
23 #include "mlir/IR/BuiltinTypes.h"  // from @llvm-project
24 #include "mlir/IR/Dialect.h"  // from @llvm-project
25 #include "mlir/IR/DialectImplementation.h"  // from @llvm-project
26 #include "mlir/IR/FunctionInterfaces.h"  // from @llvm-project
27 #include "mlir/IR/MLIRContext.h"  // from @llvm-project
28 #include "mlir/IR/Types.h"  // from @llvm-project
29 #include "mlir/Interfaces/CallInterfaces.h"  // from @llvm-project
30 #include "mlir/Interfaces/ControlFlowInterfaces.h"  // from @llvm-project
31 #include "mlir/Interfaces/InferTypeOpInterface.h"  // from @llvm-project
32 #include "mlir/Interfaces/SideEffectInterfaces.h"  // from @llvm-project
33 
34 namespace mlir {
35 namespace TFR {
36 
37 constexpr char kAttrArgumentNameAttr[] = "tfr.name";
38 constexpr char kAttrArgumentDefaultAttr[] = "tfr.default";
39 constexpr char kAttrArgumentTypeAttr[] = "tfr.type";
40 
41 class TFRDialect : public Dialect {
42  public:
43   explicit TFRDialect(MLIRContext *context);
44 
getDialectNamespace()45   static StringRef getDialectNamespace() { return "tfr"; }
46 
47   Operation *materializeConstant(OpBuilder &builder, Attribute value, Type type,
48                                  Location loc) override;
49 
50   // Parse a type registered to this dialect.
51   Type parseType(DialectAsmParser &parser) const override;
52 
53   // Prints a type registered to this dialect.
54   void printType(Type ty, DialectAsmPrinter &os) const override;
55 };
56 
57 }  // namespace TFR
58 }  // namespace mlir
59 
60 #define GET_OP_CLASSES
61 #include "tensorflow/compiler/mlir/tfr/ir/tfr_ops.h.inc"
62 
63 #endif  // TENSORFLOW_COMPILER_MLIR_TFR_IR_TFR_OPS_H_
64