//===- UniformSupport.h - Support utilities for uniform quant ---*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_QUANT_UTILS_UNIFORMSUPPORT_H_ #define MLIR_DIALECT_QUANT_UTILS_UNIFORMSUPPORT_H_ #include <utility> #include "mlir/Dialect/Quant/IR/QuantTypes.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Types.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/APSInt.h" namespace mlir { namespace quant { /// Performs type conversion from an arbitrary input type to a type /// that is expressed by a QuantizedType. /// /// This handles cases where the inputType is a supported primitive type /// (i.e. f32, bf16, etc) or a vector/tensor type based on a supported /// elemental type. /// /// Since conversion often involves introspecting some attributes of the /// input type in order to determine how to represent it, this is a two step /// process. struct ExpressedToQuantizedConverter { … }; /// Reference implementation of converting between real numbers and values /// represented by a UniformQuantizedType. /// Note that this is not expected to be speedy and may be superseded eventually /// by a more optimal implementation. /// Also, the interface assumes that quantization is done per-layer and will /// need to be wider for various per-channel schemes. As such, this is a /// placeholder. class UniformQuantizedValueConverter { … }; /// An utility class to quantize an attribute by the per-axis quantization /// parameters. The size of the quantization dim in the converted elements /// attribute should match the size of scales/zeroPoints vectors in the /// quantization parameters. class UniformQuantizedPerAxisValueConverter { … }; } // namespace quant } // namespace mlir #endif // MLIR_DIALECT_QUANT_UTILS_UNIFORMSUPPORT_H_