Skip to content

Commit ea21116

Browse files
committed
propagate alignment in MKLMemory
1 parent 5909cac commit ea21116

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

mkl/_mkl_memory.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ cdef class MKLMemory:
116116
memcpy(self._memory_ptr, other_mem._memory_ptr, self.nbytes)
117117

118118
def __cinit__(self, *args, **kwargs):
119-
cdef Py_ssize_t alignment = kwargs.get("alignment", 64)
119+
cdef Py_ssize_t alignment
120120

121121
n_args = len(args)
122122
if not (0 < n_args < 3):
@@ -127,8 +127,10 @@ cdef class MKLMemory:
127127
if n_args == 1:
128128
arg = args[0]
129129
if isinstance(arg, numbers.Integral):
130+
alignment = kwargs.get("alignment", 64)
130131
self._cinit_malloc(arg, alignment)
131132
elif isinstance(arg, MKLMemory):
133+
alignment = kwargs.get("alignment", arg.alignment)
132134
self._cinit_mklmemory(arg, alignment)
133135
else:
134136
raise TypeError(
@@ -138,6 +140,7 @@ cdef class MKLMemory:
138140

139141
elif n_args == 2:
140142
arg0, arg1 = args[0], args[1]
143+
alignment = kwargs.get("alignment", 64)
141144
if not isinstance(arg0, numbers.Integral):
142145
raise TypeError(
143146
"MKLMemory constructor expects first argument "
@@ -148,7 +151,6 @@ cdef class MKLMemory:
148151
"MKLMemory constructor expects second argument "
149152
f"to be an integer, but got {type(arg1)}"
150153
)
151-
152154
self._cinit_calloc(arg0, arg1, alignment)
153155

154156
def __dealloc__(self):

0 commit comments

Comments
 (0)