pub struct TensorCreationOptions<B: Backend> {
pub device: Device<B>,
pub dtype: Option<DType>,
}Expand description
Options for tensor creation.
This struct allows specifying the device and/or data type (dtype) when creating a tensor.
Fields§
§device: Device<B>Device where the tensor will be created.
dtype: Option<DType>Optional data type.
If None, the dtype will be inferred on creation from the backend’s default dtype for the tensor kind.
Implementations§
Source§impl<B: Backend> TensorCreationOptions<B>
impl<B: Backend> TensorCreationOptions<B>
Sourcepub fn new(device: Device<B>) -> Self
pub fn new(device: Device<B>) -> Self
Create new options with a specific device.
Data type will be inferred on creation from the backend’s default dtype for the tensor kind.
Sourcepub fn with_dtype(self, dtype: DType) -> Self
pub fn with_dtype(self, dtype: DType) -> Self
Set the tensor creation data type.
Sourcepub fn with_device(self, device: Device<B>) -> Self
pub fn with_device(self, device: Device<B>) -> Self
Set the tensor creation device.
Sourcepub fn dtype_or(&self, dtype: DType) -> DType
pub fn dtype_or(&self, dtype: DType) -> DType
Returns the tensor data type, or a provided default if not set.
This is useful for cases where TensorCreationOptions may not have an explicit dtype.
Trait Implementations§
Source§impl<B: Clone + Backend> Clone for TensorCreationOptions<B>
impl<B: Clone + Backend> Clone for TensorCreationOptions<B>
Source§fn clone(&self) -> TensorCreationOptions<B>
fn clone(&self) -> TensorCreationOptions<B>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<B: Backend> Default for TensorCreationOptions<B>
impl<B: Backend> Default for TensorCreationOptions<B>
Auto Trait Implementations§
impl<B> Freeze for TensorCreationOptions<B>
impl<B> RefUnwindSafe for TensorCreationOptions<B>
impl<B> Send for TensorCreationOptions<B>
impl<B> Sync for TensorCreationOptions<B>
impl<B> Unpin for TensorCreationOptions<B>
impl<B> UnwindSafe for TensorCreationOptions<B>
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
Mutably borrows from an owned value. Read more