Closed Andy3531 closed 1 year ago
Hi @Andy3531
Could you provide us with a reproducer for the original issue? I tried something naive and it seems to be working as intended.
Yes, if we run the following code,
size_t shape0[3]={512,512,4};
TensorXf tensor0(dr::zeros<typename TensorXf::Array>(512*512*4), 3, shape0);`
size_t shape1[3]={1,1,4};
TensorXf tensor1(dr::zeros<typename TensorXf::Array>(4), 3, shape1);
tensor0 = tensor0.mul_(tensor1);
we will get an error: Caught a critical exception: ArrayBase: out of range access (tried to access index 4 in an array of size 4)
where type TensorXf
is defined here
And similar problem is encountered in this issue: @Speierers in https://github.com/mitsuba-renderer/drjit/issues/85#issuecomment-1272843300_
It took me a while to figure it out, but I finally was able to reproduce this... So, in JIT variants this doesn't crash, but produces a potentially wrong output. Only in scalar mode does the error message appear.
The original code will fail on multipling two tensors of shape (512,512,4) and (1,1,4) because of the wrong recursive direction in the for loop.