diff options
author | Laurent Mazare <laurent.mazare@gmail.com> | 2023-07-08 08:39:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-08 08:39:27 +0100 |
commit | 33479c5f1b98a6e9f537ea139449bb8dc26fed3e (patch) | |
tree | d4b78d20f7ce5457a8596d46a92f39ad184b672a /candle-core/examples/cuda_basics.rs | |
parent | f35cfc5e976d454541dcc66934aa97969a08595f (diff) | |
download | candle-33479c5f1b98a6e9f537ea139449bb8dc26fed3e.tar.gz candle-33479c5f1b98a6e9f537ea139449bb8dc26fed3e.tar.bz2 candle-33479c5f1b98a6e9f537ea139449bb8dc26fed3e.zip |
Add some very simple sum benchmark. (#108)
* Add some very simple sum benchmark.
* Rename the file.
Diffstat (limited to 'candle-core/examples/cuda_basics.rs')
-rw-r--r-- | candle-core/examples/cuda_basics.rs | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/candle-core/examples/cuda_basics.rs b/candle-core/examples/cuda_basics.rs deleted file mode 100644 index 6050d793..00000000 --- a/candle-core/examples/cuda_basics.rs +++ /dev/null @@ -1,34 +0,0 @@ -#[cfg(feature = "mkl")] -extern crate intel_mkl_src; - -use anyhow::Result; -use candle::{Device, Tensor}; - -fn main() -> Result<()> { - let device = Device::new_cuda(0)?; - let ids = Tensor::new(&[0u32, 2u32, 1u32], &device)?; - let t = Tensor::new(&[[0f32, 1f32], [2f32, 3f32], [4f32, 5f32]], &device)?; - let hs = Tensor::embedding(&ids, &t)?; - println!("> {:?}", hs.to_vec2::<f32>()); - - 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 + x * 3.)?; - println!("{:?}", z.to_vec1::<f32>()?); - println!("{:?}", z.sqrt()?.to_vec1::<f32>()?); - let x = Tensor::new(&[[11f32, 22.], [33., 44.], [55., 66.], [77., 78.]], &device)?; - let y = Tensor::new(&[[1f32, 2., 3.], [4., 5., 6.]], &device)?; - println!("{:?}", y.to_vec2::<f32>()?); - let z = x.matmul(&y)?; - println!("{:?}", z.to_vec2::<f32>()?); - let x = Tensor::new( - &[[11f32, 22.], [33., 44.], [55., 66.], [77., 78.]], - &Device::Cpu, - )?; - let y = Tensor::new(&[[1f32, 2., 3.], [4., 5., 6.]], &Device::Cpu)?; - println!("{:?}", y.to_vec2::<f32>()?); - let z = x.matmul(&y)?; - println!("{:?}", z.to_vec2::<f32>()?); - Ok(()) -} |