pub trait Cast<B: Backend, K: TensorKind<B>> {
type OutputKind: TensorKind<B>;
// Required method
fn cast(
primitive: K::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::Primitive,
dtype: Self,
) -> <Self::OutputKind as TensorKind<B>>::Primitive
fn cast( primitive: K::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".
Implementors§
Source§impl<B: Backend> Cast<B, Bool> for FloatDType
impl<B: Backend> Cast<B, Bool> for FloatDType
type OutputKind = Float
Source§impl<B: Backend> Cast<B, Float> for DType
Backward-compatible impl: only float DType variants are accepted.
impl<B: Backend> Cast<B, Float> for DType
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: Backend> Cast<B, Float> for FloatDType
impl<B: Backend> Cast<B, Float> for FloatDType
type OutputKind = Float
Source§impl<B: Backend> Cast<B, Int> for DType
Backward-compatible impl: only int DType variants are accepted.
impl<B: Backend> Cast<B, Int> for DType
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.