diff options
author | Pavan Yalamanchili <pyalamanchili@twitter.com> | 2017-02-10 06:05:52 +0300 |
---|---|---|
committer | Pavan Yalamanchili <pyalamanchili@twitter.com> | 2017-02-23 01:05:14 +0300 |
commit | fc3e682f6044f429c2dbc3b733e0b8b670338ad2 (patch) | |
tree | 369b5f4e6dbef021413ce3874c86f45af883aad3 /test | |
parent | 8c4708a66ff5fa9935fad7e352e8c3e869e3fb43 (diff) |
Adding test for bitxor
Diffstat (limited to 'test')
-rw-r--r-- | test/test.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua index ef3013e..3cb4166 100644 --- a/test/test.lua +++ b/test/test.lua @@ -900,6 +900,20 @@ function torchtest.bitor() mytester:assertlt(err, precision, 'error in torch.bitor - scalar, contiguous') end +function torchtest.cbitxor() + local t1 = torch.LongTensor(10,10):random(0,10000) + local t2 = torch.LongTensor(10,10):random(10001,20000) + + -- Perform xor swap and check results + local t3 = torch.cbitxor(t1, t2) + local r1 = torch.cbitxor(t3, t2) + local r2 = torch.cbitxor(t3, t1) + + local err1 = (r1 - t1):abs():max() + local err2 = (r2 - t2):abs():max() + mytester:assertlt(err1 + err2, precision, 'error in torch.cbitxor contiguous') +end + function torchtest.mm() -- helper function local function matrixmultiply(mat1,mat2) |