mirror of
https://github.com/huggingface/candle.git
synced 2025-06-17 02:58:50 +00:00
Use a reference for the device.
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
use anyhow::Result;
|
||||
use candle::{DType, Device, Tensor};
|
||||
use candle::{Device, Tensor};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let device = Device::new_cuda(0)?;
|
||||
let x = Tensor::zeros(4, DType::F32, device)?;
|
||||
let x = Tensor::new(&[3f32, 1., 4., 1., 5.], &device)?;
|
||||
let y = Tensor::new(&[2f32, 7., 1., 8., 2.], &device)?;
|
||||
println!("{:?}", x.to_vec1::<f32>()?);
|
||||
let z = (x + y)?;
|
||||
println!("{:?}", z.to_vec1::<f32>()?);
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user