pub struct TensorDescriptor { /* private fields */ }Expand description
Shape, element strides, type, offset, and device for one tensor.
Implementations§
Source§impl TensorDescriptor
impl TensorDescriptor
Sourcepub fn contiguous(dtype: DataType, shape: Vec<usize>, device: Device) -> Self
pub fn contiguous(dtype: DataType, shape: Vec<usize>, device: Device) -> Self
Creates a compact C-order tensor on a device.
Sourcepub fn try_strided(
dtype: DataType,
shape: Vec<usize>,
strides: Vec<isize>,
byte_offset: usize,
device: Device,
) -> Result<Self, TensorError>
pub fn try_strided( dtype: DataType, shape: Vec<usize>, strides: Vec<isize>, byte_offset: usize, device: Device, ) -> Result<Self, TensorError>
Creates an explicitly strided tensor. Strides are measured in elements.
Sourcepub fn strides(&self) -> Option<&[isize]>
pub fn strides(&self) -> Option<&[isize]>
Returns element strides, or None for compact C order.
Sourcepub const fn byte_offset(&self) -> usize
pub const fn byte_offset(&self) -> usize
Returns the byte offset from the allocation start to logical element zero.
Sourcepub fn element_count(&self) -> Result<usize, TensorError>
pub fn element_count(&self) -> Result<usize, TensorError>
Returns the number of logical elements, including one for a scalar.
Sourcepub fn is_c_contiguous(&self) -> bool
pub fn is_c_contiguous(&self) -> bool
Returns whether the tensor is compact in C order.
Sourcepub fn required_byte_range(&self) -> Result<Range<usize>, TensorError>
pub fn required_byte_range(&self) -> Result<Range<usize>, TensorError>
Computes the smallest allocation byte range reachable by the layout.
Trait Implementations§
Source§impl Clone for TensorDescriptor
impl Clone for TensorDescriptor
Source§fn clone(&self) -> TensorDescriptor
fn clone(&self) -> TensorDescriptor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TensorDescriptor
impl Debug for TensorDescriptor
Source§impl PartialEq for TensorDescriptor
impl PartialEq for TensorDescriptor
Source§fn eq(&self, other: &TensorDescriptor) -> bool
fn eq(&self, other: &TensorDescriptor) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for TensorDescriptor
impl StructuralPartialEq for TensorDescriptor
Auto Trait Implementations§
impl Freeze for TensorDescriptor
impl RefUnwindSafe for TensorDescriptor
impl Send for TensorDescriptor
impl Sync for TensorDescriptor
impl Unpin for TensorDescriptor
impl UnsafeUnpin for TensorDescriptor
impl UnwindSafe for TensorDescriptor
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