[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:20 PDT 2024
https://github.com/penagos created https://github.com/llvm/llvm-project/pull/110939
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.
>From 65ab9af3c08351f7a01407a93132dc3d9993f9a2 Mon Sep 17 00:00:00 2001
From: Luis Penagos <lpenagos at google.com>
Date: Wed, 2 Oct 2024 16:04:53 -0700
Subject: [PATCH] [mlir][tablegen] Correctly set Type constraint description
---
mlir/include/mlir/IR/CommonTypeConstraints.td | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 = "";
}
More information about the Mlir-commits
mailing list