提交 629191e8 authored 作者: Harm de Vries's avatar Harm de Vries

solve conflicts

...@@ -40,9 +40,9 @@ def raise_no_cudnn(msg="CuDNN is required for convolution and pooling"): ...@@ -40,9 +40,9 @@ def raise_no_cudnn(msg="CuDNN is required for convolution and pooling"):
def _dnn_check_compile(): def _dnn_check_compile():
preambule = """ preambule = """
#include <stdio.h> # include <stdio.h>
#include <cudnn.h> # include <cudnn.h>
#include <cudnn_helper.h> # include <cudnn_helper.h>
""" """
# No need for the context in here since we won't execute that code # No need for the context in here since we won't execute that code
...@@ -201,9 +201,9 @@ class DnnVersion(Op): ...@@ -201,9 +201,9 @@ class DnnVersion(Op):
def c_support_code(self): def c_support_code(self):
return """ return """
#if PY_MAJOR_VERSION >= 3 # if PY_MAJOR_VERSION >= 3
#define PyInt_FromLong PyLong_FromLong # define PyInt_FromLong PyLong_FromLong
#endif # endif
""" """
def make_node(self): def make_node(self):
...@@ -1077,6 +1077,11 @@ class GpuDnnPool(DnnBase): ...@@ -1077,6 +1077,11 @@ class GpuDnnPool(DnnBase):
if mode == 'average': if mode == 'average':
mode = 'average_inc_pad' mode = 'average_inc_pad'
assert mode in ('max', 'average_inc_pad', 'average_exc_pad') assert mode in ('max', 'average_inc_pad', 'average_exc_pad')
<< << << < HEAD
== == == =
if version() == -1:
raise Exception("cudnn v1 do not support average_exc_pad")
>>>>>> > cb3fbfe94620d4938c10ac2e20d43f8a286e3856
self.mode = mode self.mode = mode
def get_op_params(self): def get_op_params(self):
......
...@@ -284,8 +284,8 @@ def test_pooling_with_tensor_vars(): ...@@ -284,8 +284,8 @@ def test_pooling_with_tensor_vars():
mode = 'max' mode = 'max'
def fn(x): def fn(x):
dnn_op = dnn.dnn_pool( dnn_op = dnn.dnn_pool(x,
x, ws=ws, ws=ws,
stride=st, stride=st,
pad=pad, pad=pad,
mode=mode) mode=mode)
...@@ -299,32 +299,28 @@ def test_pooling_with_tensor_vars(): ...@@ -299,32 +299,28 @@ def test_pooling_with_tensor_vars():
cast_to_output_type=False, cast_to_output_type=False,
mode=mode_with_gpu) mode=mode_with_gpu)
out2 = pool_2d_i2n(x, ds=(2, 2), strides=(1, 1),
pad=(0, 0),
pool_function=T.max)
mode_without_gpu2 = mode_without_gpu.including() mode_without_gpu2 = mode_without_gpu.including()
mode_without_gpu2.check_isfinite = False mode_without_gpu2.check_isfinite = False
f_gpu = theano.function([x], fn(x), mode=mode_with_gpu) f1 = theano.function([x], fn(x), mode=mode_with_gpu)
assert any([isinstance(node.op, dnn.GpuDnnPool) assert any([isinstance(node.op, dnn.GpuDnnPool)
for node in f_gpu.maker.fgraph.apply_nodes]) for node in f1.maker.fgraph.apply_nodes])
f2 = theano.function([x], out2, mode=mode_without_gpu2)
i = 1 assert not any([isinstance(node.op, dnn.GpuDnnPool)
for node in f2.maker.fgraph.apply_nodes])
for shp in [(1, 10, 100, 100), for shp in [(1, 10, 100, 100),
(1, 3, 99, 99), (1, 3, 99, 99),
(32, 1, 147, 197)]: (32, 1, 147, 197),
]:
data = numpy.random.normal(0, 1, shp).astype("float32") data = numpy.random.normal(0, 1, shp).astype("float32")
out = pool_2d_i2n(x, ds=(i, i), strides=(1, 1), a = f1(data).__array__()
pad=(0, 0),
pool_function=T.max)
f_cpu = theano.function([x], out, mode=mode_without_gpu2)
assert not any([isinstance(node.op, dnn.GpuDnnPool)
for node in f_cpu.maker.fgraph.apply_nodes])
# Change the window size dynamically for gpu op b = f2(data).__array__()
ws.set_value(numpy.array([i, i]).astype('int32'))
a = f_gpu(data).__array__()
b = f_cpu(data).__array__()
utt.assert_allclose(a, b) utt.assert_allclose(a, b)
i += 1
def test_pooling_opt(): def test_pooling_opt():
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论