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

github.com/torch/cutorch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPavan Yalamanchili <pyalamanchili@twitter.com>2017-02-10 05:11:58 +0300
committerPavan Yalamanchili <pyalamanchili@twitter.com>2017-02-10 05:11:58 +0300
commit428d4ad91777b584d431c9e9f478db15bdf47da4 (patch)
treef76e07462c0c0dd86ae1a0d1bd1566a47f9e65b7 /test
parent45921791a009dcd0f6876830d4cb484d0bcd1c6f (diff)
Adding bitwise operations
- lshift, rshift, bitand, bitor, bitxor
Diffstat (limited to 'test')
-rw-r--r--test/test.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua
index 32918b1..d18fba9 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -904,6 +904,35 @@ function test.add()
checkMultiDevice(x, 'add', y, v, z)
end
+local test_bitops = function(funcname, tmin, tmax, vmin, vmax)
+ local sz1 = chooseInt(minsize, maxsize)
+ local sz2 = chooseInt(minsize, maxsize)
+ local x = torch.IntTensor(sz1, sz2):random(tmin, tmax)
+ local v = torch.random(vmin, vmax)
+ compareCPUAndCUDATypeTensorArgs('torch.CudaIntTensor', nil, x, funcname, v)
+ checkMultiDevice(x, funcname, v)
+end
+
+function test.lshift()
+ test_bitops('lshift', 1, 1000, 1, 10)
+end
+
+function test.rshift()
+ test_bitops('rshift', 1000, 1000000, 1, 10)
+end
+
+function test.bitand()
+ test_bitops('bitand', 1, 1000, 1, 255)
+end
+
+function test.bitor()
+ test_bitops('bitor', 1, 1000, 1, 255)
+end
+
+function test.bitxor()
+ test_bitops('bitxor', 1, 1000, 1, 255)
+end
+
function test.csub()
local sz1 = chooseInt(minsize, maxsize)
local sz2 = chooseInt(minsize, maxsize)