Check quantized-storage-type to be a signless integer #2054
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.
Current StablehLO quantized signed int cs uses
mlir::quant::QuantizedType::isSIgned
to decide on the signed-ness of the storage type.StableHLO, as bootstrapped from MHLO, inherits
signless
integers (added in MHLO for some legacy reasons) to be treated as signed integer. This is not captured by the checkmlir::quant::QuantizedType::isSigned
because of the following reason.Based on this,
mlir::quant::QuantizedType::isSIgned()
is true if the associated bit in flag is 1. Here are a few ways to set that flag as true.In other words, It is on the producers of
mlir::quant::QuantizedType
to set that bit based on their interpretation of signedness, which in case of StableHLO is signedless. That means the atrue
value ofmlir::quant::QuantizedType::isSIgned()
is not enough to ensure that the desired signed-ness of storage type.Suggested change
Replace
with
IMO, we can skip the check
mlir::quant::UniformQuantizedType::isSigned()
altogether as is it not sufficient nor necessary.Context: #1812 (comment)