xref: /aosp_15_r20/external/tensorflow/tensorflow/compiler/mlir/tensorflow/ir/tf_executor.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 // This file defines the tf_executor dialect: it models the TensorFlow executor
17 // semantics and can represent arbitrary TensorFlow graphs. As such it follows
18 // the existing execution model that includes deadness propagation, concurrent
19 // semantics, and control dependencies.
20 
21 #ifndef TENSORFLOW_COMPILER_MLIR_TENSORFLOW_IR_TF_EXECUTOR_H_
22 #define TENSORFLOW_COMPILER_MLIR_TENSORFLOW_IR_TF_EXECUTOR_H_
23 
24 #include "mlir/Dialect/Traits.h"  // from @llvm-project
25 #include "mlir/IR/Attributes.h"  // from @llvm-project
26 #include "mlir/IR/Builders.h"  // from @llvm-project
27 #include "mlir/IR/BuiltinTypes.h"  // from @llvm-project
28 #include "mlir/IR/Dialect.h"  // from @llvm-project
29 #include "mlir/IR/Matchers.h"  // from @llvm-project
30 #include "mlir/IR/OpImplementation.h"  // from @llvm-project
31 #include "tensorflow/compiler/mlir/tensorflow/ir/tf_types.h"
32 
33 namespace mlir {
34 namespace tf_executor {
35 
36 class TensorFlowExecutorDialect : public Dialect {
37  public:
getDialectNamespace()38   static StringRef getDialectNamespace() { return "tf_executor"; }
39   explicit TensorFlowExecutorDialect(MLIRContext *context);
40 
41   // Parses a type registered to this dialect.
42   Type parseType(DialectAsmParser &parser) const override;
43 
44   // Prints a type registered to this dialect.
45   void printType(Type type, DialectAsmPrinter &os) const override;
46 };
47 
48 // The Control type is a token-like value that models control dependencies from
49 // TensorFlow graphs.
50 class ControlType : public Type::TypeBase<ControlType, Type, TypeStorage> {
51  public:
52   using Base::Base;
53 };
54 
55 class TokenType : public Type::TypeBase<TokenType, Type, TypeStorage> {
56  public:
57   using Base::Base;
58 };
59 
60 }  // namespace tf_executor
61 }  // namespace mlir
62 
63 // Declares the operations for this dialect using the generated header.
64 #define GET_OP_CLASSES
65 #include "tensorflow/compiler/mlir/tensorflow/ir/tf_executor.h.inc"
66 
67 #endif  // TENSORFLOW_COMPILER_MLIR_TENSORFLOW_IR_TF_EXECUTOR_H_
68