pub struct TensorView<'a> {
pub data: DevicePtr,
pub dtype: DataType,
pub shape: &'a [usize],
pub strides: &'a [i64],
pub byte_offset: usize,
pub device: DeviceId,
/* private fields */
}Expand description
Immutable, non-owning view of a tensor on any device.
Fields§
§data: DevicePtr§dtype: DataType§shape: &'a [usize]§strides: &'a [i64]Strides in elements (may be negative, matching DLPack).
byte_offset: usizeOffset in bytes of the element origin from data (DLPack semantics).
device: DeviceIdImplementations§
Source§impl<'a> TensorView<'a>
impl<'a> TensorView<'a>
Sourcepub fn new(
data: DevicePtr,
dtype: DataType,
shape: &'a [usize],
strides: &'a [i64],
device: DeviceId,
) -> Self
pub fn new( data: DevicePtr, dtype: DataType, shape: &'a [usize], strides: &'a [i64], device: DeviceId, ) -> Self
Construct a zero-offset view. data must remain valid for 'a.
Sourcepub fn with_byte_offset(self, byte_offset: usize) -> Self
pub fn with_byte_offset(self, byte_offset: usize) -> Self
Set the DLPack-style byte offset of the element origin.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Check the view’s invariants (rank, dtype, offset alignment). See
[validate_view]; call this on any view imported from DLPack before use.
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
Whether the view is contiguous row-major.
Auto Trait Implementations§
impl<'a> !Send for TensorView<'a>
impl<'a> !Sync for TensorView<'a>
impl<'a> Freeze for TensorView<'a>
impl<'a> RefUnwindSafe for TensorView<'a>
impl<'a> Unpin for TensorView<'a>
impl<'a> UnsafeUnpin for TensorView<'a>
impl<'a> UnwindSafe for TensorView<'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