1 /* Copyright 2022 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 // Functions for quantization specifications of TensorFlow ops. 16 17 #ifndef TENSORFLOW_COMPILER_MLIR_QUANTIZATION_TENSORFLOW_OPS_QUANTIZABLE_OP_SPEC_H_ 18 #define TENSORFLOW_COMPILER_MLIR_QUANTIZATION_TENSORFLOW_OPS_QUANTIZABLE_OP_SPEC_H_ 19 20 #include <memory> 21 22 #include "mlir/IR/Operation.h" // from @llvm-project 23 #include "tensorflow/compiler/mlir/lite/quantization/quantization_config.h" 24 #include "tensorflow/compiler/mlir/lite/quantization/quantization_utils.h" 25 #include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h" 26 27 namespace mlir { 28 namespace quant { 29 30 // Returns the spec for the given operation that can be used for both of 31 // dynamic and static range quantization. 32 std::unique_ptr<OpQuantSpec> GetTFOpQuantSpec(Operation* op); 33 34 // Returns quantization scale specs (fixed output, same scale) for a TF op. 35 // TODO(b/224691264): Implement same scale verification like `VerifySameScales` 36 std::unique_ptr<OpQuantScaleSpec> GetTfQuantScaleSpec(Operation* op); 37 38 } // namespace quant 39 } // namespace mlir 40 41 #endif // TENSORFLOW_COMPILER_MLIR_QUANTIZATION_TENSORFLOW_OPS_QUANTIZABLE_OP_SPEC_H_ 42