[Mlir-commits] [mlir] [mlir][spirv] Add support for SPV_ARM_tensors (PR #144667)
Igor Wodiany
llvmlistbot at llvm.org
Thu Jun 19 01:28:50 PDT 2025
================
@@ -1203,11 +1236,94 @@ void MatrixType::getCapabilities(
llvm::cast<SPIRVType>(getColumnType()).getCapabilities(capabilities, storage);
}
+//===----------------------------------------------------------------------===//
+// TensorArmType
+//===----------------------------------------------------------------------===//
+
+struct spirv::detail::TensorArmTypeStorage final : TypeStorage {
+ using KeyTy = std::tuple<ArrayRef<int64_t>, Type>;
+
+ static TensorArmTypeStorage *construct(TypeStorageAllocator &allocator,
+ const KeyTy &key) {
+ auto shape = std::get<0>(key);
+ auto elementType = std::get<1>(key);
+ shape = allocator.copyInto(shape);
+ return new (allocator.allocate<TensorArmTypeStorage>())
+ TensorArmTypeStorage(std::move(shape), std::move(elementType));
+ }
+
+ static llvm::hash_code hashKey(const KeyTy &key) {
+ return llvm::hash_combine(std::get<0>(key), std::get<1>(key));
+ }
+
+ bool operator==(const KeyTy &key) const {
+ return key == KeyTy(shape, elementType);
+ }
+
+ TensorArmTypeStorage(ArrayRef<int64_t> shape, Type elementType)
+ : shape(std::move(shape)), elementType(std::move(elementType)) {}
+
+ ArrayRef<int64_t> shape;
----------------
IgWod-IMG wrote:
Okay, I think I understand it now. I missed this line:
```c
shape = allocator.copyInto(shape);
```
It seems that the allocator handles the lifetime of the array, hence `ArrayRef` can be used. Sorry for the confusion.
https://github.com/llvm/llvm-project/pull/144667
More information about the Mlir-commits
mailing list