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§
Required Methods§
Sourcefn empty<S: Into<Shape>>(shape: S) -> Result<Self::Output, TensorError>
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 typeSmust implementInto<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.