-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong result when call reshape() after Tensor::stack #1053
Comments
Seems the bug of The print result of test code with cat// after cat
Tensor {
data:
[[[1, 0],
[2, 0],
[3, 0],
[4, 0],
[5, 0],
[6, 0]],
[[7, 0],
[8, 0],
[9, 0],
[10, 0],
[11, 0],
[12, 0]],
[[13, 0],
[14, 0],
[15, 0],
[16, 0],
[17, 0],
[18, 0]],
[[19, 0],
[20, 0],
[21, 0],
[22, 0],
[23, 0],
[24, 0]]],
shape: [4, 6, 2],
device: Cpu,
backend: "ndarray",
kind: "Int",
dtype: "i64",
}
// after calling reshape
Tensor {
data:
[[1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0],
[7, 8, 9, 10, 11, 12, 0, 0, 0, 0, 0, 0],
[13, 14, 15, 16, 17, 18, 0, 0, 0, 0, 0, 0],
[19, 20, 21, 22, 23, 24, 0, 0, 0, 0, 0, 0]],
shape: [4, 12],
device: Cpu,
backend: "ndarray",
kind: "Int",
dtype: "i64",
} the result from dummy reshape code// created from from_ints(...)
Tensor {
data:
[[[1, 0],
[2, 0],
[3, 0],
[4, 0],
[5, 0],
[6, 0]],
[[7, 0],
[8, 0],
[9, 0],
[10, 0],
[11, 0],
[12, 0]],
[[13, 0],
[14, 0],
[15, 0],
[16, 0],
[17, 0],
[18, 0]],
[[19, 0],
[20, 0],
[21, 0],
[22, 0],
[23, 0],
[24, 0]]],
shape: [4, 6, 2],
device: Cpu,
backend: "ndarray",
kind: "Int",
dtype: "i64",
}
// after calling reshape
Tensor {
data:
[[1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0],
[7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0],
[13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0],
[19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0]],
shape: [4, 12],
device: Cpu,
backend: "ndarray",
kind: "Int",
dtype: "i64",
} dummy reshape code #[test]
fn test_bug_2() {
use burn_tensor::{Int, Tensor};
type Backend = crate::NdArray;
let intersperse: Tensor<Backend, 3, Int> = Tensor::from_ints([
[[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0]],
[[7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0]],
[[13, 0], [14, 0], [15, 0], [16, 0], [17, 0], [18, 0]],
[[19, 0], [20, 0], [21, 0], [22, 0], [23, 0], [24, 0]],
]);
println!("{}", intersperse);
let intersperse = intersperse.reshape([4, 12]);
println!("{}", intersperse);
} |
@AuruTus Thanks for your investigation! However, this bug is not likely caused by For burn, I believe using |
Hi @wcshds . Thanks for the reply. Then I understand why this weird thing will happen. The Indeed, |
I investigate the code again. And I find that actually we have a row major layout check in the macro I ran the |
Here is the code.
The result is:
But the expected result should be:
I can get correct results on LibTorch Backend and Wgpu Backend.
The text was updated successfully, but these errors were encountered: