提交 97fe07f0 authored 作者: Laurent Dinh's avatar Laurent Dinh

Several optimizations possible

上级 6877f6fb
...@@ -91,8 +91,8 @@ class TestConv2d(unittest.TestCase): ...@@ -91,8 +91,8 @@ class TestConv2d(unittest.TestCase):
f = theano.function([], c, mode) f = theano.function([], c, mode)
if target_op is not None: if target_op is not None:
assert any([isinstance(n.op, target_op) for n assert any([isinstance(n.op, target_op) for n
in f.maker.fgraph.toposort()]) in f.maker.fgraph.toposort()])
res_ref = numpy.array(f_ref()) res_ref = numpy.array(f_ref())
res = numpy.array(f()) res = numpy.array(f())
...@@ -140,8 +140,8 @@ class TestConv2d(unittest.TestCase): ...@@ -140,8 +140,8 @@ class TestConv2d(unittest.TestCase):
f_ref = theano.function([], c_ref, mode) f_ref = theano.function([], c_ref, mode)
if target_op is not None: if target_op is not None:
assert any([isinstance(n.op, target_op) for n assert any([isinstance(n.op, target_op) for n
in f.maker.fgraph.toposort()]) in f.maker.fgraph.toposort()])
res_ref = numpy.array(f_ref()) res_ref = numpy.array(f_ref())
res = numpy.array(f()) res = numpy.array(f())
...@@ -192,8 +192,8 @@ class TestConv2d(unittest.TestCase): ...@@ -192,8 +192,8 @@ class TestConv2d(unittest.TestCase):
f_ref = theano.function([], c_ref, mode) f_ref = theano.function([], c_ref, mode)
if target_op is not None: if target_op is not None:
assert any([isinstance(n.op, target_op) for n assert any([isinstance(n.op, target_op) for n
in f.maker.fgraph.toposort()]) in f.maker.fgraph.toposort()])
res_ref = numpy.array(f_ref()) res_ref = numpy.array(f_ref())
res = numpy.array(f()) res = numpy.array(f())
...@@ -249,7 +249,10 @@ class TestConv2d(unittest.TestCase): ...@@ -249,7 +249,10 @@ class TestConv2d(unittest.TestCase):
self.run_fwd(inputs_shape=i, filters_shape=f, subsample=s, self.run_fwd(inputs_shape=i, filters_shape=f, subsample=s,
verify_grad=True, mode=mode, device='gpu', verify_grad=True, mode=mode, device='gpu',
provide_shape=provide_shape, border_mode=b, provide_shape=provide_shape, border_mode=b,
filter_flip=flip, target_op=GpuCorrMM) filter_flip=flip,
target_op=(GpuCorrMM,
GpuCorrMM_gradWeights,
GpuCorrMM_gradInputs))
self.run_gradweight(inputs_shape=i, filters_shape=f, self.run_gradweight(inputs_shape=i, filters_shape=f,
output_shape=o, subsample=s, output_shape=o, subsample=s,
verify_grad=True, mode=mode, device='gpu', verify_grad=True, mode=mode, device='gpu',
......
...@@ -10,10 +10,10 @@ import theano.tensor.nnet.abstract_conv as conv ...@@ -10,10 +10,10 @@ import theano.tensor.nnet.abstract_conv as conv
from theano.compile import shared as cpu_shared from theano.compile import shared as cpu_shared
from ..type import gpuarray_shared_constructor as gpu_shared from ..type import gpuarray_shared_constructor as gpu_shared
from ..dnn import ( from ..dnn import (
dnn_available, dnn_conv, dnn_gradweight, dnn_gradinput, dnn_available, dnn_conv, dnn_gradweight, dnn_gradinput,
GpuDnnConv, GpuDnnConvGradW, GpuDnnConvGradI) GpuDnnConv, GpuDnnConvGradW, GpuDnnConvGradI)
from theano.tensor.nnet.corr import ( from theano.tensor.nnet.corr import (
CorrMM, CorrMM_gradWeights, CorrMM_gradInputs) CorrMM, CorrMM_gradWeights, CorrMM_gradInputs)
from theano.tensor.nnet.conv import ConvOp from theano.tensor.nnet.conv import ConvOp
from theano.tensor.nnet import ConvGrad3D, ConvTransp3D from theano.tensor.nnet import ConvGrad3D, ConvTransp3D
...@@ -85,8 +85,8 @@ class TestConv2d(unittest.TestCase): ...@@ -85,8 +85,8 @@ class TestConv2d(unittest.TestCase):
f = theano.function([], c, mode) f = theano.function([], c, mode)
if target_op is not None: if target_op is not None:
assert any([isinstance(n.op, target_op) for n assert any([isinstance(n.op, target_op) for n
in f.maker.fgraph.toposort()]) in f.maker.fgraph.toposort()])
res_ref = numpy.array(f_ref()) res_ref = numpy.array(f_ref())
res = numpy.array(f()) res = numpy.array(f())
...@@ -134,8 +134,8 @@ class TestConv2d(unittest.TestCase): ...@@ -134,8 +134,8 @@ class TestConv2d(unittest.TestCase):
f_ref = theano.function([], c_ref, mode) f_ref = theano.function([], c_ref, mode)
if target_op is not None: if target_op is not None:
assert any([isinstance(n.op, target_op) for n assert any([isinstance(n.op, target_op) for n
in f.maker.fgraph.toposort()]) in f.maker.fgraph.toposort()])
res_ref = numpy.array(f_ref()) res_ref = numpy.array(f_ref())
res = numpy.array(f()) res = numpy.array(f())
...@@ -184,8 +184,8 @@ class TestConv2d(unittest.TestCase): ...@@ -184,8 +184,8 @@ class TestConv2d(unittest.TestCase):
f_ref = theano.function([], c_ref, mode) f_ref = theano.function([], c_ref, mode)
if target_op is not None: if target_op is not None:
assert any([isinstance(n.op, target_op) for n assert any([isinstance(n.op, target_op) for n
in f.maker.fgraph.toposort()]) in f.maker.fgraph.toposort()])
res_ref = numpy.array(f_ref()) res_ref = numpy.array(f_ref())
res = numpy.array(f()) res = numpy.array(f())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论