-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Extending UniformQuantizedType with interface-based support for new storage types in Quant dialect #152966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Roman-Pevnyi
wants to merge
4
commits into
llvm:main
Choose a base branch
from
Roman-Pevnyi:quant_dialect_add_quantization_interface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+301
−76
Open
Extending UniformQuantizedType with interface-based support for new storage types in Quant dialect #152966
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
784e1d7
Added new type interafce to let UniformQuantizeType accept other than…
Roman-Pevnyi 407fae4
Added QuantizationInterface to Float8E5M2Type and Float8E4M3FNType
Roman-Pevnyi d7447a8
Renamed to QuantStorageTypeInterface and removed redundant dyn_cast c…
Roman-Pevnyi f8458e7
Added interface methods which expose a few basic packing and alignmen…
Roman-Pevnyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===- QuantStorageTypeInterface.h - Quantzation Interfaces --------*- 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_IR_QuantStorageTypeInterface_H | ||
#define MLIR_IR_QuantStorageTypeInterface_H | ||
|
||
#include "mlir/IR/Types.h" | ||
|
||
// Forward declarations for the types we need in the implementation | ||
namespace mlir { | ||
class IntegerType; | ||
} // namespace mlir | ||
|
||
#include "mlir/IR/QuantStorageTypeInterface.h.inc" | ||
|
||
#endif // MLIR_IR_QuantStorageTypeInterface_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#ifndef MLIR_IR_QUANTSTORAGETYPEINTERFACE | ||
#define MLIR_IR_QUANTSTORAGETYPEINTERFACE | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def QuantStorageTypeInterface : TypeInterface<"QuantStorageTypeInterface"> { | ||
let description = [{ | ||
Interface for types that can be used as storage types in Quant dialect. | ||
This interface provides methods to determine storage characteristics for quantization purposes, | ||
including packing behavior, and alignment requirements. | ||
}]; | ||
let cppNamespace = "::mlir"; | ||
|
||
let methods = [ | ||
InterfaceMethod<[{ | ||
Check if the storage type is signed. | ||
Returns true if the type represents signed values, false for unsigned. | ||
}], | ||
"bool", "isStorageSigned", (ins)>, | ||
|
||
InterfaceMethod<[{ | ||
Get the bit width of this type. | ||
Returns the number of bits used to store values of this type. | ||
}], | ||
"unsigned", "getStorageWidth", (ins)>, | ||
|
||
InterfaceMethod<[{ | ||
Get default minimum value for this type. | ||
}], | ||
"int64_t", "getDefaultMinimum", (ins)>, | ||
|
||
InterfaceMethod<[{ | ||
Get default maximum value for this type. | ||
}], | ||
"int64_t", "getDefaultMaximum", (ins)>, | ||
|
||
InterfaceMethod<[{ | ||
Get the storage type as a string. | ||
}], | ||
"std::string", "getStorageType", (ins)>, | ||
|
||
InterfaceMethod<[{ | ||
Check if the storage type uses packed representation. | ||
Returns true if multiple values are packed into one byte (e.g., sub-byte types), | ||
false if value uses full byte. | ||
}], | ||
"bool", "isPacked", (ins)>, | ||
|
||
InterfaceMethod<[{ | ||
Get the logical bit width per value. | ||
For packed sub-byte types, this may differ from getStorageWidth(). | ||
}], | ||
"unsigned", "getLogicalBitWidth", (ins)>, | ||
|
||
InterfaceMethod<[{ | ||
Get the number of logical elements that fit in one byte. | ||
For packed sub-byte types, this returns how many values can be stored per byte. | ||
}], | ||
"unsigned", "getElementsPerByte", (ins)>, | ||
|
||
InterfaceMethod<[{ | ||
Returns the preferred alignment for this type, in bytes. | ||
}], | ||
"std::optional<unsigned>", "getPreferredAlignmentBytes", (ins)> | ||
]; | ||
|
||
} | ||
|
||
#endif // MLIR_IR_QUANTSTORAGETYPEINTERFACE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.