[Mlir-commits] [mlir] [mlir][python] enable memref.subview (PR #79393)

Jacques Pienaar llvmlistbot at llvm.org
Wed Jan 24 17:01:52 PST 2024


================
@@ -426,6 +428,18 @@ MlirAttribute mlirMemRefTypeGetMemorySpace(MlirType type) {
   return wrap(llvm::cast<MemRefType>(unwrap(type)).getMemorySpace());
 }
 
+void mlirMemRefTypeGetStridesAndOffset(MlirType type, int64_t *strides,
+                                       int64_t *offset) {
+  MemRefType memrefType = llvm::cast<MemRefType>(unwrap(type));
+  std::pair<SmallVector<int64_t>, int64_t> stridesOffsets =
+      getStridesAndOffset(memrefType);
+  assert(stridesOffsets.first.size() == memrefType.getRank() &&
+         "Strides and rank don't match for memref");
+  (void)std::copy(stridesOffsets.first.begin(), stridesOffsets.first.end(),
----------------
jpienaar wrote:

I don't think there is anyway to verify here that space provided is sufficient... not sure if we need to document it , probably C API is the raw sharp edges part. Was just thinking this could allow some rather nasty overwrites. But python or other language should be guarding.

https://github.com/llvm/llvm-project/pull/79393


More information about the Mlir-commits mailing list