[Mlir-commits] [mlir] [mlir] Fix correct memset range in `OwningMemRef` zero-init (PR #158200)

Mehdi Amini llvmlistbot at llvm.org
Sat Sep 13 02:39:53 PDT 2025


================
@@ -205,50 +205,66 @@ TEST(NativeMemRefJit, SKIP_WITHOUT_JIT(BasicMemref)) {
   };
   int64_t shape[] = {k, m};
   int64_t shapeAlloc[] = {k + 1, m + 1};
-  // Use a large alignment to stress the case where the memref data/basePtr are
-  // disjoint.
-  int alignment = 8192;
-  OwningMemRef<float, 2> a(shape, shapeAlloc, init, alignment);
-  ASSERT_EQ(
-      (void *)(((uintptr_t)a->basePtr + alignment - 1) & ~(alignment - 1)),
-      a->data);
-  ASSERT_EQ(a->sizes[0], k);
-  ASSERT_EQ(a->sizes[1], m);
-  ASSERT_EQ(a->strides[0], m + 1);
-  ASSERT_EQ(a->strides[1], 1);
-  for (int i = 0; i < k; ++i) {
-    for (int j = 0; j < m; ++j) {
-      EXPECT_EQ((a[{i, j}]), i * m + j);
-      EXPECT_EQ(&(a[{i, j}]), &((*a)[i][j]));
+  auto runTest = [&](std::string_view traceName,
----------------
joker-eph wrote:

Can you add a comment? This test becomes quite non trivial now.

I wonder if it wouldn't just have been better to add a separate test that just check the 0 init and nothing else.


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


More information about the Mlir-commits mailing list