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