diff options
author | GeorgOstrovski <ostrovski@google.com> | 2015-03-17 20:52:28 +0300 |
---|---|---|
committer | GeorgOstrovski <ostrovski@google.com> | 2015-03-17 20:52:28 +0300 |
commit | f6c1b74a3d4205f5347a7f3c799bdc4b959717ec (patch) | |
tree | ab1c7f3bef8aa259f07918c7347986d64789831c /Tester.lua | |
parent | 6e07d525aefab634b28e2565fcdfa20bc04af45e (diff) |
fix assertTensorEq for case of empty tensors
The case of empty tensors was handled wrongly: leading to exception. In the test of torch.maskedSelect and similar the case of an empty tensor can occur, leading to occasional test failures.
Diffstat (limited to 'Tester.lua')
-rw-r--r-- | Tester.lua | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -53,6 +53,9 @@ function Tester:assertne (val, condition, message) end function Tester:assertTensorEq(ta, tb, condition, message) + if ta:dim() == 0 and tb:dim() == 0 then + return + end local diff = ta-tb local err = diff:abs():max() self:assert_sub(err<condition,string.format('%s\n%s val=%s, condition=%s',(message or ''),' TensorEQ(==) violation ', tostring(err), tostring(condition))) |