[Mlir-commits] [mlir] [MLIR][Python] implement __iter__ for OpResultList (PR #163444)
Maksim Levental
llvmlistbot at llvm.org
Tue Oct 14 13:24:23 PDT 2025
https://github.com/makslevental created https://github.com/llvm/llvm-project/pull/163444
None
>From c3325062327cf091faac047eb60196b96cdc7c33 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Tue, 14 Oct 2025 13:24:02 -0700
Subject: [PATCH] [MLIR][Python] implement __iter__ for OpResultList
---
mlir/lib/Bindings/Python/NanobindUtils.h | 2 +-
mlir/test/python/dialects/memref.py | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Bindings/Python/NanobindUtils.h b/mlir/lib/Bindings/Python/NanobindUtils.h
index 64ea4329f65f1..6e42334f369be 100644
--- a/mlir/lib/Bindings/Python/NanobindUtils.h
+++ b/mlir/lib/Bindings/Python/NanobindUtils.h
@@ -357,7 +357,7 @@ class Sliceable {
// that should throw in a non-terminal way, so we forgo further
// exception marshalling.
// See: https://github.com/pybind/nanobind/issues/2842
- auto heap_type = reinterpret_cast<PyHeapTypeObject *>(clazz.ptr());
+ auto *heap_type = reinterpret_cast<PyHeapTypeObject *>(clazz.ptr());
assert(heap_type->ht_type.tp_flags & Py_TPFLAGS_HEAPTYPE &&
"must be heap type");
heap_type->as_sequence.sq_length = +[](PyObject *rawSelf) -> Py_ssize_t {
diff --git a/mlir/test/python/dialects/memref.py b/mlir/test/python/dialects/memref.py
index b91fdc367cf30..ee30be731155d 100644
--- a/mlir/test/python/dialects/memref.py
+++ b/mlir/test/python/dialects/memref.py
@@ -249,3 +249,20 @@ def check_strides_offset(memref, np_view):
check_strides_offset(memref.subview(mem3, (0, 0), (4, 4), (1, 1)), golden_mem[0:4, 0:4])
check_strides_offset(memref.subview(mem3, (4, 4), (4, 4), (1, 1)), golden_mem[4:8, 4:8])
# fmt: on
+
+# CHECK-LABEL: TEST: testExtractStridedMetadataOp
+ at run
+def testExtractStridedMetadataOp():
+ S = ShapedType.get_dynamic_size()
+ shape = [S] * 4
+ with Context() as ctx, Location.unknown(ctx):
+ dynamc_memref_t = T.memref(
+ *shape,
+ element_type=T.f32(),
+ layout=StridedLayoutAttr.get(offset=S, strides=shape, context=ctx)
+ )
+ module = Module.create()
+ with InsertionPoint(module.body):
+ A = memref.alloc(dynamc_memref_t, [], [])
+ A_base, A_offset, A_sizes, A_strides = memref.extract_strided_metadata(A)
+
More information about the Mlir-commits
mailing list