提交 58e9b7fb authored 作者: Frederic's avatar Frederic

Skip elemwise tests with c linker with opencl back-end.

上级 9adb3026
...@@ -21,14 +21,17 @@ class test_gpu_Broadcast(test_Broadcast): ...@@ -21,14 +21,17 @@ class test_gpu_Broadcast(test_Broadcast):
type = GpuArrayType type = GpuArrayType
cop = GpuElemwise cop = GpuElemwise
ctype = GpuArrayType ctype = GpuArrayType
# The order is important
linkers = [gof.PerformLinker, gof.CLinker]
def setUp(self):
dev = theano.sandbox.gpuarray.init_dev.device
if not dev.startswith('cuda'):
self.linkers = [gof.PerformLinker]
def rand_val(self, shp): def rand_val(self, shp):
return rand_gpuarray(*shp, **dict(cls=gpuarray)) return rand_gpuarray(*shp, **dict(cls=gpuarray))
# no c_code() yet
#cop = GpuElemwise
#ctype = GpuArrayType
def rand_cval(self, shp): def rand_cval(self, shp):
return rand_gpuarray(*shp, **dict(cls=gpuarray)) return rand_gpuarray(*shp, **dict(cls=gpuarray))
......
...@@ -158,6 +158,9 @@ class test_Broadcast(unittest.TestCase): ...@@ -158,6 +158,9 @@ class test_Broadcast(unittest.TestCase):
openmp_minsize = 2*config.openmp_elemwise_minsize openmp_minsize = 2*config.openmp_elemwise_minsize
openmp_minsize_sqrt = math.ceil(math.sqrt(openmp_minsize)) openmp_minsize_sqrt = math.ceil(math.sqrt(openmp_minsize))
# The order is important if you change them.
linkers = [gof.PerformLinker, gof.CLinker]
def rand_val(self, shp): def rand_val(self, shp):
return numpy.asarray(numpy.random.rand(*shp)) return numpy.asarray(numpy.random.rand(*shp))
...@@ -262,12 +265,13 @@ class test_Broadcast(unittest.TestCase): ...@@ -262,12 +265,13 @@ class test_Broadcast(unittest.TestCase):
raise SkipTest("G++ not available, so we need to skip this test.") raise SkipTest("G++ not available, so we need to skip this test.")
x = self.ctype('float64', [0, 0])('x') x = self.ctype('float64', [0, 0])('x')
y = self.ctype('float64', [1, 1])('y') y = self.ctype('float64', [1, 1])('y')
e = self.cop(scalar.Second(scalar.transfer_type(0)), {0: 0})(x, y) for linker, op in zip(self.linkers, [self.op, self.cop]):
f = gof.CLinker().accept(FunctionGraph([x, y], [e])).make_function() e = op(scalar.Second(scalar.transfer_type(0)), {0: 0})(x, y)
xv = self.rand_cval((5, 5)) f = linker().accept(FunctionGraph([x, y], [e])).make_function()
yv = self.rand_cval((1, 1)) xv = self.rand_cval((5, 5))
f(xv, yv) yv = self.rand_cval((1, 1))
assert (xv == yv).all() f(xv, yv)
assert (xv == yv).all()
def test_fill_var(self): def test_fill_var(self):
x = tensor.matrix() x = tensor.matrix()
...@@ -286,22 +290,24 @@ class test_Broadcast(unittest.TestCase): ...@@ -286,22 +290,24 @@ class test_Broadcast(unittest.TestCase):
raise SkipTest("G++ not available, so we need to skip this test.") raise SkipTest("G++ not available, so we need to skip this test.")
x = self.ctype('float64', [0, 0, 0, 0, 0])('x') x = self.ctype('float64', [0, 0, 0, 0, 0])('x')
y = self.ctype('float64', [0, 0, 0, 0, 0])('y') y = self.ctype('float64', [0, 0, 0, 0, 0])('y')
e = self.cop(scalar.add)(x, y) for linker, op in zip(self.linkers, [self.op, self.cop]):
f = gof.CLinker().accept(FunctionGraph([x, y], [e])).make_function() e = op(scalar.add)(x, y)
xv = self.rand_cval((2, 2, 2, 2, 2)) f = linker().accept(FunctionGraph([x, y], [e])).make_function()
yv = self.rand_cval((2, 2, 2, 2, 2)).transpose(4, 0, 3, 1, 2) xv = self.rand_cval((2, 2, 2, 2, 2))
zv = xv + yv yv = self.rand_cval((2, 2, 2, 2, 2)).transpose(4, 0, 3, 1, 2)
assert (f(xv, yv) == zv).all() zv = xv + yv
assert (f(xv, yv) == zv).all()
def test_same_inputs(self): def test_same_inputs(self):
if not theano.config.cxx: if not theano.config.cxx:
raise SkipTest("G++ not available, so we need to skip this test.") raise SkipTest("G++ not available, so we need to skip this test.")
x = self.ctype('float64', [0, 0])('x') x = self.ctype('float64', [0, 0])('x')
e = self.cop(scalar.add)(x, x) for linker, op in zip(self.linkers, [self.op, self.cop]):
f = gof.CLinker().accept(FunctionGraph([x], [e])).make_function() e = op(scalar.add)(x, x)
xv = self.rand_cval((2, 2)) f = linker().accept(FunctionGraph([x], [e])).make_function()
zv = xv + xv xv = self.rand_cval((2, 2))
assert (f(xv) == zv).all() zv = xv + xv
assert (f(xv) == zv).all()
class test_CAReduce(unittest_tools.InferShapeTester): class test_CAReduce(unittest_tools.InferShapeTester):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论