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_CORE_IR_OPS_H_ 17 #define TENSORFLOW_CORE_IR_OPS_H_ 18 19 #include "mlir/IR/Attributes.h" // from @llvm-project 20 #include "mlir/IR/Builders.h" // from @llvm-project 21 #include "mlir/IR/BuiltinOps.h" // from @llvm-project 22 #include "mlir/IR/BuiltinTypes.h" // from @llvm-project 23 #include "mlir/IR/Dialect.h" // from @llvm-project 24 #include "mlir/IR/FunctionInterfaces.h" // from @llvm-project 25 #include "mlir/IR/Matchers.h" // from @llvm-project 26 #include "mlir/IR/OpImplementation.h" // from @llvm-project 27 #include "mlir/IR/PatternMatch.h" // from @llvm-project 28 #include "mlir/IR/RegionKindInterface.h" // from @llvm-project 29 #include "mlir/IR/TypeUtilities.h" // from @llvm-project 30 #include "mlir/Interfaces/CallInterfaces.h" // from @llvm-project 31 #include "mlir/Interfaces/ControlFlowInterfaces.h" // from @llvm-project 32 #include "mlir/Interfaces/InferTypeOpInterface.h" // from @llvm-project 33 #include "tensorflow/core/ir/dialect.h" 34 #include "tensorflow/core/ir/interfaces.h" 35 #include "tensorflow/core/ir/tf_op_wrapper.h" 36 37 // Get the C++ declaration for all the ops defined in ODS for the dialect. 38 39 #define GET_OP_CLASSES 40 #include "tensorflow/core/ir/ops.h.inc" 41 42 namespace mlir { 43 namespace tfg { 44 45 // Analysis that keeps track of all function names in a module. 46 struct FunctionTable { 47 explicit FunctionTable(ModuleOp module); 48 49 // Returns whether there are no functions. emptyFunctionTable50 bool empty() const { return functions.empty(); } 51 52 // Returns whether `op` may be a function call. 53 bool MayBeCall(Operation* op) const; 54 55 // Returns whether `op` is a legacy function call. A "legacy" function call 56 // is when the operation name is the name of a function in the library. 57 bool IsLegacyCall(Operation* op) const; 58 59 private: 60 // All the functions in the graph. 61 DenseSet<StringRef> functions; 62 }; 63 64 } // namespace tfg 65 } // namespace mlir 66 67 #endif // TENSORFLOW_CORE_IR_OPS_H_ 68