提交 33fae103 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Add a test for GpuCAReduce

上级 955248cc
import unittest
from theano import scalar
from theano import scalar, gof
from theano.gof import FunctionGraph
from theano.gof.python25 import all, any
from theano.tests.unittest_tools import SkipTest
from theano.tensor.tests.test_elemwise import test_Broadcast, test_DimShuffle
from theano.tensor.tests.test_elemwise import (test_Broadcast, test_DimShuffle,
test_CAReduce)
from theano.sandbox.gpuarray.tests.test_basic_ops import rand_gpuarray
from theano.sandbox.gpuarray.elemwise import GpuElemwise, GpuDimShuffle
from theano.sandbox.gpuarray.elemwise import (GpuElemwise, GpuDimShuffle,
GpuCAReduce)
from theano.sandbox.gpuarray.type import GpuArrayType
from pygpu.array import gpuarray
......@@ -30,3 +33,26 @@ class test_gpu_Broadcast(test_Broadcast):
class test_GpuDimShuffle(test_DimShuffle):
op = GpuDimShuffle
class test_GpuCAReduce(test_CAReduce):
dtypes = ["float32"]
op = GpuCAReduce
reds = [scalar.add, scalar.mul]
def test_perform(self):
for dtype in self.dtypes + self.bin_dtypes:
for op in self.reds:
self.with_linker(gof.PerformLinker(), op, dtype=dtype)
def test_perform_nan(self):
raise SkipTest("for now")
for dtype in self.dtypes:
for op in self.reds:
self.with_linker(gof.PerformLinker(), op, dtype=dtype,
test_nan=True)
def test_c(self):
raise SkipTest("no C code")
def test_c_nan(self):
raise SkipTest("no C code")
......@@ -283,6 +283,7 @@ class test_Broadcast(unittest.TestCase):
class test_CAReduce(unittest_tools.InferShapeTester):
op = CAReduce
def with_linker(self, linker, scalar_op=scalar.add, dtype="floatX",
test_nan=False, tensor_op=None):
......@@ -305,7 +306,7 @@ class test_CAReduce(unittest_tools.InferShapeTester):
dtype = theano.config.floatX
x = TensorType(dtype, [(entry == 1) for entry in xsh])('x')
if tensor_op is None:
e = CAReduce(scalar_op, axis=tosum)(x)
e = self.op(scalar_op, axis=tosum)(x)
else:
e = tensor_op(x, axis=tosum)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论