use burn::backend::{Autodiff, Wgpu}; use burn::tensor::{Distribution, Tensor}; fn main() { type Backend = Autodiff; let x: Tensor = Tensor::random([32, 32], Distribution::Default); let y: Tensor = Tensor::random([32, 32], Distribution::Default).require_grad(); let tmp = x.clone() + y.clone(); let tmp = tmp.matmul(x); let tmp = tmp.exp(); let grads = tmp.backward(); let y_grad = y.grad(&grads).unwrap(); println!("{y_grad}");