dfdx 0.9.0

Ergonomic auto differentiation in Rust, with pytorch like apis.
Documentation
1
2
3
4
5
6
7
8
9
10
11
use crate::prelude::*;

impl<T: Tensor<Dtype = f32>> CanUpdateWithGradients for T {
    /// Subtracts the gradient for the tensor from [HasArrayData::mut_data].
    fn update<G: GradientProvider>(&mut self, grads: &mut G, unused: &mut UnusedTensors) {
        match grads.gradient(self) {
            Some(gradient) => <Self as HasDevice>::Device::sub(self.mut_data(), gradient.as_ref()),
            None => unused.add(self),
        }
    }
}