Skip to content

Commit 52abcdd

Browse files
Will Fengfacebook-github-bot
authored andcommitted
Fix out-of-range error for test_neg (#9431)
Summary: `test_neg` sometimes fails internally because `random_()` can generate an out-of-range value for CharTensor. This PR fixes it. Pull Request resolved: #9431 Reviewed By: SsnL Differential Revision: D8843284 Pulled By: yf225 fbshipit-source-id: bf516cceb8f780e133fa54f7364c77821eb7c013
1 parent e7f49d1 commit 52abcdd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/test_torch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ def _test_neg(self, cast):
10721072
if t in float_types:
10731073
a = cast(torch.randn(100, 90).type(t))
10741074
else:
1075-
a = cast(torch.Tensor(100, 90).type(t).random_())
1075+
a = cast(torch.Tensor(100, 90).type(t).random_(-128, 128))
10761076
zeros = cast(torch.Tensor().type(t)).resize_as_(a).zero_()
10771077

10781078
if t == 'torch.ByteTensor':

0 commit comments

Comments
 (0)