提交 919b5b0e authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Add test for noncontiguous strides.

上级 2a9156a9
...@@ -18,7 +18,7 @@ from theano.tensor.nnet import bn ...@@ -18,7 +18,7 @@ from theano.tensor.nnet import bn
from .. import dnn from .. import dnn
from ..basic_ops import GpuAllocEmpty from ..basic_ops import GpuAllocEmpty
from ..type import gpuarray_shared_constructor from ..type import gpuarray_shared_constructor, GpuArrayType
from .config import mode_with_gpu, mode_without_gpu, test_ctx_name, ref_cast from .config import mode_with_gpu, mode_without_gpu, test_ctx_name, ref_cast
from . import test_nnet from . import test_nnet
...@@ -26,6 +26,11 @@ from .rnn_support import Model, GRU, LSTM, WrapperLayer ...@@ -26,6 +26,11 @@ from .rnn_support import Model, GRU, LSTM, WrapperLayer
from theano.configdefaults import SUPPORTED_DNN_CONV_ALGO_FWD from theano.configdefaults import SUPPORTED_DNN_CONV_ALGO_FWD
try:
import pygpu
except ImportError:
pass
mode_with_gpu = mode_with_gpu.including() mode_with_gpu = mode_with_gpu.including()
# Globally disabled for mode_without_gpu # Globally disabled for mode_without_gpu
mode_with_gpu.check_py_code = False mode_with_gpu.check_py_code = False
...@@ -1506,6 +1511,22 @@ def test_dnn_reduction_opt(): ...@@ -1506,6 +1511,22 @@ def test_dnn_reduction_opt():
yield dnn_reduction, 2, idtype, adtype, odtype yield dnn_reduction, 2, idtype, adtype, odtype
def dnn_reduction_strides(shp, shuffle, slice):
inp = GpuArrayType('float32', (False,) * len(shp),
context_name=test_ctx_name)()
tmp = inp.dimshuffle(shuffle)[slice]
res = tmp.sum(acc_dtype='float32', dtype='float32')
f = theano.function([inp], res, mode=mode_with_gpu)
assert any(isinstance(n.op, dnn.GpuDnnReduction)
for n in f.maker.fgraph.apply_nodes)
f(pygpu.zeros(shp, dtype='float32', context=inp.type.context))
def test_dnn_reduction_strides():
yield dnn_reduction_strides, (2, 3, 2), (1, 0, 2), ...
yield dnn_reduction_strides, (2, 3, 2), (0, 1, 2), slice(None, None, -1)
def dnn_maxargmax(nd, idtype, axis): def dnn_maxargmax(nd, idtype, axis):
inp = T.TensorType(idtype, (False,) * nd)() inp = T.TensorType(idtype, (False,) * nd)()
res = T.max_and_argmax(inp, axis=axis) res = T.max_and_argmax(inp, axis=axis)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论