Skip to content

Commit 5bd7d1c

Browse files
committed
adapted the inferredAlignment parameter
Now the inferedAlignment is in bytes and not elements anymore. This is also the case in getFromBuffer().
1 parent 7520742 commit 5bd7d1c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mlir/lib/Bindings/Python/IRAttributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ class PyDenseResourceElementsAttribute
15271527
if (alignment)
15281528
inferredAlignment = *alignment;
15291529
else
1530-
inferredAlignment = view->stride_ptr()[view->ndim() - 1];
1530+
inferredAlignment = static_cast<size_t>(view->stride(view->ndim() - 1) * view->itemsize());
15311531

15321532
// The userData is a nb::ndarray<nb::any_contig>* that the deleter owns.
15331533
auto deleter = [](void *userData, const void *data, size_t size,

mlir/test/python/ir/array_attributes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def test_attribute_int32(context, mview_int32):
646646
module = Module.parse("module {}")
647647
module.operation.attributes["test.resource"] = resource
648648
# CHECK: test.resource = dense_resource<from_py> : tensor<2x3xi32>
649-
# CHECK: from_py: "0x01000000010000000200000003000000040000000500000006000000"
649+
# CHECK: from_py: "0x04000000010000000200000003000000040000000500000006000000"
650650
print(module)
651651

652652
# Verifies type casting.
@@ -693,7 +693,7 @@ def test_attribute_float32(context, mview_float32):
693693
module = Module.parse("module {}")
694694
module.operation.attributes["test.resource"] = resource
695695
# CHECK: test.resource = dense_resource<from_py> : tensor<2x3xf32>
696-
# CHECK: from_py: "0x010000000000803F0000004000004040000080400000A0400000C040"
696+
# CHECK: from_py: "0x040000000000803F0000004000004040000080400000A0400000C040"
697697
print(module)
698698

699699
# Verifies type casting.

0 commit comments

Comments
 (0)