{"action":"created","comment":{"url":"https://api.github.com/repos/Theano/Theano/pulls/comments/76814409","id":76814409,"diff_hunk":"@@ -357,279 +415,368 @@ def c_headers(self):\n     def c_code(self, node, name, inp, out, sub):\n         if self.mode not in ('max', 'sum', 'average_exc_pad', 'average_inc_pad'):\n             raise theano.gof.utils.MethodNotDefined()\n+        nd = len(self.ds)\n         x, = inp\n         z, = out\n+        total_ndim = node.inputs[0].ndim\n+        non_pool_ndim = total_ndim - nd\n         fail = sub['fail']\n         ignore_border = int(self.ignore_border)\n-        ds0, ds1 = self.ds\n-        st0, st1 = self.st\n-        pd0, pd1 = self.padding\n+        ds = ','.join(map(str, self.ds))\n+        st = ','.join(map(str, self.st))\n+        pd = ','.join(map(str, self.padding))\n         if self.openmp:\n-            omp_parallel = '#pragma omp parallel for private(r_st, r_end, c_st, c_end, collector) schedule(static)'\n+            # run in parallel over each pooling block\n+            omp_parallel = '#pragma omp parallel for private(r_st, r_end, r_idx, i_idx, o_idx, collector) schedule(static)'\n         else:\n             omp_parallel = ''\n         ccode = \"\"\"\n         int typenum = PyArray_ObjectType((PyObject*)%(x)s, 0);\n-        int z_r, z_c; // shape of the output\n-        int r, c; // shape of the padded_input\n-        if(PyArray_NDIM(%(x)s)!=4)\n+        int z[%(nd)s]; // shape of the output\n+        int r[%(nd)s]; // shape of the padded_input\n+        int ds[%(nd)s] = {%(ds)s};\n+        int st[%(nd)s] = {%(st)s};\n+        int pd[%(nd)s] = {%(pd)s};\n+        if(PyArray_NDIM(%(x)s)!=%(total_ndim)s)\n         {\n-            PyErr_SetString(PyExc_ValueError, \"x must be a 4d ndarray\");\n+            PyErr_SetString(PyExc_ValueError, \"x must be a %(total_ndim)sD ndarray\");\n             %(fail)s;\n         }\n-        r = PyArray_DIMS(%(x)s)[2];\n-        c = PyArray_DIMS(%(x)s)[3];\n-        r += %(pd0)s * 2;\n-        c += %(pd1)s * 2;\n-        if (%(pd0)s != 0 && %(pd1)s != 0 && !%(ignore_border)s)\n-            {\n-              PyErr_SetString(PyExc_ValueError,\n-                \"padding must be (0,0) when ignore border is False\");\n-              %(fail)s;\n-            }\n+        for (int i=0; i<%(nd)s; i++)\n+        {\n+            r[i] = PyArray_DIMS(%(x)s)[%(non_pool_ndim)s + i] + 2 * pd[i];\n+        }\n+        \"\"\"\n+\n+        if not self.ignore_border and any(self.padding[i] > 0 for i in xrange(nd)):","path":"theano/tensor/signal/pool.py","position":451,"original_position":451,"commit_id":"6a59785c526284f7417d10c64b7c8dfef117f9a0","original_commit_id":"6a59785c526284f7417d10c64b7c8dfef117f9a0","user":{"login":"nouiz","id":180987,"avatar_url":"https://avatars.githubusercontent.com/u/180987?v=3","gravatar_id":"","url":"https://api.github.com/users/nouiz","html_url":"https://github.com/nouiz","followers_url":"https://api.github.com/users/nouiz/followers","following_url":"https://api.github.com/users/nouiz/following{/other_user}","gists_url":"https://api.github.com/users/nouiz/gists{/gist_id}","starred_url":"https://api.github.com/users/nouiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nouiz/subscriptions","organizations_url":"https://api.github.com/users/nouiz/orgs","repos_url":"https://api.github.com/users/nouiz/repos","events_url":"https://api.github.com/users/nouiz/events{/privacy}","received_events_url":"https://api.github.com/users/nouiz/received_events","type":"User","site_admin":false},"body":"There is a PR that make the padding as an input of the node. To help the conflict resolution of both PR, can you keep that in the C code?","created_at":"2016-08-30T15:07:14Z","updated_at":"2016-08-30T15:07:14Z","html_url":"https://github.com/Theano/Theano/pull/4884#discussion_r76814409","pull_request_url":"https://api.github.com/repos/Theano/Theano/pulls/4884","_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments/76814409"},"html":{"href":"https://github.com/Theano/Theano/pull/4884#discussion_r76814409"},"pull_request":{"href":"https://api.github.com/repos/Theano/Theano/pulls/4884"}}},"pull_request":{"url":"https://api.github.com/repos/Theano/Theano/pulls/4884","id":82115839,"html_url":"https://github.com/Theano/Theano/pull/4884","diff_url":"https://github.com/Theano/Theano/pull/4884.diff","patch_url":"https://github.com/Theano/Theano/pull/4884.patch","issue_url":"https://api.github.com/repos/Theano/Theano/issues/4884","number":4884,"state":"open","locked":false,"title":"theano.tensor.signal.Pool with 3D support","user":{"login":"gvtulder","id":31510,"avatar_url":"https://avatars.githubusercontent.com/u/31510?v=3","gravatar_id":"","url":"https://api.github.com/users/gvtulder","html_url":"https://github.com/gvtulder","followers_url":"https://api.github.com/users/gvtulder/followers","following_url":"https://api.github.com/users/gvtulder/following{/other_user}","gists_url":"https://api.github.com/users/gvtulder/gists{/gist_id}","starred_url":"https://api.github.com/users/gvtulder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvtulder/subscriptions","organizations_url":"https://api.github.com/users/gvtulder/orgs","repos_url":"https://api.github.com/users/gvtulder/repos","events_url":"https://api.github.com/users/gvtulder/events{/privacy}","received_events_url":"https://api.github.com/users/gvtulder/received_events","type":"User","site_admin":false},"body":"This would add a 3D CPU implementation for `theano.tensor.signal.Pool` and its gradients, which can then be optimised with a GPU implementation.\r\n\r\n(Actually, it turns the Pool op into a more generic Nd pooling operation, which may or may not be a good idea.)\r\n\r\nSee also issue #4731.","created_at":"2016-08-21T20:20:04Z","updated_at":"2016-08-30T15:07:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be84209132626864999800560ff192cc6afccff3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Theano/Theano/pulls/4884/commits","review_comments_url":"https://api.github.com/repos/Theano/Theano/pulls/4884/comments","review_comment_url":"https://api.github.com/repos/Theano/Theano/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Theano/Theano/issues/4884/comments","statuses_url":"https://api.github.com/repos/Theano/Theano/statuses/6a59785c526284f7417d10c64b7c8dfef117f9a0","head":{"label":"gvtulder:f-pool-3d","ref":"f-pool-3d","sha":"6a59785c526284f7417d10c64b7c8dfef117f9a0","user":{"login":"gvtulder","id":31510,"avatar_url":"https://avatars.githubusercontent.com/u/31510?v=3","gravatar_id":"","url":"https://api.github.com/users/gvtulder","html_url":"https://github.com/gvtulder","followers_url":"https://api.github.com/users/gvtulder/followers","following_url":"https://api.github.com/users/gvtulder/following{/other_user}","gists_url":"https://api.github.com/users/gvtulder/gists{/gist_id}","starred_url":"https://api.github.com/users/gvtulder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvtulder/subscriptions","organizations_url":"https://api.github.com/users/gvtulder/orgs","repos_url":"https://api.github.com/users/gvtulder/repos","events_url":"https://api.github.com/users/gvtulder/events{/privacy}","received_events_url":"https://api.github.com/users/gvtulder/received_events","type":"User","site_admin":false},"repo":{"id":35170737,"name":"Theano","full_name":"gvtulder/Theano","owner":{"login":"gvtulder","id":31510,"avatar_url":"https://avatars.githubusercontent.com/u/31510?v=3","gravatar_id":"","url":"https://api.github.com/users/gvtulder","html_url":"https://github.com/gvtulder","followers_url":"https://api.github.com/users/gvtulder/followers","following_url":"https://api.github.com/users/gvtulder/following{/other_user}","gists_url":"https://api.github.com/users/gvtulder/gists{/gist_id}","starred_url":"https://api.github.com/users/gvtulder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvtulder/subscriptions","organizations_url":"https://api.github.com/users/gvtulder/orgs","repos_url":"https://api.github.com/users/gvtulder/repos","events_url":"https://api.github.com/users/gvtulder/events{/privacy}","received_events_url":"https://api.github.com/users/gvtulder/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gvtulder/Theano","description":"Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It can use GPUs and perform efficient symbolic differentiation.","fork":true,"url":"https://api.github.com/repos/gvtulder/Theano","forks_url":"https://api.github.com/repos/gvtulder/Theano/forks","keys_url":"https://api.github.com/repos/gvtulder/Theano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gvtulder/Theano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gvtulder/Theano/teams","hooks_url":"https://api.github.com/repos/gvtulder/Theano/hooks","issue_events_url":"https://api.github.com/repos/gvtulder/Theano/issues/events{/number}","events_url":"https://api.github.com/repos/gvtulder/Theano/events","assignees_url":"https://api.github.com/repos/gvtulder/Theano/assignees{/user}","branches_url":"https://api.github.com/repos/gvtulder/Theano/branches{/branch}","tags_url":"https://api.github.com/repos/gvtulder/Theano/tags","blobs_url":"https://api.github.com/repos/gvtulder/Theano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gvtulder/Theano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gvtulder/Theano/git/refs{/sha}","trees_url":"https://api.github.com/repos/gvtulder/Theano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gvtulder/Theano/statuses/{sha}","languages_url":"https://api.github.com/repos/gvtulder/Theano/languages","stargazers_url":"https://api.github.com/repos/gvtulder/Theano/stargazers","contributors_url":"https://api.github.com/repos/gvtulder/Theano/contributors","subscribers_url":"https://api.github.com/repos/gvtulder/Theano/subscribers","subscription_url":"https://api.github.com/repos/gvtulder/Theano/subscription","commits_url":"https://api.github.com/repos/gvtulder/Theano/commits{/sha}","git_commits_url":"https://api.github.com/repos/gvtulder/Theano/git/commits{/sha}","comments_url":"https://api.github.com/repos/gvtulder/Theano/comments{/number}","issue_comment_url":"https://api.github.com/repos/gvtulder/Theano/issues/comments{/number}","contents_url":"https://api.github.com/repos/gvtulder/Theano/contents/{+path}","compare_url":"https://api.github.com/repos/gvtulder/Theano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gvtulder/Theano/merges","archive_url":"https://api.github.com/repos/gvtulder/Theano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gvtulder/Theano/downloads","issues_url":"https://api.github.com/repos/gvtulder/Theano/issues{/number}","pulls_url":"https://api.github.com/repos/gvtulder/Theano/pulls{/number}","milestones_url":"https://api.github.com/repos/gvtulder/Theano/milestones{/number}","notifications_url":"https://api.github.com/repos/gvtulder/Theano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gvtulder/Theano/labels{/name}","releases_url":"https://api.github.com/repos/gvtulder/Theano/releases{/id}","deployments_url":"https://api.github.com/repos/gvtulder/Theano/deployments","created_at":"2015-05-06T16:37:48Z","updated_at":"2016-08-04T10:11:14Z","pushed_at":"2016-08-26T14:29:36Z","git_url":"git://github.com/gvtulder/Theano.git","ssh_url":"git@github.com:gvtulder/Theano.git","clone_url":"https://github.com/gvtulder/Theano.git","svn_url":"https://github.com/gvtulder/Theano","homepage":"http://www.deeplearning.net/software/theano","size":57277,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Theano:master","ref":"master","sha":"74c0233b125798bab02300896f1e4c7a0900bb40","user":{"login":"Theano","id":970517,"avatar_url":"https://avatars.githubusercontent.com/u/970517?v=3","gravatar_id":"","url":"https://api.github.com/users/Theano","html_url":"https://github.com/Theano","followers_url":"https://api.github.com/users/Theano/followers","following_url":"https://api.github.com/users/Theano/following{/other_user}","gists_url":"https://api.github.com/users/Theano/gists{/gist_id}","starred_url":"https://api.github.com/users/Theano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Theano/subscriptions","organizations_url":"https://api.github.com/users/Theano/orgs","repos_url":"https://api.github.com/users/Theano/repos","events_url":"https://api.github.com/users/Theano/events{/privacy}","received_events_url":"https://api.github.com/users/Theano/received_events","type":"Organization","site_admin":false},"repo":{"id":2183193,"name":"Theano","full_name":"Theano/Theano","owner":{"login":"Theano","id":970517,"avatar_url":"https://avatars.githubusercontent.com/u/970517?v=3","gravatar_id":"","url":"https://api.github.com/users/Theano","html_url":"https://github.com/Theano","followers_url":"https://api.github.com/users/Theano/followers","following_url":"https://api.github.com/users/Theano/following{/other_user}","gists_url":"https://api.github.com/users/Theano/gists{/gist_id}","starred_url":"https://api.github.com/users/Theano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Theano/subscriptions","organizations_url":"https://api.github.com/users/Theano/orgs","repos_url":"https://api.github.com/users/Theano/repos","events_url":"https://api.github.com/users/Theano/events{/privacy}","received_events_url":"https://api.github.com/users/Theano/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Theano/Theano","description":"Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It can use GPUs and perform efficient symbolic differentiation.","fork":false,"url":"https://api.github.com/repos/Theano/Theano","forks_url":"https://api.github.com/repos/Theano/Theano/forks","keys_url":"https://api.github.com/repos/Theano/Theano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Theano/Theano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Theano/Theano/teams","hooks_url":"https://api.github.com/repos/Theano/Theano/hooks","issue_events_url":"https://api.github.com/repos/Theano/Theano/issues/events{/number}","events_url":"https://api.github.com/repos/Theano/Theano/events","assignees_url":"https://api.github.com/repos/Theano/Theano/assignees{/user}","branches_url":"https://api.github.com/repos/Theano/Theano/branches{/branch}","tags_url":"https://api.github.com/repos/Theano/Theano/tags","blobs_url":"https://api.github.com/repos/Theano/Theano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Theano/Theano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Theano/Theano/git/refs{/sha}","trees_url":"https://api.github.com/repos/Theano/Theano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Theano/Theano/statuses/{sha}","languages_url":"https://api.github.com/repos/Theano/Theano/languages","stargazers_url":"https://api.github.com/repos/Theano/Theano/stargazers","contributors_url":"https://api.github.com/repos/Theano/Theano/contributors","subscribers_url":"https://api.github.com/repos/Theano/Theano/subscribers","subscription_url":"https://api.github.com/repos/Theano/Theano/subscription","commits_url":"https://api.github.com/repos/Theano/Theano/commits{/sha}","git_commits_url":"https://api.github.com/repos/Theano/Theano/git/commits{/sha}","comments_url":"https://api.github.com/repos/Theano/Theano/comments{/number}","issue_comment_url":"https://api.github.com/repos/Theano/Theano/issues/comments{/number}","contents_url":"https://api.github.com/repos/Theano/Theano/contents/{+path}","compare_url":"https://api.github.com/repos/Theano/Theano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Theano/Theano/merges","archive_url":"https://api.github.com/repos/Theano/Theano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Theano/Theano/downloads","issues_url":"https://api.github.com/repos/Theano/Theano/issues{/number}","pulls_url":"https://api.github.com/repos/Theano/Theano/pulls{/number}","milestones_url":"https://api.github.com/repos/Theano/Theano/milestones{/number}","notifications_url":"https://api.github.com/repos/Theano/Theano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Theano/Theano/labels{/name}","releases_url":"https://api.github.com/repos/Theano/Theano/releases{/id}","deployments_url":"https://api.github.com/repos/Theano/Theano/deployments","created_at":"2011-08-10T03:48:06Z","updated_at":"2016-08-30T11:38:38Z","pushed_at":"2016-08-30T14:34:17Z","git_url":"git://github.com/Theano/Theano.git","ssh_url":"git@github.com:Theano/Theano.git","clone_url":"https://github.com/Theano/Theano.git","svn_url":"https://github.com/Theano/Theano","homepage":"http://www.deeplearning.net/software/theano","size":76316,"stargazers_count":4418,"watchers_count":4418,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1584,"mirror_url":null,"open_issues_count":736,"forks":1584,"open_issues":736,"watchers":4418,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/4884"},"html":{"href":"https://github.com/Theano/Theano/pull/4884"},"issue":{"href":"https://api.github.com/repos/Theano/Theano/issues/4884"},"comments":{"href":"https://api.github.com/repos/Theano/Theano/issues/4884/comments"},"review_comments":{"href":"https://api.github.com/repos/Theano/Theano/pulls/4884/comments"},"review_comment":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Theano/Theano/pulls/4884/commits"},"statuses":{"href":"https://api.github.com/repos/Theano/Theano/statuses/6a59785c526284f7417d10c64b7c8dfef117f9a0"}}}}
{"actor":{"display_login":"nouiz"}}