diff options
Diffstat (limited to 'candle-core/examples/basics.rs')
-rw-r--r-- | candle-core/examples/basics.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/candle-core/examples/basics.rs b/candle-core/examples/basics.rs index ad008177..fe15187b 100644 --- a/candle-core/examples/basics.rs +++ b/candle-core/examples/basics.rs @@ -8,11 +8,10 @@ use anyhow::Result; use candle_core::{Device, Tensor}; fn main() -> Result<()> { - let inp = Tensor::randn(0f32, 1., (2, 320, 96, 96), &Device::Cpu)?; - let w = Tensor::randn(0f32, 1., (320, 320, 3, 3), &Device::Cpu)?; - let start = std::time::Instant::now(); - let res = inp.conv2d(&w, 0, 1, 1, 1)?; - println!("{:?}", start.elapsed()); - println!("{res:?}"); + let a = Tensor::new(&[[0.0f32, 1.0, 2.0], [3.0, 4.0, 5.0]], &Device::Cpu)?; + let b = Tensor::new(&[[88.0f32, 99.0]], &Device::Cpu)?; + let new_a = a.slice_scatter(&b, 1, 2)?; + assert_eq!(a.to_vec2::<f32>()?, [[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]); + assert_eq!(new_a.to_vec2::<f32>()?, [[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]); Ok(()) } |