{"action":"created","issue":{"url":"https://api.github.com/repos/Theano/Theano/issues/2254","labels_url":"https://api.github.com/repos/Theano/Theano/issues/2254/labels{/name}","comments_url":"https://api.github.com/repos/Theano/Theano/issues/2254/comments","events_url":"https://api.github.com/repos/Theano/Theano/issues/2254/events","html_url":"https://github.com/Theano/Theano/issues/2254","id":48710191,"number":2254,"title":"Missing GPU case/optimization for some axis patterns in GpuCAReduce","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},"labels":[{"url":"https://api.github.com/repos/Theano/Theano/labels/CCW","name":"CCW","color":"f7c6c7"},{"url":"https://api.github.com/repos/Theano/Theano/labels/GPU","name":"GPU","color":"ededed"},{"url":"https://api.github.com/repos/Theano/Theano/labels/Optimization","name":"Optimization","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2014-11-13T23:38:41Z","updated_at":"2015-09-29T00:33:50Z","closed_at":null,"body":"Reductions over axes `(0, 1, 3)` for a 4D tensor (at least) are not transferred to GPU.\r\n\r\n```python\r\n>>> import theano\r\n>>> import numpy as np\r\n\r\n>>> x = theano.shared(np.ones((2,3,4,5), dtype=theano.config.floatX))\r\n>>> f = theano.function([], theano.tensor.sum(x, (0, 1, 3)))\r\n>>> theano.printing.debugprint(f, print_type=True)\r\nSum{axis=[0, 1, 3], acc_dtype=float64} [@A] <TensorType(float32, vector)> ''   1\r\n |HostFromGpu [@B] <TensorType(float32, 4D)> ''   0\r\n   |<CudaNdarrayType(float32, 4D)> [@C] <CudaNdarrayType(float32, 4D)>\r\n```\r\nIt works for other axes, like `(0, 2, 3)`:\r\n```python\r\n>>> g = theano.function([], theano.tensor.sum(x, (0, 2, 3)))\r\n>>> theano.printing.debugprint(g, print_type=True)\r\nHostFromGpu [@A] <TensorType(float32, vector)> ''   1\r\n |GpuCAReduce{add}{0,1,1,1} [@B] <CudaNdarrayType(float32, vector)> ''   0\r\n   |<CudaNdarrayType(float32, 4D)> [@C] <CudaNdarrayType(float32, 4D)>\r\n```\r\n\r\nor, with a more complex expression, for `(0, 1, 2)`: \r\n```python\r\n>>> h = theano.function([], theano.tensor.sum(x, (0, 1, 2)))\r\n>>> theano.printing.debugprint(h, print_type=True)\r\nHostFromGpu [@A] <TensorType(float32, vector)> ''   8\r\n |GpuCAReduce{add}{1,0} [@B] <CudaNdarrayType(float32, vector)> ''   7\r\n   |GpuReshape{2} [@C] <CudaNdarrayType(float32, matrix)> ''   6\r\n     |<CudaNdarrayType(float32, 4D)> [@D] <CudaNdarrayType(float32, 4D)>\r\n     |MakeVector [@E] <TensorType(int64, vector)> ''   5\r\n       |Elemwise{Mul}[(0, 0)] [@F] <TensorType(int64, scalar)> ''   4\r\n       | |Shape_i{2} [@G] <TensorType(int64, scalar)> ''   3\r\n       | | |<CudaNdarrayType(float32, 4D)> [@D] <CudaNdarrayType(float32, 4D)>\r\n       | |Shape_i{0} [@H] <TensorType(int64, scalar)> ''   2\r\n       | | |<CudaNdarrayType(float32, 4D)> [@D] <CudaNdarrayType(float32, 4D)>\r\n       | |Shape_i{1} [@I] <TensorType(int64, scalar)> ''   1\r\n       |   |<CudaNdarrayType(float32, 4D)> [@D] <CudaNdarrayType(float32, 4D)>\r\n       |Shape_i{3} [@J] <TensorType(int64, scalar)> ''   0\r\n         |<CudaNdarrayType(float32, 4D)> [@D] <CudaNdarrayType(float32, 4D)>\r\n```"},"comment":{"url":"https://api.github.com/repos/Theano/Theano/issues/comments/143910779","html_url":"https://github.com/Theano/Theano/issues/2254#issuecomment-143910779","issue_url":"https://api.github.com/repos/Theano/Theano/issues/2254","id":143910779,"user":{"login":"variousvirgil","id":6761583,"avatar_url":"https://avatars.githubusercontent.com/u/6761583?v=3","gravatar_id":"","url":"https://api.github.com/users/variousvirgil","html_url":"https://github.com/variousvirgil","followers_url":"https://api.github.com/users/variousvirgil/followers","following_url":"https://api.github.com/users/variousvirgil/following{/other_user}","gists_url":"https://api.github.com/users/variousvirgil/gists{/gist_id}","starred_url":"https://api.github.com/users/variousvirgil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/variousvirgil/subscriptions","organizations_url":"https://api.github.com/users/variousvirgil/orgs","repos_url":"https://api.github.com/users/variousvirgil/repos","events_url":"https://api.github.com/users/variousvirgil/events{/privacy}","received_events_url":"https://api.github.com/users/variousvirgil/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T00:33:50Z","updated_at":"2015-09-29T00:33:50Z","body":"@nouiz Thanks!"}}