You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following snippet causes numeric overflow in JIT if x is uint8:
definvert(x):
bound=255.0returnbound-x# Overflow happens here due to -x when uint8x=torch.randint(0, 256, (10, 10), dtype=torch.uint8)
script_invert=torch.jit.script(invert)
invert(x).equal(script_invert(x)) # False
We can avoid it if we define the invert differently:
definvert2(x):
bound=255.0return-(x-bound) # Avoids underflow because x is casted to float before negatedscript_invert2=torch.jit.script(invert2)
invert2(x).equal(script_invert2(x)) # True
Expected behavior
The two implementations should yield equivalent results. The invert() should return the same result either it's scripted or not.
馃悰 Bug
To Reproduce
The following snippet causes numeric overflow in JIT if x is
uint8
:We can avoid it if we define the invert differently:
Expected behavior
The two implementations should yield equivalent results. The
invert()
should return the same result either it's scripted or not.cc @gmagogsfm
The text was updated successfully, but these errors were encountered: