diff options
author | laurent <laurent.mazare@gmail.com> | 2023-06-22 11:01:49 +0100 |
---|---|---|
committer | laurent <laurent.mazare@gmail.com> | 2023-06-22 11:01:49 +0100 |
commit | 87a37b3bf3b6fd5034269c10c21c8f91e0223eb0 (patch) | |
tree | 7a25c28df9bb0eda94a89a61da95c8cdf0f55c06 /examples/cuda_basics.rs | |
parent | 083ced4428819f123ce8549ead9163055ac1ac64 (diff) | |
download | candle-87a37b3bf3b6fd5034269c10c21c8f91e0223eb0.tar.gz candle-87a37b3bf3b6fd5034269c10c21c8f91e0223eb0.tar.bz2 candle-87a37b3bf3b6fd5034269c10c21c8f91e0223eb0.zip |
Retrieve data from the gpu.
Diffstat (limited to 'examples/cuda_basics.rs')
-rw-r--r-- | examples/cuda_basics.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/cuda_basics.rs b/examples/cuda_basics.rs index 0a4825fa..046091a3 100644 --- a/examples/cuda_basics.rs +++ b/examples/cuda_basics.rs @@ -1,12 +1,14 @@ use anyhow::Result; -use candle::{Device, Tensor}; +use candle::{DType, Device, Tensor}; fn main() -> Result<()> { let device = Device::new_cuda(0)?; let x = Tensor::new(&[3f32, 1., 4., 1., 5.], &device)?; println!("{:?}", x.to_vec1::<f32>()?); - let y = Tensor::new(&[2f32, 7., 1., 8., 2.], &device)?; - let z = (y * 3.)?; - println!("{:?}", z.to_vec1::<f32>()?); + let x = Tensor::new(&[2f32, 7., 1., 8., 2.], &device)?; + let y = (x * 3.)?; + println!("{:?}", y.to_vec1::<f32>()?); + let x = Tensor::ones((3, 2), DType::F32, &device)?; + println!("{:?}", x.to_vec2::<f32>()?); Ok(()) } |