{"action":"created","issue":{"url":"https://api.github.com/repos/Theano/Theano/issues/3845","labels_url":"https://api.github.com/repos/Theano/Theano/issues/3845/labels{/name}","comments_url":"https://api.github.com/repos/Theano/Theano/issues/3845/comments","events_url":"https://api.github.com/repos/Theano/Theano/issues/3845/events","html_url":"https://github.com/Theano/Theano/pull/3845","id":125402442,"number":3845,"title":"Add border_mode=\"half\" to cuDNN convolutions","user":{"login":"f0k","id":629706,"avatar_url":"https://avatars.githubusercontent.com/u/629706?v=3","gravatar_id":"","url":"https://api.github.com/users/f0k","html_url":"https://github.com/f0k","followers_url":"https://api.github.com/users/f0k/followers","following_url":"https://api.github.com/users/f0k/following{/other_user}","gists_url":"https://api.github.com/users/f0k/gists{/gist_id}","starred_url":"https://api.github.com/users/f0k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f0k/subscriptions","organizations_url":"https://api.github.com/users/f0k/orgs","repos_url":"https://api.github.com/users/f0k/repos","events_url":"https://api.github.com/users/f0k/events{/privacy}","received_events_url":"https://api.github.com/users/f0k/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2016-01-07T14:18:17Z","updated_at":"2016-01-25T23:59:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Theano/Theano/pulls/3845","html_url":"https://github.com/Theano/Theano/pull/3845","diff_url":"https://github.com/Theano/Theano/pull/3845.diff","patch_url":"https://github.com/Theano/Theano/pull/3845.patch"},"body":"The new `conv2d()` interface supports `border_mode=\"half\"` for same convolutions. However, the cudnn convolution interface in Theano does not support it. `local_abstractconv_cudnn()` does not take care of this. Thus, the following fails when cuDNN is available:\r\n```python\r\nIn [1]: import theano\r\nUsing gpu device 0: Tesla K40c (CNMeM is enabled)\r\n\r\nIn [2]: x, w = theano.tensor.tensor4s('xw')\r\n\r\nIn [3]: c = theano.tensor.nnet.conv2d(x, w, border_mode='half')\r\n\r\nIn [4]: f = theano.function([x, w], c)\r\n\r\nERROR (theano.gof.opt): Optimization failure due to: LocalOptGroup(local_abstractconv_cudnn,local_conv_dnn,local_abstractconv_gemm,local_abstractconv_gradinputs_gemm,local_abstractconv_gradweight_gemm,local_conv_gemm)\r\nERROR (theano.gof.opt): node: AbstractConv2d{border_mode='half', subsample=(1, 1), filter_flip=True, imshp=None, kshp=None}(GpuFromHost.0, GpuFromHost.0)\r\nERROR (theano.gof.opt): TRACEBACK:\r\nERROR (theano.gof.opt): Traceback (most recent call last):\r\n  [...]\r\nValueError: invalid border_mode half, which must be either \"valid\", \"full\", an integer or a pair of integers\r\n```\r\n\r\nAn easy fix would be modifying `local_abstractconv_cudnn()` to catch `border_mode=\"half\"` and replace it with a suitable tuple of integers. It's difficult to adapt `test_abstractconv.py` accordingly, though, because it uses the cuDNN convolution as a reference. Plus it would only work for convolutions that have a filter size specified at compile time.\r\n\r\nSo I opted for changing `theano.sandbox.cuda.dnn` to include support for the \"half\" border mode, which wasn't very difficult either. `test_abstractconv.py` fails for me, but it also fails for the latest master.\r\n`test_dnn.py` still needs updates for the shape inference tests (to not give repeated values)."},"comment":{"url":"https://api.github.com/repos/Theano/Theano/issues/comments/174736595","html_url":"https://github.com/Theano/Theano/pull/3845#issuecomment-174736595","issue_url":"https://api.github.com/repos/Theano/Theano/issues/3845","id":174736595,"user":{"login":"lamblin","id":178249,"avatar_url":"https://avatars.githubusercontent.com/u/178249?v=3","gravatar_id":"","url":"https://api.github.com/users/lamblin","html_url":"https://github.com/lamblin","followers_url":"https://api.github.com/users/lamblin/followers","following_url":"https://api.github.com/users/lamblin/following{/other_user}","gists_url":"https://api.github.com/users/lamblin/gists{/gist_id}","starred_url":"https://api.github.com/users/lamblin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamblin/subscriptions","organizations_url":"https://api.github.com/users/lamblin/orgs","repos_url":"https://api.github.com/users/lamblin/repos","events_url":"https://api.github.com/users/lamblin/events{/privacy}","received_events_url":"https://api.github.com/users/lamblin/received_events","type":"User","site_admin":false},"created_at":"2016-01-25T23:59:23Z","updated_at":"2016-01-25T23:59:23Z","body":"Looks good, thanks. I just ran `test_dnn.py` locally without issues, I'm running `test_abstractconv.py` now, and will merge if it succeeds."}}