pub struct TensorView<'a, Scalar, const MAX_RANK: usize = DEFAULT_MAX_RANK> { /* private fields */ }Expand description
A read-only, zero-copy view into a Tensor.
TensorView borrows the parent tensor’s memory for the duration of 'a
without owning or copying any data. Views may have arbitrary byte strides,
so they transparently represent slicing, transposition, or step-sampling
of the underlying storage — iteration and indexing honour those strides.
A view is normally obtained by calling Tensor::view or by slicing:
tensor.slice((0..4_usize, ..)). For lower-level construction from a
raw pointer plus shape/stride arrays, see TensorView::from_raw_parts.
TensorView is the immutable counterpart of TensorSpan. Both share
the same layout fields, but a view cannot be used to mutate the backing
storage. Multiple views into the same tensor may coexist, subject to
Rust’s borrow rules; a mutable span excludes all other references.
The 'a lifetime ties the view to the source tensor (or outer view),
ensuring the referenced memory outlives the view itself.
Implementations§
Source§impl<'a, Scalar: MaxSim, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: MaxSim, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub fn try_maxsim_pack_in<Alloc: Allocator>(
&self,
alloc: Alloc,
) -> Result<MaxSimPackedMatrix<Scalar, Alloc>, TensorError>
pub fn try_maxsim_pack_in<Alloc: Allocator>( &self, alloc: Alloc, ) -> Result<MaxSimPackedMatrix<Scalar, Alloc>, TensorError>
Pack this 2D tensor view for MaxSim scoring using the provided allocator.
Sourcepub fn try_maxsim_pack(
&self,
) -> Result<MaxSimPackedMatrix<Scalar, Global>, TensorError>
pub fn try_maxsim_pack( &self, ) -> Result<MaxSimPackedMatrix<Scalar, Global>, TensorError>
Pack this 2D tensor view for MaxSim scoring using the global allocator.
Source§impl<'a, Scalar: Dots, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>where
Scalar::Accumulator: 'static,
impl<'a, Scalar: Dots, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>where
Scalar::Accumulator: 'static,
Sourcepub fn try_dots_symmetric(
&self,
) -> Result<Tensor<Scalar::Accumulator, Global, MAX_RANK>, TensorError>
pub fn try_dots_symmetric( &self, ) -> Result<Tensor<Scalar::Accumulator, Global, MAX_RANK>, TensorError>
Computes the symmetric dot-product matrix C = A × Aᵀ.
Given a matrix of row vectors, computes the matrix of all pairwise dot products. The result is a symmetric n×n matrix where result[i,j] = dot(row_i, row_j).
§Example
use numkong::{Tensor, TensorView};
// 100 vectors of dimension 768
let vectors = Tensor::<f32>::try_full(&[100, 768], 0.0)?;
// Compute 100×100 symmetric matrix
let gram = vectors.view().try_dots_symmetric()?;
assert_eq!(gram.shape(), &[100, 100]);Sourcepub fn try_dots_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>(
&self,
c: &mut OutputTensor,
) -> Result<(), TensorError>where
OutputTensor: TensorMut<Scalar::Accumulator, OUTPUT_MAX_RANK>,
pub fn try_dots_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>(
&self,
c: &mut OutputTensor,
) -> Result<(), TensorError>where
OutputTensor: TensorMut<Scalar::Accumulator, OUTPUT_MAX_RANK>,
Computes the symmetric dot-product matrix into pre-allocated output.
Only the upper triangle of c is written; the lower triangle is left
as-is. The output may be a &mut Tensor<...> or &mut TensorSpan<...>.
Source§impl<'a, Scalar: Angulars, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Angulars, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub fn try_angulars_symmetric(
&self,
) -> Result<Tensor<Scalar::SpatialResult, Global, MAX_RANK>, TensorError>
pub fn try_angulars_symmetric( &self, ) -> Result<Tensor<Scalar::SpatialResult, Global, MAX_RANK>, TensorError>
Computes symmetric angular distance matrix for a set of vectors.
Sourcepub fn try_angulars_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>(
&self,
c: &mut OutputTensor,
) -> Result<(), TensorError>where
OutputTensor: TensorMut<Scalar::SpatialResult, OUTPUT_MAX_RANK>,
pub fn try_angulars_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>(
&self,
c: &mut OutputTensor,
) -> Result<(), TensorError>where
OutputTensor: TensorMut<Scalar::SpatialResult, OUTPUT_MAX_RANK>,
Computes symmetric angular distances into pre-allocated output. Only the upper triangle is written.
Source§impl<'a, Scalar: Euclideans, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Euclideans, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub fn try_euclideans_symmetric(
&self,
) -> Result<Tensor<Scalar::SpatialResult, Global, MAX_RANK>, TensorError>
pub fn try_euclideans_symmetric( &self, ) -> Result<Tensor<Scalar::SpatialResult, Global, MAX_RANK>, TensorError>
Computes symmetric euclidean distance matrix for a set of vectors.
Sourcepub fn try_euclideans_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>(
&self,
c: &mut OutputTensor,
) -> Result<(), TensorError>where
OutputTensor: TensorMut<Scalar::SpatialResult, OUTPUT_MAX_RANK>,
pub fn try_euclideans_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>(
&self,
c: &mut OutputTensor,
) -> Result<(), TensorError>where
OutputTensor: TensorMut<Scalar::SpatialResult, OUTPUT_MAX_RANK>,
Computes symmetric euclidean distances into pre-allocated output. Only the upper triangle is written.
Source§impl<'a, Scalar: Hammings, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Hammings, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub fn try_hammings_symmetric(
&self,
) -> Result<Tensor<u32, Global, MAX_RANK>, TensorError>
pub fn try_hammings_symmetric( &self, ) -> Result<Tensor<u32, Global, MAX_RANK>, TensorError>
Computes symmetric Hamming distance matrix for a set of binary vectors.
Sourcepub fn try_hammings_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>(
&self,
c: &mut OutputTensor,
) -> Result<(), TensorError>
pub fn try_hammings_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>( &self, c: &mut OutputTensor, ) -> Result<(), TensorError>
Computes symmetric Hamming distances into pre-allocated output. Only the upper triangle is written.
Source§impl<'a, Scalar: Jaccards, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Jaccards, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub fn try_jaccards_symmetric(
&self,
) -> Result<Tensor<Scalar::JaccardResult, Global, MAX_RANK>, TensorError>
pub fn try_jaccards_symmetric( &self, ) -> Result<Tensor<Scalar::JaccardResult, Global, MAX_RANK>, TensorError>
Computes symmetric Jaccard distance matrix for a set of binary vectors.
Sourcepub fn try_jaccards_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>(
&self,
c: &mut OutputTensor,
) -> Result<(), TensorError>where
OutputTensor: TensorMut<Scalar::JaccardResult, OUTPUT_MAX_RANK>,
pub fn try_jaccards_symmetric_into<OutputTensor, const OUTPUT_MAX_RANK: usize>(
&self,
c: &mut OutputTensor,
) -> Result<(), TensorError>where
OutputTensor: TensorMut<Scalar::JaccardResult, OUTPUT_MAX_RANK>,
Computes symmetric Jaccard distances into pre-allocated output. Only the upper triangle is written.
Source§impl<'a, Scalar, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub unsafe fn from_raw_parts(
data: *const Scalar,
shape: &[usize],
strides_bytes: &[isize],
) -> Self
pub unsafe fn from_raw_parts( data: *const Scalar, shape: &[usize], strides_bytes: &[isize], ) -> Self
Create a view from a raw pointer, shape, and byte strides.
The shape specifies logical dimensions. For sub-byte types, the
storage count is inferred as shape.product() / dimensions_per_value().
For normal types the two are equal.
§Safety
datamust be valid for reads over the region described byshapeandstrides_bytes.- The pointed-to memory must outlive
'a. shape.len()must be<= MAX_RANK.shape.len()must equalstrides_bytes.len().
§Panics
Panics if shape.len() > MAX_RANK or shape.len() != strides_bytes.len().
Sourcepub fn numel(&self) -> usize
pub fn numel(&self) -> usize
Returns the total number of logical elements (computed from shape).
Sourcepub fn stride_bytes(&self, dim: usize) -> isize
pub fn stride_bytes(&self, dim: usize) -> isize
Returns the stride in bytes for the given dimension.
Sourcepub fn as_ptr(&self) -> *const Scalar
pub fn as_ptr(&self) -> *const Scalar
Returns a pointer to the first element.
Sourcepub fn has_contiguous_rows(&self) -> bool
pub fn has_contiguous_rows(&self) -> bool
Check if the view has contiguous rows.
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
Check if the entire view is contiguous in memory.
Sourcepub unsafe fn get_unchecked(&self, index: usize) -> &Scalar
pub unsafe fn get_unchecked(&self, index: usize) -> &Scalar
Get element at flat index (only valid for contiguous views).
§Safety
Caller must ensure the view is contiguous and index is in bounds.
Sourcepub fn try_flat<AnyIndex: VectorIndex>(
&self,
index: AnyIndex,
) -> Result<&Scalar, TensorError>
pub fn try_flat<AnyIndex: VectorIndex>( &self, index: AnyIndex, ) -> Result<&Scalar, TensorError>
Try to get an element by flat logical row-major index.
Negative isize indices wrap from the end (-1 is the last element).
Returns TensorError::DimensionMismatch on a rank-0 view and
TensorError::IndexOutOfBounds when the index is outside the
logical element count.
§Examples
use numkong::tensor::Tensor;
let t = Tensor::<f32>::try_from_slice(&[1.0, 2.0, 3.0, 4.0], &[2, 2]).unwrap();
let view = t.view();
assert_eq!(*view.try_flat(0_usize).unwrap(), 1.0);
assert_eq!(*view.try_flat(-1_i32).unwrap(), 4.0);Sourcepub fn try_coords<C: TensorCoordinates>(
&self,
coords: C,
) -> Result<&Scalar, TensorError>
pub fn try_coords<C: TensorCoordinates>( &self, coords: C, ) -> Result<&Scalar, TensorError>
Try to get an element by exact coordinates.
Sourcepub fn try_scalar(&self) -> Result<&Scalar, TensorError>
pub fn try_scalar(&self) -> Result<&Scalar, TensorError>
Try to access the scalar value of a rank-0 tensor view.
Sourcepub fn slice_leading<AnyIndex: VectorIndex>(
&self,
index: AnyIndex,
) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
pub fn slice_leading<AnyIndex: VectorIndex>( &self, index: AnyIndex, ) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
Slice the leading axis by one index, reducing rank by one.
Sourcepub fn slice(
&self,
spec: impl SliceSpec,
) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
pub fn slice( &self, spec: impl SliceSpec, ) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
Slice the view along multiple dimensions.
Accepts tuples of Rust range types or &[SliceRange]. Indexing with a
scalar reduces the rank, while range arguments preserve it.
§Examples
use numkong::tensor::{Tensor, SliceRange};
let t = Tensor::<f32>::try_full(&[4, 5], 1.0).unwrap();
let view = t.view();
// Rust-native tuple syntax
let row = view.slice((1_usize, ..)).unwrap(); // t[1, :]
let block = view.slice((1..3_usize, 0..4_usize)).unwrap();// t[1:3, 0:4]
// Enum-based syntax for programmatic construction
let same_row = view.slice(&[SliceRange::index(1), SliceRange::full()]).unwrap();
assert_eq!(row.shape(), same_row.shape());Source§impl<'a, Scalar: Clone + StorageElement, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + StorageElement, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub fn to_owned(&self) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn to_owned(&self) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
Copy the view contents to a new owned Tensor.
Sourcepub fn storage_len(&self) -> usize
pub fn storage_len(&self) -> usize
Number of storage values (for sub-byte types, less than numel).
Sourcepub fn as_contiguous_slice(&self) -> Option<&[Scalar]>
pub fn as_contiguous_slice(&self) -> Option<&[Scalar]>
Convert to slice (only valid for contiguous views).
Source§impl<'a, Scalar, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub fn axis_views<AnyIndex: VectorIndex>(
&self,
axis: AnyIndex,
) -> Result<AxisIterator<'a, Scalar, MAX_RANK>, TensorError>
pub fn axis_views<AnyIndex: VectorIndex>( &self, axis: AnyIndex, ) -> Result<AxisIterator<'a, Scalar, MAX_RANK>, TensorError>
Iterate along the given axis, yielding sub-tensor views with rank-1.
Source§impl<'a, Scalar: StorageElement, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: StorageElement, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub fn transpose(&self) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
pub fn transpose(&self) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
Transpose (reverse all dimensions, no data copy).
Returns an error for sub-byte types with ndim >= 2, since transposing would produce non-contiguous strides that break packed element addressing.
Sourcepub fn reshape(
&self,
new_shape: &[usize],
) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
pub fn reshape( &self, new_shape: &[usize], ) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
Reshape the view (must have same total elements, contiguous only).
Returns an error for sub-byte types, since reshape would invalidate the packed element layout.
Sourcepub fn flatten(&self) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
pub fn flatten(&self) -> Result<TensorView<'a, Scalar, MAX_RANK>, TensorError>
Flatten to 1D (requires contiguous layout).
Sourcepub fn squeeze(&self) -> TensorView<'a, Scalar, MAX_RANK>
pub fn squeeze(&self) -> TensorView<'a, Scalar, MAX_RANK>
Remove dimensions of size 1.
Source§impl<'a, Scalar: FloatConvertible, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: FloatConvertible, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
Sourcepub fn iter(&self) -> TensorViewIterator<'a, Scalar, MAX_RANK> ⓘ
pub fn iter(&self) -> TensorViewIterator<'a, Scalar, MAX_RANK> ⓘ
Returns a lazy iterator over all logical scalars in row-major order.
Yields (position, DimRef) pairs. Use .iter().dims() for just dimensions.
For sub-byte types, the innermost dimension is expanded.
Source§impl<'a, Scalar: Clone + EachScale, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + EachScale, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
pub fn try_scale_tensor( &self, alpha: Scalar::Scalar, beta: Scalar::Scalar, ) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_scale_tensor_into( &self, alpha: Scalar::Scalar, beta: Scalar::Scalar, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
pub fn try_add_scalar( &self, scalar: Scalar::Scalar, ) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_sub_scalar( &self, scalar: Scalar::Scalar, ) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_mul_scalar( &self, scalar: Scalar::Scalar, ) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_add_scalar_into( &self, scalar: Scalar::Scalar, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
pub fn try_sub_scalar_into( &self, scalar: Scalar::Scalar, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
pub fn try_mul_scalar_into( &self, scalar: Scalar::Scalar, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
Source§impl<'a, Scalar: Clone + EachSum, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + EachSum, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
pub fn try_add_tensor( &self, other: &TensorView<'_, Scalar, MAX_RANK>, ) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_add_tensor_into( &self, other: &TensorView<'_, Scalar, MAX_RANK>, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
Source§impl<'a, Scalar: Clone + EachBlend, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + EachBlend, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
pub fn try_blend_tensor( &self, other: &TensorView<'_, Scalar, MAX_RANK>, alpha: Scalar::Scalar, beta: Scalar::Scalar, ) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_blend_tensor_into( &self, other: &TensorView<'_, Scalar, MAX_RANK>, alpha: Scalar::Scalar, beta: Scalar::Scalar, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
pub fn try_sub_tensor( &self, other: &TensorView<'_, Scalar, MAX_RANK>, ) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_sub_tensor_into( &self, other: &TensorView<'_, Scalar, MAX_RANK>, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
Source§impl<'a, Scalar: Clone + EachFMA, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + EachFMA, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
pub fn try_fma_tensors( &self, b: &TensorView<'_, Scalar, MAX_RANK>, c: &TensorView<'_, Scalar, MAX_RANK>, alpha: Scalar::Scalar, beta: Scalar::Scalar, ) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_fma_tensors_into( &self, b: &TensorView<'_, Scalar, MAX_RANK>, c: &TensorView<'_, Scalar, MAX_RANK>, alpha: Scalar::Scalar, beta: Scalar::Scalar, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
pub fn try_mul_tensor( &self, other: &TensorView<'_, Scalar, MAX_RANK>, ) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_mul_tensor_into( &self, other: &TensorView<'_, Scalar, MAX_RANK>, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
Source§impl<'a, Source: Clone + CastDtype, const MAX_RANK: usize> TensorView<'a, Source, MAX_RANK>
impl<'a, Source: Clone + CastDtype, const MAX_RANK: usize> TensorView<'a, Source, MAX_RANK>
pub fn try_cast_dtype<Destination: Clone + CastDtype>( &self, ) -> Result<Tensor<Destination, Global, MAX_RANK>, TensorError>
pub fn try_cast_dtype_into<Destination: Clone + CastDtype>( &self, out: &mut TensorSpan<'_, Destination, MAX_RANK>, ) -> Result<(), TensorError>
Source§impl<'a, Scalar: Clone + EachSin, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + EachSin, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
pub fn try_sin(&self) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_sin_into( &self, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
Source§impl<'a, Scalar: Clone + EachCos, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + EachCos, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
pub fn try_cos(&self) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_cos_into( &self, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
Source§impl<'a, Scalar: Clone + EachATan, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + EachATan, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
pub fn try_atan(&self) -> Result<Tensor<Scalar, Global, MAX_RANK>, TensorError>
pub fn try_atan_into( &self, out: &mut TensorSpan<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
Source§impl<'a, Scalar: Clone + ReduceMoments, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + ReduceMoments, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
pub fn try_moments_all( &self, ) -> Result<(Scalar::SumOutput, Scalar::SumSqOutput), TensorError>
pub fn try_moments_axis<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, ) -> Result<(Tensor<<Scalar as ReduceMoments>::SumOutput, Global, MAX_RANK>, Tensor<<Scalar as ReduceMoments>::SumSqOutput, Global, MAX_RANK>), TensorError>
pub fn try_moments_axis_into<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, sum_out: &mut Tensor<Scalar::SumOutput, Global, MAX_RANK>, sumsq_out: &mut Tensor<Scalar::SumSqOutput, Global, MAX_RANK>, ) -> Result<(), TensorError>
pub fn try_sum_all(&self) -> Result<Scalar::SumOutput, TensorError>
pub fn try_sum_axis<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, ) -> Result<Tensor<Scalar::SumOutput, Global, MAX_RANK>, TensorError>
pub fn try_sum_axis_into<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, out: &mut Tensor<Scalar::SumOutput, Global, MAX_RANK>, ) -> Result<(), TensorError>
pub fn try_norm_all(&self) -> Result<f64, TensorError>
pub fn try_norm_axis<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, ) -> Result<Tensor<f64, Global, MAX_RANK>, TensorError>
pub fn try_norm_axis_into<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, out: &mut Tensor<f64, Global, MAX_RANK>, ) -> Result<(), TensorError>
Source§impl<'a, Scalar: Clone + ReduceMinMax, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: Clone + ReduceMinMax, const MAX_RANK: usize> TensorView<'a, Scalar, MAX_RANK>
pub fn try_minmax_all( &self, ) -> Result<MinMaxResult<Scalar::Output>, TensorError>
pub fn try_minmax_axis<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, ) -> Result<MinMaxResult<Tensor<<Scalar as ReduceMinMax>::Output, Global, MAX_RANK>, Tensor<usize, Global, MAX_RANK>>, TensorError>
pub fn try_minmax_axis_into<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, min_out: &mut Tensor<Scalar::Output, Global, MAX_RANK>, argmin_out: &mut Tensor<usize, Global, MAX_RANK>, max_out: &mut Tensor<Scalar::Output, Global, MAX_RANK>, argmax_out: &mut Tensor<usize, Global, MAX_RANK>, ) -> Result<(), TensorError>
pub fn try_min_all(&self) -> Result<Scalar::Output, TensorError>
pub fn try_argmin_all(&self) -> Result<usize, TensorError>
pub fn try_max_all(&self) -> Result<Scalar::Output, TensorError>
pub fn try_argmax_all(&self) -> Result<usize, TensorError>
pub fn try_min_axis<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, ) -> Result<Tensor<Scalar::Output, Global, MAX_RANK>, TensorError>
pub fn try_argmin_axis<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, ) -> Result<Tensor<usize, Global, MAX_RANK>, TensorError>
pub fn try_max_axis<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, ) -> Result<Tensor<Scalar::Output, Global, MAX_RANK>, TensorError>
pub fn try_argmax_axis<AnyIndex: VectorIndex>( &self, axis: AnyIndex, keep_dims: bool, ) -> Result<Tensor<usize, Global, MAX_RANK>, TensorError>
Trait Implementations§
Source§impl<'a, 'b, Scalar: StorageElement, const MAX_RANK: usize> CopyFrom<&'b TensorView<'_, Scalar, MAX_RANK>> for TensorSpan<'a, Scalar, MAX_RANK>
impl<'a, 'b, Scalar: StorageElement, const MAX_RANK: usize> CopyFrom<&'b TensorView<'_, Scalar, MAX_RANK>> for TensorSpan<'a, Scalar, MAX_RANK>
Source§fn copy_from(
&mut self,
source: &'b TensorView<'_, Scalar, MAX_RANK>,
) -> Result<(), TensorError>
fn copy_from( &mut self, source: &'b TensorView<'_, Scalar, MAX_RANK>, ) -> Result<(), TensorError>
source into self. Returns an error on a shape or storage
mismatch and does not modify the destination on error.Source§impl<'a, I0: VectorIndex, I1: VectorIndex, Scalar, const MAX_RANK: usize> Index<(I0, I1)> for TensorView<'a, Scalar, MAX_RANK>
impl<'a, I0: VectorIndex, I1: VectorIndex, Scalar, const MAX_RANK: usize> Index<(I0, I1)> for TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, Scalar, const MAX_RANK: usize> Index<(I0, I1, I2)> for TensorView<'a, Scalar, MAX_RANK>
impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, Scalar, const MAX_RANK: usize> Index<(I0, I1, I2)> for TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3)> for TensorView<'a, Scalar, MAX_RANK>
impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3)> for TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, I4: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3, I4)> for TensorView<'a, Scalar, MAX_RANK>
impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, I4: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3, I4)> for TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, I4: VectorIndex, I5: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3, I4, I5)> for TensorView<'a, Scalar, MAX_RANK>
impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, I4: VectorIndex, I5: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3, I4, I5)> for TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, I4: VectorIndex, I5: VectorIndex, I6: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3, I4, I5, I6)> for TensorView<'a, Scalar, MAX_RANK>
impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, I4: VectorIndex, I5: VectorIndex, I6: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3, I4, I5, I6)> for TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, I4: VectorIndex, I5: VectorIndex, I6: VectorIndex, I7: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3, I4, I5, I6, I7)> for TensorView<'a, Scalar, MAX_RANK>
impl<'a, I0: VectorIndex, I1: VectorIndex, I2: VectorIndex, I3: VectorIndex, I4: VectorIndex, I5: VectorIndex, I6: VectorIndex, I7: VectorIndex, Scalar: StorageElement, const MAX_RANK: usize> Index<(I0, I1, I2, I3, I4, I5, I6, I7)> for TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, AnyIndex: VectorIndex, Scalar, const MAX_RANK: usize> Index<AnyIndex> for TensorView<'a, Scalar, MAX_RANK>
impl<'a, AnyIndex: VectorIndex, Scalar, const MAX_RANK: usize> Index<AnyIndex> for TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, Scalar: FloatConvertible, const MAX_RANK: usize> IntoIterator for &'a TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: FloatConvertible, const MAX_RANK: usize> IntoIterator for &'a TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, Scalar: FloatConvertible, const MAX_RANK: usize> PartialEq for TensorView<'a, Scalar, MAX_RANK>
impl<'a, Scalar: FloatConvertible, const MAX_RANK: usize> PartialEq for TensorView<'a, Scalar, MAX_RANK>
Source§impl<'a, Scalar: StorageElement, const R: usize> TensorRef<Scalar, R> for TensorView<'a, Scalar, R>
impl<'a, Scalar: StorageElement, const R: usize> TensorRef<Scalar, R> for TensorView<'a, Scalar, R>
Source§fn as_ptr(&self) -> *const Scalar
fn as_ptr(&self) -> *const Scalar
Source§fn view(&self) -> TensorView<'_, Scalar, R>
fn view(&self) -> TensorView<'_, Scalar, R>
TensorView with the same shape and strides. Read moreSource§fn numel(&self) -> usize
fn numel(&self) -> usize
Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
true if the tensor contains zero logical elements. Read moreSource§fn has_contiguous_rows(&self) -> bool
fn has_contiguous_rows(&self) -> bool
true for rank-2 tensors whose innermost stride equals one
element — the layout required by GEMM’s left-hand matrix.Source§fn is_contiguous(&self) -> bool
fn is_contiguous(&self) -> bool
true if the entire tensor is stored in row-major contiguous
order with no gaps. Read more