From 89a6c556d84c54b246442c10fadf5511dd17e063 Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Mon, 28 Oct 2019 17:40:46 +0100
Subject: [PATCH] Call pybind11::array by value

---
 src/pystencils_autodiff/backends/astnodes.py                  | 1 +
 .../framework_integration/texture_astnodes.py                 | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/pystencils_autodiff/backends/astnodes.py b/src/pystencils_autodiff/backends/astnodes.py
index 9c968cc..34a6a3f 100644
--- a/src/pystencils_autodiff/backends/astnodes.py
+++ b/src/pystencils_autodiff/backends/astnodes.py
@@ -59,6 +59,7 @@ class PybindArrayDestructuring(DestructuringBindingsForFieldClass):
     }
 
     CLASS_NAME_TEMPLATE = "pybind11::array_t<{dtype}>"
+    ARGS_AS_REFERENCE = False
 
     headers = ["<pybind11/numpy.h>"]
 
diff --git a/src/pystencils_autodiff/framework_integration/texture_astnodes.py b/src/pystencils_autodiff/framework_integration/texture_astnodes.py
index f6b2f53..e228b21 100644
--- a/src/pystencils_autodiff/framework_integration/texture_astnodes.py
+++ b/src/pystencils_autodiff/framework_integration/texture_astnodes.py
@@ -187,7 +187,7 @@ cudaMalloc{ndim}Array(&{array}, &channel_desc_{texture_name}, """ + (
             copy_params = f'cpy_{texture_name}_params'
             return f"""cudaMemcpy3DParms {copy_params}{{}};
 {copy_params}.srcPtr = {{{self._device_ptr},
-                        {self._texture.field.strides[-1] * self._texture.field.shape[-1] * self._dtype.numpy_dtype.itemsize},
+                        {self._texture.field.strides[-1] * self._texture.field.shape[-2]},
                         {self._texture.field.shape[-1]},
                         {self._texture.field.shape[-2]}}};
 {copy_params}.dstArray = {array};
@@ -201,7 +201,7 @@ cudaMemcpy3D(&{copy_params});"""  # noqa
                     0u,
                     0u,
                     {self._device_ptr},
-                    {self._texture.field.strides[-1] * self._texture.field.shape[-1] * self._dtype.numpy_dtype.itemsize},
+                    {self._texture.field.strides[-1]},
                     {self._texture.field.shape[-1]},
                     {self._texture.field.shape[-2]},
                     cudaMemcpyDeviceToDevice);
-- 
GitLab