[Mlir-commits] [mlir] [mlir][spirv] Add support for SPV_ARM_tensors (PR #144667)
Davide Grohmann
llvmlistbot at llvm.org
Thu Jun 19 01:30:35 PDT 2025
================
@@ -477,6 +479,37 @@ class MatrixType : public Type::TypeBase<MatrixType, CompositeType,
std::optional<StorageClass> storage = std::nullopt);
};
+// SPIR-V TensorARM Type
+class TensorArmType
+ : public Type::TypeBase<TensorArmType, CompositeType,
+ detail::TensorArmTypeStorage, ShapedType::Trait> {
+public:
+ using Base::Base;
+
+ static constexpr StringLiteral name = "spirv.arm.tensor";
+
+ // TensorArm supports minimum rank of 1, hence an empty shape here means
+ // unranked.
+ static TensorArmType get(ArrayRef<int64_t> shape, Type elementType);
+ TensorArmType cloneWith(std::optional<ArrayRef<int64_t>> shape,
+ Type elementType) const;
+
+ static LogicalResult
+ verifyInvariants(function_ref<InFlightDiagnostic()> emitError,
+ ArrayRef<int64_t> shape, Type elementType);
+
+ Type getElementType() const;
+ ArrayRef<int64_t> getShape() const;
+ unsigned getNumElements() const;
----------------
davidegrohmann wrote:
It should probably fail if the tensor is unranked or has dynamic shapes. What is the best way to make `TensorArmType` implement the `ShapeType` trait?
Should I do something similar to `RankedTensorType`?
```
using ShapedType::Trait<RankedTensorType>::getElementTypeBitWidth;
using ShapedType::Trait<RankedTensorType>::getRank;
using ShapedType::Trait<RankedTensorType>::getNumElements;
using ShapedType::Trait<RankedTensorType>::isDynamicDim;
using ShapedType::Trait<RankedTensorType>::hasStaticShape;
using ShapedType::Trait<RankedTensorType>::getNumDynamicDims;
using ShapedType::Trait<RankedTensorType>::getDimSize;
using ShapedType::Trait<RankedTensorType>::getDynamicDimIndex;
```
https://github.com/llvm/llvm-project/pull/144667
More information about the Mlir-commits
mailing list