pub struct DLPackTensorRefMut<'a> { /* private fields */ }Expand description
A mutable reference to a DLPack tensor, with data borrowed from some owner, potentially in another language.
Implementations§
Source§impl<'a> DLPackTensorRefMut<'a>
impl<'a> DLPackTensorRefMut<'a>
Sourcepub unsafe fn from_raw(tensor: DLTensor) -> DLPackTensorRefMut<'a>
pub unsafe fn from_raw(tensor: DLTensor) -> DLPackTensorRefMut<'a>
Create a DLPackTensorRefMut from a raw DLTensor
§Safety
The lifetime of the returned reference should be constrained to the
actual lifetime of the DLTensor. The DLTensor should also be
mutable, and there should not be any other references (mutable or not)
to the same DLTensor.
Sourcepub fn as_ref(&self) -> DLPackTensorRef<'_>
pub fn as_ref(&self) -> DLPackTensorRef<'_>
Convert this mutable reference to an immutable reference.
Sourcepub fn data_ptr<T>(&self) -> Result<*const T, CastError>where
T: DLPackPointerCast,
pub fn data_ptr<T>(&self) -> Result<*const T, CastError>where
T: DLPackPointerCast,
Get a pointer to data in this tensor. This pointer can be a device
pointer according to DLPackTensorRefMut::device.
Sourcepub fn data_ptr_mut<T>(&mut self) -> Result<*mut T, CastError>where
T: DLPackPointerCast,
pub fn data_ptr_mut<T>(&mut self) -> Result<*mut T, CastError>where
T: DLPackPointerCast,
Get a mutable pointer to data in this tensor. This pointer can be a
device pointer according to DLPackTensorRefMut::device.
Sourcepub fn dtype(&self) -> DLDataType
pub fn dtype(&self) -> DLDataType
Get the data type of this tensor
Sourcepub fn byte_offset(&self) -> usize
pub fn byte_offset(&self) -> usize
Get the byte offset of this tensor, i.e. how many bytes should be added
to DLPackTensorRefMut::data_ptr and
DLPackTensorRefMut::data_ptr_mut to get the first element of the
tensor.
Sourcepub fn as_dltensor(&self) -> &DLTensor
pub fn as_dltensor(&self) -> &DLTensor
Get a reference to the underlying DLTensor