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,
pub backing: TensorBacking,
/* 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: DeviceId§backing: TensorBackingImplementations§
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 absent(dtype: DataType) -> Self
pub fn absent(dtype: DataType) -> Self
Construct an absent view: the positional placeholder an executor
passes for an omitted optional input (an ONNX empty-string input name).
It carries a null pointer and an empty shape so it can never be read as a
real tensor — kernels test TensorView::is_absent before touching an
optional slot. This preserves positional arity so a later present input
(e.g. Slice’s steps when axes is omitted) is not misread as the
omitted one.
Sourcepub fn is_absent(&self) -> bool
pub fn is_absent(&self) -> bool
Whether this view is the TensorView::absent placeholder for an
omitted optional input (null backing pointer). Kernels with optional
inputs check this to distinguish “input not supplied” from a real,
possibly-empty, tensor.
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.
pub fn with_backing(self, backing: TensorBacking) -> Self
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.
Trait Implementations§
Source§impl<'a> Clone for TensorView<'a>
impl<'a> Clone for TensorView<'a>
Source§fn clone(&self) -> TensorView<'a>
fn clone(&self) -> TensorView<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more