Skip to content

Commit

Permalink
fix basics example
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma Jian committed Dec 24, 2024
1 parent 11aa30b commit d40a2d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions candle-core/examples/basics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use candle_core::{Device, Tensor};

fn main() -> Result<()> {
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 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]]);
assert_eq!(new_a.to_vec2::<f32>()?, [[0.0, 1.0, 88.0], [3.0, 4.0, 99.0]]);
Ok(())
}

0 comments on commit d40a2d8

Please sign in to comment.