pub struct DLPackTensorRef<'a> {
pub raw: DLTensor,
/* private fields */
}Expand description
A reference to a DLPack tensor, with data borrowed from some owner, potentially in another language.
Fields§
§raw: DLTensorImplementations§
Source§impl<'a> DLPackTensorRef<'a>
impl<'a> DLPackTensorRef<'a>
Sourcepub unsafe fn from_raw(tensor: DLTensor) -> DLPackTensorRef<'a>
pub unsafe fn from_raw(tensor: DLTensor) -> DLPackTensorRef<'a>
Create a DLPackTensorRef from a raw DLTensor
§Safety
The lifetime of the returned reference should be constrained to the
actual lifetime of the DLTensor.
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 DLPackTensorRef::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 DLPackTensorRef::data_ptr 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
Trait Implementations§
Source§impl Debug for DLPackTensorRef<'_>
impl Debug for DLPackTensorRef<'_>
Source§impl<'a, T, D> TryFrom<&'a ArrayBase<OwnedArcRepr<T>, D>> for DLPackTensorRef<'a>where
D: Dimension,
T: GetDLPackDataType,
impl<'a, T, D> TryFrom<&'a ArrayBase<OwnedArcRepr<T>, D>> for DLPackTensorRef<'a>where
D: Dimension,
T: GetDLPackDataType,
Source§impl<'a, T, D> TryFrom<&'a ArrayBase<OwnedRepr<T>, D>> for DLPackTensorRef<'a>where
D: Dimension,
T: GetDLPackDataType,
impl<'a, T, D> TryFrom<&'a ArrayBase<OwnedRepr<T>, D>> for DLPackTensorRef<'a>where
D: Dimension,
T: GetDLPackDataType,
Source§impl<'a, T, D> TryFrom<&'a ArrayBase<ViewRepr<&'a T>, D>> for DLPackTensorRef<'a>where
D: Dimension,
T: GetDLPackDataType,
impl<'a, T, D> TryFrom<&'a ArrayBase<ViewRepr<&'a T>, D>> for DLPackTensorRef<'a>where
D: Dimension,
T: GetDLPackDataType,
Source§impl<'py> TryFrom<Bound<'py, PyCapsule>> for DLPackTensorRef<'py>
impl<'py> TryFrom<Bound<'py, PyCapsule>> for DLPackTensorRef<'py>
Source§impl<'a, T> TryFrom<DLPackTensorRef<'a>> for &'a [T]where
T: DLPackPointerCast,
impl<'a, T> TryFrom<DLPackTensorRef<'a>> for &'a [T]where
T: DLPackPointerCast,
Source§type Error = DLPackVecError
type Error = DLPackVecError
The type returned in the event of a conversion error.
Source§impl<'a, T, D> TryFrom<DLPackTensorRef<'a>> for ArrayView<'a, T, D>where
T: DLPackPointerCast + 'static,
D: DimFromVec + 'static,
impl<'a, T, D> TryFrom<DLPackTensorRef<'a>> for ArrayView<'a, T, D>where
T: DLPackPointerCast + 'static,
D: DimFromVec + 'static,
Source§type Error = DLPackNDarrayError
type Error = DLPackNDarrayError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl<'a> Freeze for DLPackTensorRef<'a>
impl<'a> RefUnwindSafe for DLPackTensorRef<'a>
impl<'a> !Send for DLPackTensorRef<'a>
impl<'a> !Sync for DLPackTensorRef<'a>
impl<'a> Unpin for DLPackTensorRef<'a>
impl<'a> UnwindSafe for DLPackTensorRef<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more