pub struct TypedTensorView<'a, T, R = DynRank, D = Dynamic>where
R: TensorRank,
D: Representation,{ /* private fields */ }Expand description
Read-only borrowed view of typed tensor storage with arbitrary strides.
TypedTensorView is the typed representation for layout-only tensor
transformations. It borrows an existing host or backend allocation and
carries a logical shape, strides, and an offset. Slicing, reshaping when
stride-compatible, and transpose_view
update only metadata and do not copy storage.
Materialize through TensorStructural::to_contiguous_read
on the active backend session when a compact owned TypedTensor is
required. Use TypedTensorView::as_slice only when the current view is
contiguous in the requested layout.
§Examples
use tenferro_tensor::{Rank, TypedTensorView};
let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked([2, 2], [1, 2], 0, &data)?;
assert_eq!(view.get(&[1, 1]), Some(&4));Borrowed typed view of one tensor representation.
The buffer stays concrete on purpose: a generic-associated buffer would make
the projection invariant in 'a, and the borrowed-read surface relies on
TensorRead<'long> shortening to TensorRead<'short>. D therefore marks
which representation produced the view - Host is only ever built from host
slices, with no retained region.
Implementations§
Source§impl<'a, T, const N: usize, D> TypedTensorView<'a, T, Rank<N>, D>where
T: 'static,
D: Representation,
impl<'a, T, const N: usize, D> TypedTensorView<'a, T, Rank<N>, D>where
T: 'static,
D: Representation,
Sourcepub fn host_col_major_view(&self) -> Result<ColMajorView<'a, T, N>, Error>
pub fn host_col_major_view(&self) -> Result<ColMajorView<'a, T, N>, Error>
Validate and borrow this tensor view as a compact column-major host view.
Nonzero compact offsets are represented by the returned logical slice without copying.
§Examples
use tenferro_tensor::{Rank, TypedTensorView};
let data = [0_i32, 1, 2, 3, 4];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked([2, 2], [1, 2], 1, &data)?;
assert_eq!(view.host_col_major_view()?.as_slice(), &[1, 2, 3, 4]);§Errors
Returns crate::Error::RuntimeState when storage is backend-owned,
or crate::Error::Validation when compact layout, shape arithmetic,
or the logical host range is invalid.
Source§impl<'a, T> TypedTensorView<'a, T>where
T: 'static,
impl<'a, T> TypedTensorView<'a, T>where
T: 'static,
Sourcepub fn from_col_major(
shape: &[usize],
data: &'a [T],
) -> Result<TypedTensorView<'a, T>, Error>
pub fn from_col_major( shape: &[usize], data: &'a [T], ) -> Result<TypedTensorView<'a, T>, Error>
Create a borrowed dynamic-rank view over compact column-major host data.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::from_col_major(&[2, 2], &data)?;
assert_eq!(view.strides(), &[1, 2]);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when compact
strides or reachable bounds overflow, or
tenferro_tensor_core::ValidationError::ViewOutOfBounds when the
requested shape reaches beyond data.
Sourcepub fn from_slice(
shape: impl AsRef<[usize]>,
strides: impl AsRef<[isize]>,
offset: isize,
data: &'a [T],
) -> Result<TypedTensorView<'a, T>, Error>
pub fn from_slice( shape: impl AsRef<[usize]>, strides: impl AsRef<[isize]>, offset: isize, data: &'a [T], ) -> Result<TypedTensorView<'a, T>, Error>
Create a borrowed host view from explicit layout metadata.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice(vec![3], vec![-1], 2, &data)?;
assert_eq!(view.get(&[2]), Some(&1));§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::RankMismatch when shape and
strides have different ranks,
tenferro_tensor_core::ValidationError::ViewOutOfBounds when the
reachable layout exceeds data, or
tenferro_tensor_core::ValidationError::IntegerOverflow when layout
arithmetic overflows.
Source§impl<'a, T, R, D> TypedTensorView<'a, T, R, D>where
T: 'static,
R: TensorRank,
D: Representation,
impl<'a, T, R, D> TypedTensorView<'a, T, R, D>where
T: 'static,
R: TensorRank,
D: Representation,
Sourcepub fn from_slice_ranked(
shape: impl Into<<R as TensorRank>::Shape>,
strides: impl Into<<R as TensorRank>::Strides>,
offset: isize,
data: &'a [T],
) -> Result<TypedTensorView<'a, T, R, D>, Error>
pub fn from_slice_ranked( shape: impl Into<<R as TensorRank>::Shape>, strides: impl Into<<R as TensorRank>::Strides>, offset: isize, data: &'a [T], ) -> Result<TypedTensorView<'a, T, R, D>, Error>
Create a rank-generic borrowed host view from explicit layout metadata.
§Examples
use tenferro_tensor::{Rank, TypedTensorView};
let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked([2, 2], [1, 2], 0, &data)?;
assert_eq!(view.get(&[1, 1]), Some(&4));§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::RankMismatch when the typed
rank does not match shape or strides,
tenferro_tensor_core::ValidationError::ViewOutOfBounds when the
reachable layout exceeds data, or
tenferro_tensor_core::ValidationError::IntegerOverflow when layout
arithmetic overflows.
Source§impl<'a, T, R> TypedTensorView<'a, T, R>where
T: 'static,
R: TensorRank,
impl<'a, T, R> TypedTensorView<'a, T, R>where
T: 'static,
R: TensorRank,
Sourcepub fn is_host_memory(&self) -> bool
pub fn is_host_memory(&self) -> bool
Whether this view borrows host-addressed memory.
The same answer Self::try_host acts on and
TypedTensor::is_host_memory gives for the owner: the borrowed payload
decides, never Placement::memory_kind.
§Examples
use tenferro_tensor::TypedTensor;
let tensor = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![1.0, 2.0])?;
assert!(tensor.as_view().is_host_memory());Sourcepub fn try_host(
self,
op: &'static str,
) -> Result<TypedTensorView<'a, T, R, Host>, Error>
pub fn try_host( self, op: &'static str, ) -> Result<TypedTensorView<'a, T, R, Host>, Error>
Checked narrowing of a borrowed view to the host representation.
This is the one place a borrowed dynamic view becomes Host-marked: it
succeeds exactly when the view borrows host elements (a plain host
owner, a host slice, or a CPU-resident allocation group) and keeps the
layout and the placement label. It runs Self::is_host_memory, so a
CPU entry point that narrows here and a CPU entry point that validates
without narrowing reach the same verdict. A consumer that receives the
result reads it through TypedTensorView::as_host_slice without a
further check.
§Examples
use tenferro_tensor::TypedTensor;
let tensor = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![1.0, 2.0])?;
let host = tensor.as_view().try_host("example")?;
assert_eq!(host.as_host_slice(), &[1.0, 2.0]);§Errors
Returns crate::Error::RuntimeState attributed to op when the view
borrows backend (device) storage; download the tensor to host first.
Source§impl<'a, T, R> TypedTensorView<'a, T, R, Host>where
T: 'static,
R: TensorRank,
impl<'a, T, R> TypedTensorView<'a, T, R, Host>where
T: 'static,
R: TensorRank,
Sourcepub fn into_dynamic(self) -> TypedTensorView<'a, T, R>
pub fn into_dynamic(self) -> TypedTensorView<'a, T, R>
Widen a host-marked view to the runtime union without copying.
§Examples
use tenferro_tensor::{DynRank, Host, TypedTensorView};
let data = [1_i32, 2];
let host: TypedTensorView<'_, i32, DynRank, Host> =
TypedTensorView::from_host_slice(vec![2].as_slice(), vec![1].as_slice(), 0, &data)?;
let dynamic = host.into_dynamic();
assert_eq!(dynamic.host_storage()?, &[1, 2]);Source§impl<'a, T, R> TypedTensorView<'a, T, R, Host>where
T: 'static,
R: TensorRank,
impl<'a, T, R> TypedTensorView<'a, T, R, Host>where
T: 'static,
R: TensorRank,
Sourcepub fn from_host_slice(
shape: impl Into<<R as TensorRank>::Shape>,
strides: impl Into<<R as TensorRank>::Strides>,
offset: isize,
data: &'a [T],
) -> Result<TypedTensorView<'a, T, R, Host>, Error>
pub fn from_host_slice( shape: impl Into<<R as TensorRank>::Shape>, strides: impl Into<<R as TensorRank>::Strides>, offset: isize, data: &'a [T], ) -> Result<TypedTensorView<'a, T, R, Host>, Error>
Create a representation-marked view over an explicit host layout.
A Host-marked view is only ever built from a host slice, so it carries
no retained region and its host slice needs no runtime check.
§Examples
use tenferro_tensor::{DynRank, Host, TypedTensorView};
let data = [1_i32, 2, 3, 4];
let view: TypedTensorView<'_, i32, DynRank, Host> =
TypedTensorView::from_host_slice(vec![2, 2].as_slice(), vec![1, 2].as_slice(), 0, &data)?;
assert_eq!(view.as_host_slice(), &[1, 2, 3, 4]);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::RankMismatch when strides
has a different rank, or
tenferro_tensor_core::ValidationError::ViewOutOfBounds /
tenferro_tensor_core::ValidationError::IntegerOverflow when the
reachable layout leaves data or overflows.
Sourcepub fn as_host_slice(&self) -> &'a [T]
pub fn as_host_slice(&self) -> &'a [T]
Borrow the host elements without a runtime representation check.
§Examples
use tenferro_tensor::{DynRank, Host, TypedTensorView};
let data = [1_i32, 2];
let view: TypedTensorView<'_, i32, DynRank, Host> =
TypedTensorView::from_host_slice(vec![2].as_slice(), vec![1].as_slice(), 0, &data)?;
assert_eq!(view.as_host_slice(), &[1, 2]);§Panics
Panics only if a Host-marked view was built from non-host storage,
which no constructor in this crate does.
Source§impl<'a, T, R, D> TypedTensorView<'a, T, R, D>where
T: 'static,
R: TensorRank,
D: Representation,
impl<'a, T, R, D> TypedTensorView<'a, T, R, D>where
T: 'static,
R: TensorRank,
D: Representation,
Sourcepub fn into_tensor_read(self) -> Result<TensorRead<'a>, Error>where
T: TensorScalar,
pub fn into_tensor_read(self) -> Result<TensorRead<'a>, Error>where
T: TensorScalar,
Erase a borrowed view’s rank and dtype for session dispatch without allocating tensor storage or promoting it into an allocation group. Common ranks use the existing inline shape and stride metadata.
§Examples
use tenferro_tensor::{Rank, TypedTensorView};
let data = [1.0_f64, 2.0];
let view = TypedTensorView::<_, Rank<1>>::from_slice_ranked([2], [1], 0, &data)?;
let read = view.into_tensor_read()?;
assert_eq!(read.as_slice::<f64>()?, &[1.0, 2.0]);§Errors
Returns crate::Error::Validation with
ValidationError::IntegerOverflow for unrepresentable metadata or
ValidationError::ViewOutOfBounds if the layout leaves its allocation.
Sourcepub fn shape(&self) -> &[usize]
pub fn shape(&self) -> &[usize]
Return the logical shape.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [0_i32; 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
assert_eq!(view.shape(), &[2]);Sourcepub fn rank(&self) -> usize
pub fn rank(&self) -> usize
Return the logical rank carried by this view.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [0_i32; 6];
let view = TypedTensorView::from_slice(vec![2, 3], vec![1, 2], 0, &data)?;
assert_eq!(view.rank(), 2);Sourcepub fn strides(&self) -> &[isize]
pub fn strides(&self) -> &[isize]
Return strides in element units.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [0_i32; 2];
let view = TypedTensorView::from_slice(vec![2], vec![-1], 1, &data)?;
assert_eq!(view.strides(), &[-1]);Sourcepub fn offset(&self) -> isize
pub fn offset(&self) -> isize
Return the physical element offset.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![1], vec![1], 1, &data)?;
assert_eq!(view.offset(), 1);Sourcepub fn host_storage(&self) -> Result<&'a [T], Error>
pub fn host_storage(&self) -> Result<&'a [T], Error>
Return the borrowed host storage backing this view.
This exposes the entire backing host allocation, not just the logical
slice covered by this view. Use TypedTensorView::as_slice when the
caller needs the contiguous logical region instead.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
assert_eq!(view.host_storage()?, &[1, 2]);§Errors
Returns crate::Error::RuntimeState when this view wraps a backend
buffer; backend storage must be downloaded before host inspection.
Sourcepub fn n_elements(&self) -> usize
pub fn n_elements(&self) -> usize
Return the number of logical elements in this view.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [0_i32; 6];
let view = TypedTensorView::from_slice(vec![2, 3], vec![1, 2], 0, &data)?;
assert_eq!(view.n_elements(), 6);Sourcepub fn layout(&self) -> &TensorLayout<R>
pub fn layout(&self) -> &TensorLayout<R>
Return layout metadata for this view.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
assert!(view.layout().is_compact_col_major().unwrap());Sourcepub fn placement(&self) -> &Placement
pub fn placement(&self) -> &Placement
Return placement metadata for this view.
§Examples
use tenferro_tensor::{MemoryKind, TypedTensorView};
let data = [1_i32];
let view = TypedTensorView::from_slice(vec![1], vec![1], 0, &data)?;
assert_eq!(view.placement().memory_kind, MemoryKind::UnpinnedHost);Sourcepub fn linear_offset(&self, indices: &[usize]) -> Option<usize>
pub fn linear_offset(&self, indices: &[usize]) -> Option<usize>
Compute the physical element offset for a logical index.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice(vec![3], vec![-1], 2, &data)?;
assert_eq!(view.linear_offset(&[2]), Some(0));Sourcepub fn layout_linear_offset(&self, indices: &[usize]) -> Result<usize, Error>
pub fn layout_linear_offset(&self, indices: &[usize]) -> Result<usize, Error>
Compute the physical element offset for a logical index, returning a typed error.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice([3], [-1], 2, &data)?;
assert_eq!(view.layout_linear_offset(&[2])?, 0);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::RankMismatch when indices
has the wrong rank, tenferro_tensor_core::ValidationError::InvalidArgument
when an index is outside its axis extent, or
tenferro_tensor_core::ValidationError::IntegerOverflow when offset
arithmetic overflows.
Sourcepub fn is_col_major_contiguous(&self) -> Result<bool, Error>
pub fn is_col_major_contiguous(&self) -> Result<bool, Error>
Return whether this view is compact column-major.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2];
let view = TypedTensorView::from_slice([2], [1], 0, &data)?;
assert!(view.is_col_major_contiguous()?);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow if compactness
arithmetic overflows.
Sourcepub fn layout_summary(&self) -> String
pub fn layout_summary(&self) -> String
Return a compact string summary of this view’s layout metadata.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2];
let view = TypedTensorView::from_slice([2], [1], 0, &data)?;
assert!(view.layout_summary().contains("shape=[2]"));Sourcepub fn assert_col_major_contiguous(&self) -> Result<(), Error>
pub fn assert_col_major_contiguous(&self) -> Result<(), Error>
Assert this view is compact column-major.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2];
let view = TypedTensorView::from_slice([2], [1], 0, &data)?;
view.assert_col_major_contiguous()?;§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::IntegerOverflow when
compactness arithmetic overflows, or
tenferro_tensor_core::ValidationError::InvalidArgument when the
view is not compact column-major.
Sourcepub fn get(&self, indices: &[usize]) -> Option<&T>
pub fn get(&self, indices: &[usize]) -> Option<&T>
Borrow one host element by logical index.
Returns None for out-of-bounds indices and backend buffers.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
assert_eq!(view.get(&[1]), Some(&2));Sourcepub fn as_slice(&self) -> Result<&'a [T], Error>
pub fn as_slice(&self) -> Result<&'a [T], Error>
Borrow the contiguous host slice covered by this view.
Returns an explicit error for backend buffers and for non-contiguous layouts. This method never downloads or materializes backend data.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice(vec![2], vec![1], 1, &data)?;
assert_eq!(view.as_slice()?, &[2, 3]);§Errors
Returns crate::Error::RuntimeState when this view wraps a backend
buffer, tenferro_tensor_core::ValidationError::NonContiguousViewAsSlice
when the layout is not compact column-major,
tenferro_tensor_core::ValidationError::InvalidArgument when the view
offset is negative, or crate::Error::Validation with
tenferro_tensor_core::ValidationError::ViewOutOfBounds or
tenferro_tensor_core::ValidationError::IntegerOverflow when the
requested host range is invalid.
Sourcepub fn duplicate(&self) -> Result<TypedTensor<T, R>, Error>where
T: Clone,
pub fn duplicate(&self) -> Result<TypedTensor<T, R>, Error>where
T: Clone,
Explicitly duplicate a compact host view into a new owner.
Backend views require an explicit provider canonicalization or download boundary; this method never transfers or materializes them implicitly.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
let copy = view.duplicate()?;
assert_eq!(copy.as_slice()?, &[1, 2]);§Errors
Returns crate::Error::HostAccess or
ValidationError::NonContiguousViewAsSlice when the view is backend
owned or not contiguous, and ValidationError::InvalidArgument when
the static-rank shape cannot be reconstructed.
Sourcepub fn to_col_major(&self) -> Result<TypedTensor<T, R>, Error>where
T: Clone,
pub fn to_col_major(&self) -> Result<TypedTensor<T, R>, Error>where
T: Clone,
Explicitly copy a host view, including strided/offset views, to a compact owner.
§Examples
use tenferro_tensor::{Rank, TypedTensorView};
let storage = [1, 4, 2, 5, 3, 6];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked(
[2, 3], [1, 2], 0, &storage,
)?;
let transposed = view.transpose_view([1, 0])?;
assert_eq!(transposed.to_col_major()?.as_slice()?, &[1, 2, 3, 4, 5, 6]);§Errors
Backend-only storage returns crate::Error::RuntimeState; invalid
layout or rank conversion returns crate::Error::Validation.
Sourcepub fn transpose_view(
&self,
axes: impl AsRef<[usize]>,
) -> Result<TypedTensorView<'a, T, R, D>, Error>
pub fn transpose_view( &self, axes: impl AsRef<[usize]>, ) -> Result<TypedTensorView<'a, T, R, D>, Error>
Return a metadata-only axis permutation.
§Examples
use tenferro_tensor::{Rank, TypedTensorView};
let data = [1_i32, 2, 3, 4, 5, 6];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked([2, 3], [1, 2], 0, &data)?;
let transposed = view.transpose_view([1, 0])?;
assert_eq!(transposed.shape(), &[3, 2]);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::InvalidPermutationLength,
tenferro_tensor_core::ValidationError::AxisOutOfBounds, or
tenferro_tensor_core::ValidationError::DuplicateAxis when axes is
not a valid permutation of the view rank.
Sourcepub fn slice_view(
&self,
slices: &[StridedSliceSpec],
) -> Result<TypedTensorView<'a, T, R, D>, Error>
pub fn slice_view( &self, slices: &[StridedSliceSpec], ) -> Result<TypedTensorView<'a, T, R, D>, Error>
Return a metadata-only slice using one StridedSliceSpec per axis.
§Examples
use tenferro_tensor::{StridedSliceSpec, TypedTensorView};
let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice(vec![3], vec![1], 0, &data)?;
let reversed = view.slice_view(&[StridedSliceSpec::reverse()])?;
assert_eq!(reversed.get(&[0]), Some(&3));§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::RankMismatch when the slice
count differs from the view rank,
tenferro_tensor_core::ValidationError::InvalidSliceStep or
tenferro_tensor_core::ValidationError::InvalidSliceBounds for an
invalid slice, tenferro_tensor_core::ValidationError::IntegerOverflow
for slice arithmetic overflow, or
tenferro_tensor_core::ValidationError::ViewOutOfBounds when the
resulting layout exceeds the backing buffer.
Sourcepub fn slice_axis_view(
&self,
axis: usize,
slice: StridedSliceSpec,
) -> Result<TypedTensorView<'a, T, R, D>, Error>
pub fn slice_axis_view( &self, axis: usize, slice: StridedSliceSpec, ) -> Result<TypedTensorView<'a, T, R, D>, Error>
Return a metadata-only slice along one axis.
§Examples
use tenferro_tensor::{StridedSliceSpec, TypedTensorView};
let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::from_slice(vec![2, 2], vec![1, 2], 0, &data)?;
assert_eq!(view.slice_axis_view(1, StridedSliceSpec::reverse())?.get(&[0, 0]), Some(&3));§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::AxisOutOfBounds when axis
is outside the view rank, tenferro_tensor_core::ValidationError::InvalidSliceStep
or tenferro_tensor_core::ValidationError::InvalidSliceBounds for an
invalid slice, tenferro_tensor_core::ValidationError::IntegerOverflow
for slice arithmetic overflow, or
tenferro_tensor_core::ValidationError::ViewOutOfBounds when the
resulting layout exceeds the backing buffer.
Sourcepub fn reshape_view(
&self,
shape: &[usize],
) -> Result<TypedTensorView<'a, T, DynRank, D>, Error>
pub fn reshape_view( &self, shape: &[usize], ) -> Result<TypedTensorView<'a, T, DynRank, D>, Error>
Return a metadata-only dynamic-rank reshape for contiguous column-major views.
§Examples
use tenferro_tensor::TypedTensorView;
let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::from_slice(vec![2, 2], vec![1, 2], 0, &data)?;
assert_eq!(view.reshape_view(&[4])?.shape(), &[4]);§Errors
Returns crate::Error::Validation with
tenferro_tensor_core::ValidationError::NonContiguousViewAsSlice when
the source is not compact column-major,
tenferro_tensor_core::ValidationError::ShapeMismatch (whose
tenferro_tensor_core::ShapeMismatch::ReshapeElementCount source
records the counts) when element counts differ,
tenferro_tensor_core::ValidationError::IntegerOverflow for shape
arithmetic overflow, or
tenferro_tensor_core::ValidationError::ViewOutOfBounds when the
reshaped view exceeds the backing buffer.
Source§impl<'a, R> TypedTensorView<'a, Complex<f32>, R>where
R: TensorRank,
impl<'a, R> TypedTensorView<'a, Complex<f32>, R>where
R: TensorRank,
Sourcepub fn as_real_view(&self) -> Result<TypedTensorView<'a, f32>, Error>
pub fn as_real_view(&self) -> Result<TypedTensorView<'a, f32>, Error>
Borrow this complex view as an interleaved real view without copying.
The result has dynamic rank because reinterpretation prepends the
component axis [2, ...]. Only Complex32 <-> f32 is sealed in this
API; this is representation reinterpretation, not numeric conversion.
§Examples
use tenferro_tensor::{Complex32, TypedTensorView};
let data = [Complex32::new(1.0, 2.0)];
let view = TypedTensorView::from_col_major(&[1], &data)?;
let real = view.as_real_view()?;
assert_eq!(real.shape(), &[2, 1]);
assert_eq!(real.as_slice()?, &[1.0_f32, 2.0]);§Errors
Returns an error when the view layout is not a valid sealed representation or when backend reinterpretation is unsupported.
Source§impl<'a, R> TypedTensorView<'a, Complex<f64>, R>where
R: TensorRank,
impl<'a, R> TypedTensorView<'a, Complex<f64>, R>where
R: TensorRank,
Sourcepub fn as_real_view(&self) -> Result<TypedTensorView<'a, f64>, Error>
pub fn as_real_view(&self) -> Result<TypedTensorView<'a, f64>, Error>
Borrow this complex view as an interleaved real view without copying.
The result has dynamic rank because reinterpretation prepends the
component axis [2, ...]. Only Complex64 <-> f64 is sealed in this
API; this is representation reinterpretation, not numeric conversion.
§Examples
use tenferro_tensor::{Complex64, TypedTensorView};
let data = [Complex64::new(1.0, 2.0)];
let view = TypedTensorView::from_col_major(&[1], &data)?;
let real = view.as_real_view()?;
assert_eq!(real.shape(), &[2, 1]);
assert_eq!(real.as_slice()?, &[1.0_f64, 2.0]);§Errors
Returns an error when the view layout is not a valid sealed representation or when backend reinterpretation is unsupported.
Source§impl<'a, R> TypedTensorView<'a, f32, R>where
R: TensorRank,
impl<'a, R> TypedTensorView<'a, f32, R>where
R: TensorRank,
Sourcepub fn as_complex_view(
&self,
) -> Result<TypedTensorView<'a, Complex<f32>>, Error>
pub fn as_complex_view( &self, ) -> Result<TypedTensorView<'a, Complex<f32>>, Error>
Borrow this interleaved real view as a complex view without copying.
The source must have a leading extent and stride of 2 and 1, and
every remaining stride plus the offset must be divisible by 2.
§Examples
use tenferro_tensor::{Complex32, TypedTensorView};
let data = [1.0_f32, 2.0];
let view = TypedTensorView::from_col_major(&[2, 1], &data)?;
let complex = view.as_complex_view()?;
assert_eq!(complex.shape(), &[1]);
assert_eq!(complex.as_slice()?, &[Complex32::new(1.0, 2.0)]);§Errors
Returns an error when the view layout is not a valid sealed representation or when backend reinterpretation is unsupported.
Source§impl<'a, R> TypedTensorView<'a, f64, R>where
R: TensorRank,
impl<'a, R> TypedTensorView<'a, f64, R>where
R: TensorRank,
Sourcepub fn as_complex_view(
&self,
) -> Result<TypedTensorView<'a, Complex<f64>>, Error>
pub fn as_complex_view( &self, ) -> Result<TypedTensorView<'a, Complex<f64>>, Error>
Borrow this interleaved real view as a complex view without copying.
The source must have a leading extent and stride of 2 and 1, and
every remaining stride plus the offset must be divisible by 2.
§Examples
use tenferro_tensor::{Complex64, TypedTensorView};
let data = [1.0_f64, 2.0];
let view = TypedTensorView::from_col_major(&[2, 1], &data)?;
let complex = view.as_complex_view()?;
assert_eq!(complex.shape(), &[1]);
assert_eq!(complex.as_slice()?, &[Complex64::new(1.0, 2.0)]);§Errors
Returns an error when the view layout is not a valid sealed representation or when backend reinterpretation is unsupported.
Trait Implementations§
Source§impl<T> AsView for TypedTensorView<'_, T>where
T: TensorScalar,
impl<T> AsView for TypedTensorView<'_, T>where
T: TensorScalar,
Source§fn as_read(&self) -> TensorRead<'_>
fn as_read(&self) -> TensorRead<'_>
TensorRead. Metadata only; never copies
element data. Read moreSource§impl<'a, T, R, D> Clone for TypedTensorView<'a, T, R, D>where
R: TensorRank,
D: Representation,
impl<'a, T, R, D> Clone for TypedTensorView<'a, T, R, D>where
R: TensorRank,
D: Representation,
Source§fn clone(&self) -> TypedTensorView<'a, T, R, D>
fn clone(&self) -> TypedTensorView<'a, T, R, D>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a, T, R, D> Debug for TypedTensorView<'a, T, R, D>where
R: TensorRank,
D: Representation,
impl<'a, T, R, D> Debug for TypedTensorView<'a, T, R, D>where
R: TensorRank,
D: Representation,
Auto Trait Implementations§
impl<'a, T, R = DynRank, D = Dynamic> !RefUnwindSafe for TypedTensorView<'a, T, R, D>
impl<'a, T, R = DynRank, D = Dynamic> !UnwindSafe for TypedTensorView<'a, T, R, D>
impl<'a, T, R, D> Freeze for TypedTensorView<'a, T, R, D>
impl<'a, T, R, D> Send for TypedTensorView<'a, T, R, D>
impl<'a, T, R, D> Sync for TypedTensorView<'a, T, R, D>
impl<'a, T, R, D> Unpin for TypedTensorView<'a, T, R, D>where
<R as TensorRank>::Shape: Unpin,
<R as TensorRank>::Strides: Unpin,
D: Unpin,
T: Unpin,
R: Unpin,
impl<'a, T, R, D> UnsafeUnpin for TypedTensorView<'a, T, R, D>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<X> CoreOps for X
impl<X> CoreOps for X
Source§fn exp(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn exp( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn neg(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn neg( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn sign(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn sign( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn conj(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn conj( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn log(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn log( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn expm1(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn expm1( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
exp(x) - 1. Read moreSource§fn log1p(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn log1p( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
log(1 + x). Read moreSource§fn erf(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn erf( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn sin(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn sin( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn cos(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn cos( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn tanh(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn tanh( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn sqrt(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn sqrt( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn rsqrt(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn rsqrt( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn abs(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as CoreRepr>::Real, Error>
fn abs( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as CoreRepr>::Real, Error>
Source§fn sigmoid(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn sigmoid( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn silu(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn silu( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
x * sigmoid(x)). Read moreSource§fn softplus(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn softplus( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
log(1 + exp(x)). Read moreSource§fn gelu(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn gelu( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn gelu_tanh(
&self,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn gelu_tanh( &self, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn mul(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn mul( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn sub(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn sub( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn div(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn div( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn rem(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn rem( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn pow(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn pow( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn maximum(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn maximum( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn minimum(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn minimum( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn add(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn add( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn add_into(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
dest: Dest<<<X as AsView>::Repr as Repr>::Write<'_>>,
) -> Result<(), Error>
fn add_into( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, dest: Dest<<<X as AsView>::Repr as Repr>::Write<'_>>, ) -> Result<(), Error>
Source§fn matmul(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn matmul( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn compare(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
dir: CompareDir,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as CoreRepr>::Bool, Error>
fn compare( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, dir: CompareDir, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as CoreRepr>::Bool, Error>
bool tensor. Read moreSource§fn clamp(
&self,
lower: &impl AsView<Repr = <X as AsView>::Repr>,
upper: &impl AsView<Repr = <X as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn clamp( &self, lower: &impl AsView<Repr = <X as AsView>::Repr>, upper: &impl AsView<Repr = <X as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
[lower, upper] with broadcasting. Read moreSource§fn where_select<Y>(
&self,
on_true: &Y,
on_false: &impl AsView<Repr = <Y as AsView>::Repr>,
exec: &mut dyn Engine,
) -> Result<<<Y as AsView>::Repr as Repr>::Value, Error>
fn where_select<Y>( &self, on_true: &Y, on_false: &impl AsView<Repr = <Y as AsView>::Repr>, exec: &mut dyn Engine, ) -> Result<<<Y as AsView>::Repr as Repr>::Value, Error>
on_true where the receiver is true, on_false elsewhere, with broadcasting. The receiver is the bool condition; a typed receiver must be TypedTensor<bool>. Read moreSource§fn dot_general(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
config: DotGeneralConfig,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn dot_general( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, config: DotGeneralConfig, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
DotGeneralConfig); DotGeneralOptions conjugates an operand. Read moreSource§fn dot_general_with(
&self,
b: &impl AsView<Repr = <X as AsView>::Repr>,
config: DotGeneralConfig,
options: &DotGeneralOptions,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn dot_general_with( &self, b: &impl AsView<Repr = <X as AsView>::Repr>, config: DotGeneralConfig, options: &DotGeneralOptions, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
DotGeneralConfig); DotGeneralOptions conjugates an operand. Read moreSource§fn reduce_sum(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn reduce_sum( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn reduce_max(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn reduce_max( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn reduce_min(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn reduce_min( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn reduce_prod(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn reduce_prod( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn reduce_sum_squares(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn reduce_sum_squares( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
axes (None: every axis); axes are signed, -1 is the last axis. Read moreSource§fn reduce_mean(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn reduce_mean( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn reshape(
&self,
shape: &[usize],
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn reshape( &self, shape: &[usize], exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
shape in column-major element order. Read moreSource§fn broadcast_in_dim(
&self,
shape: &[usize],
dims: &[usize],
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn broadcast_in_dim( &self, shape: &[usize], dims: &[usize], exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
shape; dims[i] is the output axis of input axis i (an IR-level dimension map, unsigned like the *Config structs). Read moreSource§fn transpose(
&self,
perm: &[isize],
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn transpose( &self, perm: &[isize], exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn reverse(
&self,
axes: &[isize],
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn reverse( &self, axes: &[isize], exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
axes (signed). Read moreSource§fn tril(
&self,
k: i64,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn tril( &self, k: i64, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
k. Read moreSource§fn triu(
&self,
k: i64,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn triu( &self, k: i64, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
k. Read moreSource§fn extract_diag(
&self,
axis_a: isize,
axis_b: isize,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn extract_diag( &self, axis_a: isize, axis_b: isize, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn embed_diag(
&self,
axis_a: isize,
axis_b: isize,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn embed_diag( &self, axis_a: isize, axis_b: isize, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
axis_a of the receiver as the diagonal of a new axis pair; axis_b (signed, against the output rank) is the position of the inserted axis. Read moreSource§fn slice(
&self,
config: SliceConfig,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn slice( &self, config: SliceConfig, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
SliceConfig). Read moreSource§fn pad(
&self,
config: PadConfig,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn pad( &self, config: PadConfig, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
PadConfig). Read moreSource§fn gather(
&self,
indices: &impl AsView,
config: GatherConfig,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn gather( &self, indices: &impl AsView, config: GatherConfig, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn scatter(
&self,
indices: &impl AsView,
updates: &impl AsView,
config: ScatterConfig,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn scatter( &self, indices: &impl AsView, updates: &impl AsView, config: ScatterConfig, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn dynamic_slice(
&self,
starts: &impl AsView,
sizes: &[usize],
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn dynamic_slice( &self, starts: &impl AsView, sizes: &[usize], exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn dynamic_update_slice(
&self,
update: &impl AsView<Repr = <X as AsView>::Repr>,
starts: &impl AsView,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn dynamic_update_slice( &self, update: &impl AsView<Repr = <X as AsView>::Repr>, starts: &impl AsView, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn concatenate(
inputs: &[&X],
axis: isize,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn concatenate( inputs: &[&X], axis: isize, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
inputs along axis (signed). Called as CoreOps::concatenate(&[&a, &b], axis, exec). Read moreSource§fn convert(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor, Error>
fn convert(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor, Error>
Tensor because its dtype is a run-time value. Read moreSource§fn cast(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor, Error>
fn cast(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor, Error>
Tensor because its dtype is a run-time value. Read moreSource§fn scale_real(
&self,
factor: f64,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn scale_real( &self, factor: f64, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn scale_complex(
&self,
factor: Complex<f64>,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn scale_complex( &self, factor: Complex<f64>, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn softmax(
&self,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn softmax( &self, axis: isize, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
axis (signed). Read moreSource§fn log_softmax(
&self,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn log_softmax( &self, axis: isize, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
axis (signed). Read moreSource§fn masked_softmax(
&self,
mask: &impl AsView,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn masked_softmax( &self, mask: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn masked_log_softmax(
&self,
mask: &impl AsView,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn masked_log_softmax( &self, mask: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
Source§fn take_along_axis(
&self,
indices: &impl AsView,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
fn take_along_axis( &self, indices: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<<X as AsView>::Repr as Repr>::Value, Error>
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more