[Mlir-commits] [mlir] [mlir][tablegen] Correctly set Type constraint description (PR #110939)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Oct 2 16:37:53 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
@llvm/pr-subscribers-mlir
Author: luis (penagos)
<details>
<summary>Changes</summary>
The common tablegen `Type` constraint was not honoring user specified description strings by unconditionally setting `Constraint`'s description to the empty string (this appears to be inadvertent fallout from https://reviews.llvm.org/D94133 in which `typeDescription` was renamed to `description`, shadowing the existing `description` field on `Constraint`).
This has the effect of making select quantized types (among other things) indistinguishable. For example, quantized types in the TFLite dialect are defined as:
```
def QUI8 : QuantizedType<"Uniform", [8], 0>;
def QI8 : QuantizedType<"Uniform", [8], 1>;
```
Where `QuantizedType` is:
```
class QuantizedType<string n, list<int> params, bit signed>
: Type<And<[CPred<"$_self.isa<mlir::quant::QuantizedType>()">,
CPred<"$_self.cast<mlir::quant::QuantizedType>()" #
".getStorageTypeIntegralWidth() == " # !head(params)>]>,
"Q" # !if (signed, "I", "UI") # !head(params) # " type"> {
string name = n;
string asTraitArgsStr =
!interleave(params, ", ") # !if(signed, ", true", ", false");
}
```
Aside from `asTraitArgsStr`, signed/unsigned quantized types are indistinguishable at the parsed TD level, aside from the `description` passed to `Type`. This fix forwards the user provided description to the underlying `Constraint` from which `Type` inherits from.
---
Full diff: https://github.com/llvm/llvm-project/pull/110939.diff
1 Files Affected:
- (modified) mlir/include/mlir/IR/CommonTypeConstraints.td (+1-1)
``````````diff
diff --git a/mlir/include/mlir/IR/CommonTypeConstraints.td b/mlir/include/mlir/IR/CommonTypeConstraints.td
index 211385245555ad..f5ed8d8a4b0a6b 100644
--- a/mlir/include/mlir/IR/CommonTypeConstraints.td
+++ b/mlir/include/mlir/IR/CommonTypeConstraints.td
@@ -100,7 +100,7 @@ def HasValueSemanticsPred : CPred<"$_self.hasTrait<::mlir::ValueSemantics>()">;
class Type<Pred condition, string descr = "",
string cppType = "::mlir::Type"> :
TypeConstraint<condition, descr, cppType> {
- string description = "";
+ string description = descr;
string builderCall = "";
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/110939
More information about the Mlir-commits
mailing list