diff options
author | Laurent Mazare <laurent.mazare@gmail.com> | 2023-07-13 11:04:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-13 11:04:40 +0100 |
commit | 50b0946a2dff2a65f8319ff6d798f12b2ea2a6fb (patch) | |
tree | c48c4ecc686748e10b678d347af8d46cb0955a6c /candle-core/src/backprop.rs | |
parent | a3663ce2f2b03263075099baed677340974b7f4c (diff) | |
download | candle-50b0946a2dff2a65f8319ff6d798f12b2ea2a6fb.tar.gz candle-50b0946a2dff2a65f8319ff6d798f12b2ea2a6fb.tar.bz2 candle-50b0946a2dff2a65f8319ff6d798f12b2ea2a6fb.zip |
Tensor mutability (#154)
* Working towards tensor mutability.
* Use a ref-cell to provide tensor mutability.
Diffstat (limited to 'candle-core/src/backprop.rs')
-rw-r--r-- | candle-core/src/backprop.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/candle-core/src/backprop.rs b/candle-core/src/backprop.rs index 46a2c8de..61a81be0 100644 --- a/candle-core/src/backprop.rs +++ b/candle-core/src/backprop.rs @@ -222,7 +222,7 @@ impl Tensor { } else { let mut dims = arg_dims.to_vec(); dims[dim] = start_idx; - Some(Tensor::zeros(dims, grad.dtype(), &grad.device())?) + Some(Tensor::zeros(dims, grad.dtype(), grad.device())?) }; let right_pad = arg_dims[dim] - start_idx - len; let right_pad = if right_pad == 0 { @@ -230,7 +230,7 @@ impl Tensor { } else { let mut dims = arg_dims.to_vec(); dims[dim] = right_pad; - Some(Tensor::zeros(dims, grad.dtype(), &grad.device())?) + Some(Tensor::zeros(dims, grad.dtype(), grad.device())?) }; let arg_grad = match (left_pad, right_pad) { (None, None) => grad, @@ -264,7 +264,7 @@ impl Tensor { } Op::ToDevice(arg) => { let sum_grad = grads.or_insert(arg)?; - let arg_grad = grad.to_device(&sum_grad.device())?; + let arg_grad = grad.to_device(sum_grad.device())?; *sum_grad = sum_grad.add(&arg_grad)? } Op::Transpose(arg, dim1, dim2) => { |