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 #ifndef TENSORFLOW_COMPILER_MLIR_TFRT_IR_TFRT_FALLBACK_H_ 16 #define TENSORFLOW_COMPILER_MLIR_TFRT_IR_TFRT_FALLBACK_H_ 17 18 #include "mlir/IR/BuiltinOps.h" // from @llvm-project 19 #include "mlir/IR/Dialect.h" // from @llvm-project 20 #include "mlir/IR/OpDefinition.h" // from @llvm-project 21 #include "mlir/IR/OpImplementation.h" // from @llvm-project 22 #include "mlir/Interfaces/SideEffectInterfaces.h" // from @llvm-project 23 24 using namespace mlir; // NOLINT 25 26 namespace tfrt { 27 namespace fallback { 28 29 // Dialect for fallback operations. 30 class FallbackDialect : public Dialect { 31 public: 32 explicit FallbackDialect(MLIRContext *context); getDialectNamespace()33 static StringRef getDialectNamespace() { return "tfrt_fallback"; } 34 35 Type parseType(DialectAsmParser &parser) const override; 36 void printType(Type type, DialectAsmPrinter &os) const override; 37 }; 38 39 // The MLIR type represents a tensorflow::Tensor. 40 class TFTensorType : public Type::TypeBase<TFTensorType, Type, TypeStorage> { 41 public: 42 using Base::Base; 43 }; 44 45 // The MLIR type represents a tensorflow::Allocator. 46 class TFAllocatorType 47 : public Type::TypeBase<TFAllocatorType, Type, TypeStorage> { 48 public: 49 using Base::Base; 50 }; 51 52 } // namespace fallback 53 } // namespace tfrt 54 55 #define GET_OP_CLASSES 56 #include "tensorflow/compiler/mlir/tfrt/ir/tfrt_fallback.h.inc" 57 58 #endif // TENSORFLOW_COMPILER_MLIR_TFRT_IR_TFRT_FALLBACK_H_ 59