pub trait Cast<B, K>where
B: Backend,
K: TensorKind<B>,{
type OutputKind: TensorKind<B>;
// Required method
fn cast(
primitive: <K as TensorKind<B>>::Primitive,
dtype: Self,
) -> <Self::OutputKind as TensorKind<B>>::Primitive;
}Expand description
Required Associated Types§
Sourcetype OutputKind: TensorKind<B>
type OutputKind: TensorKind<B>
The output tensor kind after casting.
Required Methods§
Sourcefn cast(
primitive: <K as TensorKind<B>>::Primitive,
dtype: Self,
) -> <Self::OutputKind as TensorKind<B>>::Primitive
fn cast( primitive: <K as TensorKind<B>>::Primitive, dtype: Self, ) -> <Self::OutputKind as TensorKind<B>>::Primitive
Cast a tensor primitive to the target dtype.
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<B> Cast<B, Bool> for FloatDTypewhere
B: Backend,
impl<B> Cast<B, Bool> for FloatDTypewhere
B: Backend,
type OutputKind = Float
Source§impl<B> Cast<B, Float> for DTypewhere
B: Backend,
Backward-compatible impl: only float DType variants are accepted.
impl<B> Cast<B, Float> for DTypewhere
B: Backend,
Backward-compatible impl: only float DType variants are accepted.
§Panics
Panics if dtype is not a float variant (e.g., DType::I32).
Use IntDType directly for cross-kind casting to int.
type OutputKind = Float
Source§impl<B> Cast<B, Float> for FloatDTypewhere
B: Backend,
impl<B> Cast<B, Float> for FloatDTypewhere
B: Backend,
type OutputKind = Float
Source§impl<B> Cast<B, Int> for DTypewhere
B: Backend,
Backward-compatible impl: only int DType variants are accepted.
impl<B> Cast<B, Int> for DTypewhere
B: Backend,
Backward-compatible impl: only int DType variants are accepted.
§Panics
Panics if dtype is not an int variant (e.g., DType::F32).
Use FloatDType directly for cross-kind casting to float.