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 #ifndef TENSORFLOW_COMPILER_MLIR_LITE_UTILS_CONVERT_TYPE_H_ 17 #define TENSORFLOW_COMPILER_MLIR_LITE_UTILS_CONVERT_TYPE_H_ 18 19 #include "mlir/IR/BuiltinAttributes.h" // from @llvm-project 20 #include "mlir/IR/Types.h" // from @llvm-project 21 #include "mlir/IR/Value.h" // from @llvm-project 22 #include "tensorflow/compiler/xla/statusor.h" 23 #include "tensorflow/core/framework/types.pb.h" 24 #include "tensorflow/lite/schema/schema_generated.h" 25 26 namespace mlir { 27 class Builder; 28 } // namespace mlir 29 30 namespace tflite { 31 // Convert the scalar type of a TFlite tensor to the corresponding MLIR type. 32 mlir::Type ConvertElementType(tflite::TensorType type, mlir::Builder builder); 33 34 // Convert the scalar type of a TFLite tensor to the corresponding 35 // Tensorflow type 36 tensorflow::DataType TflTypeToTfType(tflite::TensorType type); 37 38 // Convert the Tensorflow scalar type to the corresponding TFLite type 39 xla::StatusOr<tflite::TensorType> TfTypeToTflType(tensorflow::DataType type); 40 41 // Returns element type from attribute Type 'type_attr'. 42 mlir::Type GetShapeStrippedType(mlir::TypeAttr type_attr); 43 44 // Returns true if 'val' is not from Quantize op or 45 // from Quantize Op with same quant type as 'qtype_attr' 46 bool NotFromQuantOpOrSameQuantType(mlir::Value val, mlir::TypeAttr qtype_attr); 47 48 } // namespace tflite 49 #endif // TENSORFLOW_COMPILER_MLIR_LITE_UTILS_CONVERT_TYPE_H_ 50