-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Problem with pointwise math when output tensor is zero-strided with correct size #289
Comments
There are probably many functions out there that use I agree that stride=0 is a problem for outputs though. Not sure how to fix it without checking for it in each function... |
The solution I proposed doesn't solve the problem. Actually, even if The way I see it, the problem lies within a = torch.rand(1,3):expand(3,3)
b = torch.rand(3,3)
a:resizeAs(b):copy(b); it outputs, as before th> print(a)
0.9823 0.1666 0.0679
0.9823 0.1666 0.0679
0.9823 0.1666 0.0679
[torch.DoubleTensor of size 3x3]
th> print(b)
0.3374 0.8114 0.3300
0.9484 0.8672 0.0940
0.9823 0.1666 0.0679
[torch.DoubleTensor of size 3x3] Would you expect this current behaviour to be correct ? |
When reusing a
Tensor
as the output of a pointwise math operation (likecmul
,add
,cdiv
etc), the result is not properly computed if the outputTensor
has zero stride and has the correct size.it outputs
This happens because the
THTensor_(resizeAs)
function doesn't take into account the fact that even though the sizes match, there can be a zero stride somewhere.Maybe a solution would be checking in
THTensor_(isSameSizeAs)
if there is one of the strides==0 and returning 0 in this case ? I don't know if there could be side effects though.The text was updated successfully, but these errors were encountered: