//===- QuantOps.cpp - Quantization Type and Ops Implementation --*- 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 // //===----------------------------------------------------------------------===// #include "QuantDialectBytecode.h" #include "TypeDetail.h" #include "mlir/Dialect/Quant/IR/Quant.h" #include "mlir/Dialect/Quant/IR/QuantTypes.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" #include "mlir/Dialect/Quant/IR/QuantOpsDialect.cpp.inc" namespace mlir { namespace quant { namespace { // Verify the integrity of per-axis quantization information, if present. // // - quantizedType // Any quantized type. Any quantized type with no per-axis quantization is // ignored. // // - containerType // Original input or result type of the operation using the provided quantized // type. Used to ensure that the quantized type appears within a tensor and // that the tensor is compatible with per-axis quantization information. // LogicalResult verifyPerAxisQuantization(Operation *op, QuantizedType quantizedType, Type containerType) { … } // Common verification logic for 'quant.dcast' and 'quant.qcast' ops. // // - quantizedType // Quantized type used in the input ('quant.dcast') or result ('quant.qcast'), // whether as a primitive type or in a tensor. // // - floatType // Float type used in the input ('quant.qcast') or result ('quant.dcast'), // whether as a primitive type or in a tensor. // // - containerType // Type of original input or result. // LogicalResult verifyQuantizationOp(Operation *op, QuantizedType quantizedType, FloatType floatType, Type containerType) { … } } // namespace //===----------------------------------------------------------------------===// // Dialect //===----------------------------------------------------------------------===// void QuantDialect::initialize() { … } //===----------------------------------------------------------------------===// // DequantizeCastOp //===----------------------------------------------------------------------===// LogicalResult DequantizeCastOp::verify() { … } OpFoldResult DequantizeCastOp::fold(FoldAdaptor adaptor) { … } FloatType DequantizeCastOp::getFloatType() { … } QuantizedType DequantizeCastOp::getQuantizedType() { … } //===----------------------------------------------------------------------===// // QuantizeCastOp //===----------------------------------------------------------------------===// LogicalResult QuantizeCastOp::verify() { … } OpFoldResult QuantizeCastOp::fold(FoldAdaptor adaptor) { … } FloatType QuantizeCastOp::getFloatType() { … } QuantizedType QuantizeCastOp::getQuantizedType() { … } //===----------------------------------------------------------------------===// // StorageCastOp //===----------------------------------------------------------------------===// LogicalResult StorageCastOp::verify() { … } OpFoldResult StorageCastOp::fold(FoldAdaptor adaptor) { … } IntegerType StorageCastOp::getIntegerType() { … } QuantizedType StorageCastOp::getQuantizedType() { … } } // namespace quant } // namespace mlir #define GET_OP_CLASSES #include "mlir/Dialect/Quant/IR/QuantOps.cpp.inc"