[Mlir-commits] [mlir] 5b897d9 - Fix classof implementation for QuantizedType (#213014)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jul 30 11:52:12 PDT 2026
Author: vsimion26
Date: 2026-07-30T11:52:07-07:00
New Revision: 5b897d9b57494ef37615cd9af88507a212ab5703
URL: https://github.com/llvm/llvm-project/commit/5b897d9b57494ef37615cd9af88507a212ab5703
DIFF: https://github.com/llvm/llvm-project/commit/5b897d9b57494ef37615cd9af88507a212ab5703.diff
LOG: Fix classof implementation for QuantizedType (#213014)
This PR aims to fix the misleading implementation of `classof` which
accepted as a `QuantizedType` every type registered under the
`QuantDialect.`
The now updated implementation makes the checks more restrictive,
allowing only direct subtypes of `QuantizedType` to be recognized as a
`QuantizedType,` therefore preventing `QuantileType` and other types
that are registered under `QuantDialect` to be seen as a subtype of
`QuantizedType` and wrongfully use its methods which might lead to
potential crashes.
Added:
Modified:
mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp b/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
index 508594c73aefc..8dea51ac16b87 100644
--- a/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
+++ b/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
@@ -41,7 +41,9 @@ unsigned QuantizedType::getFlags() const {
}
bool QuantizedType::classof(Type type) {
- return llvm::isa<QuantDialect>(type.getDialect());
+ return llvm::isa<AnyQuantizedType, UniformQuantizedType,
+ UniformQuantizedPerAxisType, UniformQuantizedSubChannelType,
+ CalibratedQuantizedType>(type);
}
LogicalResult
More information about the Mlir-commits
mailing list