提交 23d188f5 authored 作者: Frederic's avatar Frederic

Merge dnn conv desc correctly.

上级 c4ff11ff
...@@ -231,6 +231,9 @@ class GpuDnnConvDesc(GpuOp): ...@@ -231,6 +231,9 @@ class GpuDnnConvDesc(GpuOp):
def c_compiler(self): def c_compiler(self):
return NVCC_compiler return NVCC_compiler
def do_constant_folding(self, node):
return False
def __init__(self, border_mode, subsample=(1, 1), conv_mode='conv'): def __init__(self, border_mode, subsample=(1, 1), conv_mode='conv'):
if isinstance(border_mode, int): if isinstance(border_mode, int):
border_mode = (border_mode, border_mode) border_mode = (border_mode, border_mode)
......
...@@ -42,13 +42,30 @@ def test_dnn_conv_desc_merge(): ...@@ -42,13 +42,30 @@ def test_dnn_conv_desc_merge():
# CDataType is not DeepCopyable so this will crash if we don't use # CDataType is not DeepCopyable so this will crash if we don't use
# borrow=True # borrow=True
f = theano.function([], [theano.Out(desc1, borrow=True), f = theano.function([], [theano.Out(desc1, borrow=True),
theano.Out(desc2, borrow=True)]) theano.Out(desc2, borrow=True)],
mode=mode_with_gpu)
d1, d2 = f() d1, d2 = f()
# This will be the case if they are merged, which would be bad. # This will be the case if they are merged, which would be bad.
assert d1 != d2 assert d1 != d2
desc1v2 = dnn.GpuDnnConvDesc(border_mode='valid', subsample=(2, 2),
conv_mode='conv')(img_shp, kern_shp)
f = theano.function([], [theano.Out(desc1, borrow=True),
theano.Out(desc1v2, borrow=True)],
mode=mode_with_gpu)
assert len(f.maker.fgraph.apply_nodes)
theano.printing.debugprint(f)
# CDATA type don't equal even if they represent the same object
# So we can't use debugmode with it.
if theano.config.mode not in ["DebugMode", "DEBUG_MODE"]:
d1, d2 = f()
# This will be the case if they are merged, which would be bad.
assert d1 == d2
def test_dnn_conv_merge(): def test_dnn_conv_merge():
"""This test that we merge correctly multiple dnn_conv. """This test that we merge correctly multiple dnn_conv.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论