summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2021-11-09 11:16:33 +0200
committermattip <matti.picus@gmail.com>2021-11-09 11:16:33 +0200
commitf6076ee90985e7839d7ec6ed83ea1f85c0ece44d (patch)
tree857a4f9092d1bf398cad661cdbe1e83917bae42f /numpy
parentc38b7f328b87d626be544c5ffb542f2b6a97adee (diff)
downloadnumpy-f6076ee90985e7839d7ec6ed83ea1f85c0ece44d.tar.gz
add release note, error out if offset is used
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/dlpack.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/dlpack.c b/numpy/core/src/multiarray/dlpack.c
index f061a6bf9..b0eaa7786 100644
--- a/numpy/core/src/multiarray/dlpack.c
+++ b/numpy/core/src/multiarray/dlpack.c
@@ -206,6 +206,12 @@ array_dlpack(PyArrayObject *self,
if (data == NULL) {
return NULL;
}
+ if ((char *)PyArray_DATA(self) - data != 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "Offsets not clearly supported by this "
+ "version of DLPack.");
+ return NULL;
+ }
DLManagedTensor *managed = PyMem_Malloc(sizeof(DLManagedTensor));
if (managed == NULL) {
@@ -238,7 +244,7 @@ array_dlpack(PyArrayObject *self,
if (PyArray_SIZE(self) != 1 && !PyArray_IS_C_CONTIGUOUS(self)) {
managed->dl_tensor.strides = managed_strides;
}
- managed->dl_tensor.byte_offset = (char *)PyArray_DATA(self) - data;
+ managed->dl_tensor.byte_offset = 0;
managed->manager_ctx = self;
managed->deleter = array_dlpack_deleter;