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 operations used in the MLIR TensorFlow Lite dialect. 17 18 #ifndef TENSORFLOW_COMPILER_MLIR_LITE_IR_TFL_OPS_H_ 19 #define TENSORFLOW_COMPILER_MLIR_LITE_IR_TFL_OPS_H_ 20 21 #include "mlir/Dialect/Quant/QuantOps.h" // from @llvm-project 22 #include "mlir/Dialect/Traits.h" // from @llvm-project 23 #include "mlir/IR/Attributes.h" // from @llvm-project 24 #include "mlir/IR/Builders.h" // from @llvm-project 25 #include "mlir/IR/BuiltinTypes.h" // from @llvm-project 26 #include "mlir/IR/Dialect.h" // from @llvm-project 27 #include "mlir/IR/OpImplementation.h" // from @llvm-project 28 #include "mlir/Interfaces/DerivedAttributeOpInterface.h" // from @llvm-project 29 #include "mlir/Interfaces/InferTypeOpInterface.h" // from @llvm-project 30 #include "mlir/Interfaces/LoopLikeInterface.h" // from @llvm-project 31 #include "mlir/Interfaces/SideEffectInterfaces.h" // from @llvm-project 32 #include "mlir/Support/LLVM.h" // from @llvm-project 33 #include "tensorflow/compiler/mlir/lite/ir/tfl_structs.h.inc" 34 #include "tensorflow/compiler/mlir/lite/quantization/quantization_utils.h" 35 #include "tensorflow/lite/schema/schema_generated.h" 36 37 namespace mlir { 38 namespace TFL { 39 40 class TensorFlowLiteDialect : public Dialect { 41 public: 42 explicit TensorFlowLiteDialect(MLIRContext *context); 43 getDialectNamespace()44 static StringRef getDialectNamespace() { return "tfl"; } 45 46 // Registered hook to materialize a constant operation from a given attribute 47 // value with the desired resultant type. 48 Operation *materializeConstant(OpBuilder &builder, Attribute value, Type type, 49 Location loc) override; 50 }; 51 52 #include "tensorflow/compiler/mlir/lite/ir/tfl_ops_interface.h.inc" 53 54 } // end namespace TFL 55 } // end namespace mlir 56 57 #define GET_OP_CLASSES 58 #include "tensorflow/compiler/mlir/lite/ir/tfl_ops.h.inc" 59 60 #endif // TENSORFLOW_COMPILER_MLIR_LITE_IR_TFL_OPS_H_ 61