summaryrefslogtreecommitdiff
path: root/candle-core/src/backprop.rs
diff options
context:
space:
mode:
authorLaurent Mazare <laurent.mazare@gmail.com>2023-07-13 11:04:40 +0100
committerGitHub <noreply@github.com>2023-07-13 11:04:40 +0100
commit50b0946a2dff2a65f8319ff6d798f12b2ea2a6fb (patch)
treec48c4ecc686748e10b678d347af8d46cb0955a6c /candle-core/src/backprop.rs
parenta3663ce2f2b03263075099baed677340974b7f4c (diff)
downloadcandle-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.rs6
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) => {