diff --git a/arraycontext/container/traversal.py b/arraycontext/container/traversal.py index cf9640fe751a81d0561df379dbbb7f144f8e9513..db3633d17d994fb861a03b5f9c54574aeb966656 100644 --- a/arraycontext/container/traversal.py +++ b/arraycontext/container/traversal.py @@ -526,7 +526,7 @@ def flatten(ary: ArrayOrContainerT, actx: ArrayContext) -> Any: f"got {subary.dtype}, expected {common_dtype}") try: - flat_subary = actx.np.ravel(subary, order="A") + flat_subary = actx.np.ravel(subary, order="C") except ValueError as exc: # NOTE: we can't do much if the array context fails to ravel, # since it is the one responsible for the actual memory layout @@ -580,7 +580,8 @@ def unflatten( flat_subary = ary[offset - template_subary.size:offset] try: - subary = actx.np.reshape(flat_subary, template_subary.shape) + subary = actx.np.reshape(flat_subary, + template_subary.shape, order="C") except ValueError as exc: # NOTE: we can't do much if the array context fails to reshape, # since it is the one responsible for the actual memory layout diff --git a/arraycontext/impl/pyopencl/fake_numpy.py b/arraycontext/impl/pyopencl/fake_numpy.py index c5b57ef58b49ed2bdb95dd3547839a5222ee6eeb..c60f33d77dbff3763352366a71f3c25b2c7c2991 100644 --- a/arraycontext/impl/pyopencl/fake_numpy.py +++ b/arraycontext/impl/pyopencl/fake_numpy.py @@ -172,8 +172,10 @@ class PyOpenCLFakeNumpyNamespace(BaseFakeNumpyNamespace): queue=self._array_context.queue), *arrays) - def reshape(self, a, newshape): - return cl_array.reshape(a, newshape) + def reshape(self, a, newshape, order="C"): + return rec_map_array_container( + lambda ary: ary.reshape(newshape, order=order), + a) def concatenate(self, arrays, axis=0): return cl_array.concatenate( diff --git a/arraycontext/impl/pytato/fake_numpy.py b/arraycontext/impl/pytato/fake_numpy.py index 01efaec844a5ef0baf6620a2b08bbe6c705f172d..62b5e20086de0ec721f9a0e6724fc99d4e0ca937 100644 --- a/arraycontext/impl/pytato/fake_numpy.py +++ b/arraycontext/impl/pytato/fake_numpy.py @@ -64,8 +64,9 @@ class PytatoFakeNumpyNamespace(BaseFakeNumpyNamespace): return super().__getattr__(name) - def reshape(self, a, newshape): - return rec_multimap_array_container(pt.reshape, a, newshape) + def reshape(self, a, newshape, order="C"): + return rec_multimap_array_container( + partial(pt.reshape, order=order), a, newshape) def transpose(self, a, axes=None): return rec_multimap_array_container(pt.transpose, a, axes)