Skip to content

[MLIR][TOSA] guard against illegal rw with quant types#827

Open
tr00 wants to merge 1 commit into
aie-publicfrom
tarik.TOSA-quant-types
Open

[MLIR][TOSA] guard against illegal rw with quant types#827
tr00 wants to merge 1 commit into
aie-publicfrom
tarik.TOSA-quant-types

Conversation

@tr00
Copy link
Copy Markdown
Contributor

@tr00 tr00 commented Mar 6, 2026

The TOSA dialect allows building with quant types from the Quant dialect, but some rewrites such as abs(abs(x)) --> abs(x) are not semantic-preserving when x is e.g. tensor<...x!quant.uniform<...>>.
Added guards and LIT tests for abs and negate canonicalization.

@@ -26,6 +29,18 @@ namespace tosa {
// Utility functions to support quantization handling in Tosa.
//===----------------------------------------------------------------------===//

/// Returns true if the type is a quantized tensor.
inline bool isQuantizedTensor(Type type) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this to the .cpp

@@ -26,6 +29,18 @@ namespace tosa {
// Utility functions to support quantization handling in Tosa.
//===----------------------------------------------------------------------===//

/// Returns true if the type is a quantized tensor.
inline bool isQuantizedTensor(Type type) {
auto tensorType = mlir::dyn_cast<RankedTensorType>(type);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cast or getElementTypeOrSelf

@tr00 tr00 force-pushed the tarik.TOSA-quant-types branch from ca3ea4a to 2db5043 Compare March 10, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants