[Mlir-commits] [mlir] [mlir][tosa] Combine unranked/ranked tensor types into single type (PR #209737)
Luke Hutton
llvmlistbot at llvm.org
Wed Jul 22 07:36:48 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,
----------------
lhutton1 wrote:
Yes, that's correct, most types already accept both unranked and ranked tensors, but there are some exceptions as discussed below
https://github.com/llvm/llvm-project/pull/209737
More information about the Mlir-commits
mailing list