Skip to content

Commit

Permalink
More validation and rename cai to readonly cai
Browse files Browse the repository at this point in the history
  • Loading branch information
galipremsagar committed Dec 8, 2022
1 parent 082202f commit b55f039
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 3 additions & 1 deletion python/cudf/cudf/_lib/column.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ cdef class Column:
):
if isinstance(value, RefCountableBuffer):
value = SimpleNamespace(
__cuda_array_interface__=value._cai,
__cuda_array_interface__=(
value._cuda_array_interface_readonly
),
owner=value
)
if value.__cuda_array_interface__["typestr"] not in ("|i1", "|u1"):
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/buffer/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def __cuda_array_interface__(self) -> dict:
}

@property
def _cai(self) -> dict:
def _cuda_array_interface_readonly(self) -> dict:
"""
Internal Implementation for the CUDA Array Interface which is
read-only.
Expand Down
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/buffer/weakrefable_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def copy(self, deep: bool = True):
)

@property
def _cai(self) -> dict:
def _cuda_array_interface_readonly(self) -> dict:
"""
Internal Implementation for the CUDA Array Interface without
triggering a deepcopy.
Expand All @@ -304,7 +304,7 @@ def __cuda_array_interface__(self) -> dict:
# pointing to.
self._detach_refs(zero_copied=True)

result = self._cai
result = self._cuda_array_interface_readonly
result["data"] = (self.ptr, False)
return result

Expand Down
30 changes: 14 additions & 16 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,27 @@ def _data_array_view(self) -> "cuda.devicearray.DeviceNDArray":
Internal implementation for viewing the data as a device array object
without triggering a deep-copy.
"""
return cuda.as_cuda_array(
SimpleNamespace(
__cuda_array_interface__=self.data._cai
if self.data is not None
else None,
owner=self.data,
)
).view(self.dtype)
arr_obj = SimpleNamespace(
__cuda_array_interface__=self.data._cuda_array_interface_readonly
if self.data is not None
else None,
owner=self.data,
)
return cuda.as_cuda_array(arr_obj).view(self.dtype)

@property
def _mask_array_view(self) -> "cuda.devicearray.DeviceNDArray":
"""
Internal implementation for viewing the mask as a device array object
without triggering a deep-copy.
"""
return cuda.as_cuda_array(
SimpleNamespace(
__cuda_array_interface__=self.mask._cai
if self.mask is not None
else None,
owner=self.mask,
)
).view(mask_dtype)
arr_obj = SimpleNamespace(
__cuda_array_interface__=self.mask._cuda_array_interface_readonly
if self.mask is not None
else None,
owner=self.mask,
)
return cuda.as_cuda_array(arr_obj).view(mask_dtype)

@property
def mask_array_view(self) -> "cuda.devicearray.DeviceNDArray":
Expand Down

0 comments on commit b55f039

Please sign in to comment.