Trait CPUTensorCreator

Source
pub trait CPUTensorCreator<T> {
    type Output;

    // Required method
    fn empty<S: Into<Shape>>(shape: S) -> Result<Self::Output, TensorError>;
}
Expand description

A trait defines empty function for Tensor that will allocate memory on CPU.

Required Associated Types§

Source

type Output

the output type of the creator

Required Methods§

Source

fn empty<S: Into<Shape>>(shape: S) -> Result<Self::Output, TensorError>

Creates a tensor with uninitialized elements of the specified shape.

This function allocates memory for a tensor in CPU of the given shape, but the values are uninitialized, meaning they may contain random data.

§Arguments
  • shape - The desired shape of the tensor. The type S must implement Into<Shape>.
§Returns
  • A tensor with the specified shape, but with uninitialized data.
§Panics
  • This function may panic if the requested shape is invalid or too large for available memory.

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§