TensorLike

Trait TensorLike 

Source
pub trait TensorLike<T>: Sized {
    // Required methods
    fn as_raw(&self) -> &[T];
    fn as_raw_mut(&mut self) -> &mut [T];

    // Provided method
    fn elsize() -> usize { ... }
}
Expand description

A trait for let the object like a tensor

Required Methods§

Source

fn as_raw(&self) -> &[T]

directly convert the tensor to raw slice

§Note

This function will return a raw slice of the tensor regardless of the shape and strides.

if you do iteration on the view tensor, you may see unexpected results.

Source

fn as_raw_mut(&mut self) -> &mut [T]

directly convert the tensor to mutable raw slice

§Note

This function will return a mutable raw slice of the tensor regardless of the shape and strides.

if you do iteration on the view tensor, you may see unexpected results.

Provided Methods§

Source

fn elsize() -> usize

Returns the data type memory size in bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, const DEVICE: usize, A> TensorLike<T> for Tensor<T, Cpu, DEVICE, A>
where T: CommonBounds, A: Allocator,