mirror of
https://github.com/huggingface/candle.git
synced 2025-06-22 20:38:06 +00:00
Fix the ?
operator cannot be applied to type Device
of example (#560)
According to the API: ```rust inp = inp.to_device(&Device::Cuda(0)?)?; ``` cannot work as `Cuda(...)` expects a type `Device` not an integer. I'd recommend to instead use `new_cuda(...)`
This commit is contained in:

committed by
GitHub

parent
508d34daf2
commit
3743bed2d7
@ -107,7 +107,7 @@ Cheatsheet:
|
||||
| Operations | `tensor.view((2, 2))` | `tensor.reshape((2, 2))?` |
|
||||
| Operations | `a.matmul(b)` | `a.matmul(&b)?` |
|
||||
| Arithmetic | `a + b` | `&a + &b` |
|
||||
| Device | `tensor.to(device="cuda")` | `tensor.to_device(&Device::Cuda(0))?` |
|
||||
| Device | `tensor.to(device="cuda")` | `tensor.to_device(&Device::new_cuda(0)?)?` |
|
||||
| Dtype | `tensor.to(dtype=torch.float16)` | `tensor.to_dtype(&DType::F16)?` |
|
||||
| Saving | `torch.save({"A": A}, "model.bin")` | `candle::safetensors::save(&HashMap::from([("A", A)]), "model.safetensors")?` |
|
||||
| Loading | `weights = torch.load("model.bin")` | `candle::safetensors::load("model.safetensors", &device)` |
|
||||
|
Reference in New Issue
Block a user