Use a reference for the device.

This commit is contained in:
laurent
2023-06-21 19:55:57 +01:00
parent deb6091099
commit fcb4e6b84f
5 changed files with 23 additions and 20 deletions

View File

@ -3,7 +3,7 @@ use candle::{Device, Tensor};
#[test]
fn simple_grad() -> Result<()> {
let x = Tensor::var(&[3f32, 1., 4.], Device::Cpu)?;
let x = Tensor::var(&[3f32, 1., 4.], &Device::Cpu)?;
let y = (((&x * &x)? + &x * 5f64)? + 4f64)?;
let grads = y.backward()?;
let grad_x = grads.get(&x).context("no grad for x")?;