Trait DifferentiableTransfer
pub trait DifferentiableTransfer<Src, Dst>:
Send
+ Debug
+ 'static{
// Required methods
fn forward(
tensor: <Src as BackendTypes>::FloatTensorPrimitive,
device: &<Dst as BackendTypes>::Device,
) -> <Dst as BackendTypes>::FloatTensorPrimitive;
fn backward(
tensor: <Dst as BackendTypes>::FloatTensorPrimitive,
device: &<Src as BackendTypes>::Device,
) -> <Src as BackendTypes>::FloatTensorPrimitive;
}Expand description
Transfers plain floating-point primitives between two backends for a recorded operation.
Both directions must preserve shape, dtype, and values on the requested device. The backward direction transfers the incoming gradient, not the original forward input. Implementations choose the transfer mechanism independently in each direction.
Required Methods§
fn forward(
tensor: <Src as BackendTypes>::FloatTensorPrimitive,
device: &<Dst as BackendTypes>::Device,
) -> <Dst as BackendTypes>::FloatTensorPrimitive
fn forward( tensor: <Src as BackendTypes>::FloatTensorPrimitive, device: &<Dst as BackendTypes>::Device, ) -> <Dst as BackendTypes>::FloatTensorPrimitive
Transfers values to the destination backend.
fn backward(
tensor: <Dst as BackendTypes>::FloatTensorPrimitive,
device: &<Src as BackendTypes>::Device,
) -> <Src as BackendTypes>::FloatTensorPrimitive
fn backward( tensor: <Dst as BackendTypes>::FloatTensorPrimitive, device: &<Src as BackendTypes>::Device, ) -> <Src as BackendTypes>::FloatTensorPrimitive
Transfers gradients back to the source backend.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".