[Mlir-commits] [mlir] [mlir][tosa] Combine unranked/ranked tensor types into single type (PR #209737)
Sayan Saha
llvmlistbot at llvm.org
Tue Jul 21 06:05:49 PDT 2026
================
@@ -174,33 +174,28 @@ def AtLeastRankOne : And<[
def IsValidBlockScaledTensorType
: CPred<"::mlir::succeeded(::mlir::tosa::verifyBlockScaledTensorType($_self, false))">;
+// We include unranked tensors as a supported type for all possible tosa
+// Tensors as unranked does not guarantee invalid. If unranked tensors exist
+// they should be shape propagated using Tosa's shape inference pass and verified
+// to not include any remaining unranked tensors.
class TosaTensorOf<list<Type> allowedTypes,
+ list<Pred> extraRankedTensorPreds = [],
string summary = "tosa-conformant tensor">
: TensorOf<allowedTypes,
- [Or<[HasNo0Dimensions, IsUnrankedTensorTypePred]>,
+ [Or<[
+ IsUnrankedTensorTypePred,
+ And<!listconcat([IsRankedTensorTypePred, HasNo0Dimensions], extraRankedTensorPreds)>
+ ]>,
IsValidBlockScaledTensorType],
summary>;
-class TosaRankedTensorOf<list<Type> allowedTypes, list<Pred> preds = [],
- string summary = "tosa-conformant ranked tensor">
- : RankedTensorOf<
- allowedTypes,
- !listconcat([HasNo0Dimensions, IsValidBlockScaledTensorType], preds),
- summary>;
-
-class TosaUnrankedTensorOf<list<Type> allowedTypes, list<Pred> preds = [],
- string summary = "tosa-conformant unranked tensor">
- : UnrankedTensorOf<allowedTypes,
- !listconcat([IsValidBlockScaledTensorType], preds),
- summary>;
-
class TosaTensorRankOf<list<Type> allowedTypes, list<int> ranks>
- : TosaRankedTensorOf<allowedTypes,
+ : TosaTensorOf<allowedTypes,
----------------
sahas3 wrote:
IIUC, `TosaTensorRankOf` will now allow unranked tensors too since the base `TosaTensorOf` allows it -- is this change expected?
https://github.com/llvm/llvm-project/pull/209737
More information about the Mlir-commits
mailing list