You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let a = Tensor::new(&[3u8], &candle::Device::Cpu)?;
let b = a / 4f64;
What's the value of tensor b? Wow, it's Ok(Tensor[0; u8]). Rust compiler rejects code like 3u8 / 4f64, while it's legal in tensor operation but return wrong result.
I can say these lines are wrong for cifar dataset, and all image here are just all zero u8.
It's kind of by design though I agree that it's not ideal. The Tensor type does not expose the tensor dtypes so we cannot really express the constraints of a scalar multiplication or addition at run time. Still it's quite convenient to be able to say multiply the values in the tensor by a constant or add a constant, so affine operations using a f64 are supported for all tensors with "rounded" semantics.
What's the value of tensor
b
? Wow, it'sOk(Tensor[0; u8])
. Rust compiler rejects code like3u8 / 4f64
, while it's legal in tensor operation but return wrong result.I can say these lines are wrong for cifar dataset, and all image here are just all zero u8.
candle/candle-datasets/src/vision/cifar.rs
Lines 84 to 86 in 8a05743
Any insights on compiler check for operation on different type tensor? Or it's by design? @LaurentMazare
The text was updated successfully, but these errors were encountered: