mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 10:38:54 +00:00
Tensor mutability (#154)
* Working towards tensor mutability. * Use a ref-cell to provide tensor mutability.
This commit is contained in:
@ -27,12 +27,18 @@ fn matmul_grad(device: &Device) -> Result<()> {
|
||||
assert_eq!(grad_x.shape(), &Shape::from((2, 2, 3)));
|
||||
assert_eq!(grad_y.shape(), &Shape::from((2, 3, 2)));
|
||||
assert_eq!(
|
||||
&*grad_x.storage_data::<f32>()?,
|
||||
&[1., 5., 9., 1., 5., 9., 13., 17., 21., 13., 17., 21.]
|
||||
&*grad_x.to_vec3::<f32>()?,
|
||||
&[
|
||||
[[1., 5., 9.], [1., 5., 9.]],
|
||||
[[13., 17., 21.], [13., 17., 21.]]
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
&*grad_y.storage_data::<f32>()?,
|
||||
&[3., 3., 5., 5., 7., 7., 15., 15., 17., 17., 19., 19.]
|
||||
&*grad_y.to_vec3::<f32>()?,
|
||||
&[
|
||||
[[3., 3.], [5., 5.], [7., 7.]],
|
||||
[[15., 15.], [17., 17.], [19., 19.]]
|
||||
]
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user