pub struct TensorCreationOptions {
pub device: Device,
pub dtype: Option<DType>,
}Expand description
Options for tensor creation.
This struct allows specifying the device and overriding the data type when creating a tensor.
When the dtype is not specified, the device’s default settings is used.
Fields§
§device: DeviceDevice where the tensor will be created.
dtype: Option<DType>Optional data type.
If None, the dtype will be inferred on creation from the device settings.
Implementations§
Source§impl TensorCreationOptions
impl TensorCreationOptions
Sourcepub fn new(device: Device) -> Self
pub fn new(device: Device) -> Self
Create new options with a specific device.
Data type will follow the device settings on tensor creation.
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) -> Self
pub fn with_device(self, device: Device) -> 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 Clone for TensorCreationOptions
impl Clone for TensorCreationOptions
Source§fn clone(&self) -> TensorCreationOptions
fn clone(&self) -> TensorCreationOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TensorCreationOptions
impl Debug for TensorCreationOptions
Source§impl Default for TensorCreationOptions
impl Default for TensorCreationOptions
Source§impl From<&Device> for TensorCreationOptions
impl From<&Device> for TensorCreationOptions
Auto Trait Implementations§
impl Freeze for TensorCreationOptions
impl RefUnwindSafe for TensorCreationOptions
impl Send for TensorCreationOptions
impl Sync for TensorCreationOptions
impl Unpin for TensorCreationOptions
impl UnsafeUnpin for TensorCreationOptions
impl UnwindSafe for TensorCreationOptions
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more