Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgOstrovski <ostrovski@google.com>2015-03-17 20:52:28 +0300
committerGeorgOstrovski <ostrovski@google.com>2015-03-17 20:52:28 +0300
commitf6c1b74a3d4205f5347a7f3c799bdc4b959717ec (patch)
treeab1c7f3bef8aa259f07918c7347986d64789831c /Tester.lua
parent6e07d525aefab634b28e2565fcdfa20bc04af45e (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.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/Tester.lua b/Tester.lua
index 42aef73..ebbe8a9 100644
--- a/Tester.lua
+++ b/Tester.lua
@@ -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)))