@@ -6,7 +6,8 @@ include "mlir/IR/OpBase.td"
66def QuantStorageTypeInterface : TypeInterface<"QuantStorageTypeInterface"> {
77 let description = [{
88 Interface for types that can be used as storage types in Quant dialect.
9- This interface provides methods to determine storage characteristics for quantization purposes.
9+ This interface provides methods to determine storage characteristics for quantization purposes,
10+ including packing behavior, and alignment requirements.
1011 }];
1112 let cppNamespace = "::mlir";
1213
@@ -18,25 +19,49 @@ def QuantStorageTypeInterface : TypeInterface<"QuantStorageTypeInterface"> {
1819 "bool", "isStorageSigned", (ins)>,
1920
2021 InterfaceMethod<[{
21- Get the bit width of this integer type.
22+ Get the bit width of this type.
2223 Returns the number of bits used to store values of this type.
2324 }],
2425 "unsigned", "getStorageWidth", (ins)>,
2526
2627 InterfaceMethod<[{
27- Get default minimum value for this integer type.
28+ Get default minimum value for this type.
2829 }],
2930 "int64_t", "getDefaultMinimum", (ins)>,
3031
3132 InterfaceMethod<[{
32- Get default maximum value for this integer type.
33+ Get default maximum value for this type.
3334 }],
3435 "int64_t", "getDefaultMaximum", (ins)>,
3536
3637 InterfaceMethod<[{
3738 Get the storage type as a string.
3839 }],
39- "std::string", "getStorageType", (ins)>
40+ "std::string", "getStorageType", (ins)>,
41+
42+ InterfaceMethod<[{
43+ Check if the storage type uses packed representation.
44+ Returns true if multiple values are packed into one byte (e.g., sub-byte types),
45+ false if value uses full byte.
46+ }],
47+ "bool", "isPacked", (ins)>,
48+
49+ InterfaceMethod<[{
50+ Get the logical bit width per value.
51+ For packed sub-byte types, this may differ from getStorageWidth().
52+ }],
53+ "unsigned", "getLogicalBitWidth", (ins)>,
54+
55+ InterfaceMethod<[{
56+ Get the number of logical elements that fit in one byte.
57+ For packed sub-byte types, this returns how many values can be stored per byte.
58+ }],
59+ "unsigned", "getElementsPerByte", (ins)>,
60+
61+ InterfaceMethod<[{
62+ Returns the preferred alignment for this type, in bytes.
63+ }],
64+ "std::optional<unsigned>", "getPreferredAlignmentBytes", (ins)>
4065 ];
4166
4267}
0 commit comments