Skip to content

Commit

Permalink
first try
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Michalski committed Jan 22, 2016
1 parent dd41f3e commit a41fc8b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ distribute-*.tar.gz
Theano.suo
.ipynb_checkpoints
.pydevproject

.ropeproject
3 changes: 3 additions & 0 deletions theano/sandbox/gpuarray/tests/test_abstractconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def run_fwd(self, inputs_shape, filters_shape, ref=dnn_conv,
filter_flip=filter_flip,
input_shape=imshp,
filter_shape=kshp)
self.assertTrue(hasattr(c.tag, 'trace'))
f_ref = theano.function([], c_ref, mode=mode)
f = theano.function([], c, mode)

Expand Down Expand Up @@ -124,6 +125,7 @@ def run_gradweight(self, inputs_shape, filters_shape, output_shape,
filter_flip=filter_flip,
subsample=subsample,
imshp=imshp, kshp=kshp)
self.assertTrue(hasattr(c.tag, 'trace'))
c = c(inputs, output, filters_shape[-2:])
c_ref = ref(inputs, output,
filters_shape,
Expand Down Expand Up @@ -176,6 +178,7 @@ def run_gradinput(self, inputs_shape, filters_shape, output_shape, ref=dnn_gradi
subsample=subsample,
filter_flip=filter_flip,
imshp=imshp, kshp=kshp)
self.assertTrue(hasattr(c.tag, 'trace'))
c = c(filters, output, inputs_shape[-2:])
c_ref = ref(filters, output, inputs_shape,
border_mode=border_mode, subsample=subsample,
Expand Down
14 changes: 13 additions & 1 deletion theano/tensor/nnet/opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
AbstractConv2d_gradWeights,
AbstractConv2d_gradInputs)
from theano.tensor.nnet.abstract_conv import get_conv_output_shape
from theano.tensor.opt import register_specialize_device
from theano.tensor.opt import (copy_stack_trace,
register_specialize_device)
from theano.tensor import TensorType

# Cpu implementation
Expand Down Expand Up @@ -75,6 +76,7 @@ def local_abstractconv_gemm(node):
kern = kern[:, :, ::-1, ::-1]
rval = CorrMM(border_mode=node.op.border_mode,
subsample=node.op.subsample)(img, kern)
copy_stack_trace(node.outputs[0], rval)

return [rval]

Expand All @@ -96,6 +98,7 @@ def local_abstractconv_gradweight_gemm(node):
if node.op.filter_flip:
rval = rval[:, :, ::-1, ::-1]
rval = theano.tensor.patternbroadcast(rval, node.outputs[0].broadcastable)
copy_stack_trace(node.outputs[0], rval)

return [rval]

Expand All @@ -117,6 +120,7 @@ def local_abstractconv_gradinputs_gemm(node):
rval = CorrMM_gradInputs(border_mode=node.op.border_mode,
subsample=node.op.subsample)(kern, topgrad,
shape)
copy_stack_trace(node.outputs[0], rval)

return [rval]

Expand All @@ -141,6 +145,8 @@ def local_conv2d_cpu(node):
node.op.imshp, node.op.kshp,
border_mode=node.op.border_mode,
subsample=node.op.subsample)

copy_stack_trace(node.outputs[0], rval)
return [rval]


Expand Down Expand Up @@ -181,6 +187,7 @@ def local_conv2d_gradweight_cpu(node):
rval = rval[:, :, ::-1, ::-1]
rval = theano.tensor.patternbroadcast(rval,
node.outputs[0].broadcastable)
copy_stack_trace(node.outputs[0], rval)
return [rval]

dx, dy = node.op.subsample
Expand Down Expand Up @@ -251,6 +258,8 @@ def local_conv2d_gradweight_cpu(node):
res = res[:, :, ::-1, ::-1]

res = theano.tensor.patternbroadcast(res, node.outputs[0].broadcastable)

copy_stack_trace(node.outputs[0], res)
return [res]


Expand Down Expand Up @@ -284,6 +293,8 @@ def local_conv2d_gradinputs_cpu(node):
rval = rval.dimshuffle(0, 4, 1, 2)
rval = theano.tensor.patternbroadcast(rval,
node.outputs[0].broadcastable)

copy_stack_trace(node.outputs[0], rval)
return [rval]

# Conv2d Implementation
Expand Down Expand Up @@ -333,6 +344,7 @@ def local_conv2d_gradinputs_cpu(node):
direction_hint='bprop inputs')
din = din(topgrad, filters)
din = theano.tensor.patternbroadcast(din, node.outputs[0].broadcastable)
copy_stack_trace(node.outputs[0], din)
return [din]


Expand Down

0 comments on commit a41fc8b

Please sign in to comment.