Add a currently wrong test for narrow.

This commit is contained in:
laurent
2023-06-24 08:50:37 +01:00
parent d6cb4f1c53
commit 1b5f892d73
2 changed files with 16 additions and 2 deletions

View File

@ -1,3 +1,4 @@
// TODO: Also test the cuda backend.
use candle::{DType, Device, Result, Tensor};
#[test]
@ -106,3 +107,15 @@ fn softmax() -> Result<()> {
);
Ok(())
}
#[test]
fn narrow() -> Result<()> {
let data = &[[[3f32, 1., 4.], [1., 5., 9.]], [[2., 1., 7.], [8., 2., 8.]]];
let tensor = Tensor::new(data, &Device::Cpu)?;
assert_eq!(
tensor.narrow(2, 1, 2)?.to_vec3::<f32>()?,
// TODO: this is broken at the moment!
&[[[1., 4.], [1., 5.]], [[9., 2.], [1., 7.]]]
);
Ok(())
}