{"action":"created","comment":{"url":"https://api.github.com/repos/Theano/Theano/pulls/comments/27312782","id":27312782,"diff_hunk":"@@ -3340,6 +3318,65 @@ def c_code(self, node, name, inputs, out_, sub):\n                 %(fail)s;\n             }\n         }\n+        \"\"\" % locals()\n+        return str\n+\n+    def infer_shape(self, node, input_shapes):\n+        return [node.inputs]\n+\n+    def c_code_cache_version(self):\n+        return (1,)\n+\n+    def do_constant_folding(self, node):\n+        return False\n+\n+gpu_alloc_empty = GpuAllocEmpty()\n+\n+\n+class GpuAlloc(GpuAllocEmpty):\n+    \"\"\"Implement Alloc on the gpu.\n+\n+    The memset_0 param is an optimization. When True, we call\n+    cudaMemset that is faster.\n+\n+    \"\"\"\n+    __props__ = ('memset_0',)\n+\n+    def __init__(self, memset_0=False):\n+        self.memset_0 = memset_0\n+\n+    def __str__(self):\n+        #Hide the memset parameter when not used to prevent confusion.\n+        if self.memset_0:\n+            s = \"%s{memset_0=%s}\" % (self.__class__.__name__, self.memset_0)\n+        else:\n+            s = self.__class__.__name__\n+        return s\n+\n+    def make_node(self, value, *shape):\n+        #if there is unneeded transfert generated by the next line\n+        #the optimizer will remove them.\n+        v = as_cuda_ndarray_variable(value)\n+        shape, output = self.validate_shape(shape)\n+        return Apply(self, [v] + shape, [output])\n+\n+    def perform(self, node, inputs, out_):\n+        # the super class (GpuAllocEmpty) allocates memory, we fill it\n+        value = inputs[0]\n+        shps = inputs[1:]\n+        super(GpuAlloc, self).perform(node, shps, out_)\n+        out, = out_\n+        out[0][...] = value  # broadcast value to fill us up\n+\n+    def c_code(self, node, name, inputs, out_, sub):\n+        # the super class (GpuAllocEmpty) allocates memory, we fill it\n+        value = inputs[0]\n+        shps = inputs[1:]\n+        str = super(GpuAllocEmpty, self).c_code(node, name, shps, out_, sub)","path":"theano/sandbox/cuda/basic_ops.py","position":136,"original_position":136,"commit_id":"8fcb85e505456ef9cdcafbec548ab7d47f4f3db6","original_commit_id":"8fcb85e505456ef9cdcafbec548ab7d47f4f3db6","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":"str is a python keyword. Try to not override it. Could you rename it to something else?","created_at":"2015-03-27T17:16:17Z","updated_at":"2015-03-27T17:16:17Z","html_url":"https://github.com/Theano/Theano/pull/2664#discussion_r27312782","pull_request_url":"https://api.github.com/repos/Theano/Theano/pulls/2664","_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments/27312782"},"html":{"href":"https://github.com/Theano/Theano/pull/2664#discussion_r27312782"},"pull_request":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2664"}}},"pull_request":{"url":"https://api.github.com/repos/Theano/Theano/pulls/2664","id":31853100,"html_url":"https://github.com/Theano/Theano/pull/2664","diff_url":"https://github.com/Theano/Theano/pull/2664.diff","patch_url":"https://github.com/Theano/Theano/pull/2664.patch","issue_url":"https://api.github.com/repos/Theano/Theano/issues/2664","number":2664,"state":"closed","locked":false,"title":"GpuAllocEmpty for dnn_conv()","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},"body":"This adds `GpuAllocEmpty`, makes `GpuAlloc` derive from it to avoid a lot of duplicated code, and makes `dnn_conv()` use `gpu_alloc_empty(*shape)` instead of `gpu_alloc(_zero.clone(), *shape)`. If merged, this partly solves #2632 (for GPU only).\r\n\r\nI'm not sure about a few things:\r\n1. Does `GpuAllocEmpty` need to implement `__eq__` and `__hash__` or does one of the base classes handle it already? (It seemed to me that the base class implementation only steps in if the class has a `__props__` member.)\r\n2. What should `GpuAllocEmpty.do_constant_folding()` do? For now I always return `False`. I don't know anything about the constant folding machinery, though.\r\n3. What's needed to make it work in DebugMode? The indeterministic output is problematic, I've heard?\r\n\r\nOtherwise it seems to work fine (I don't have a free GPU to run all the tests right now).\r\n\r\nPS: I intentionally didn't update `GpuAlloc.c_code_cache_version()` because the returned C code is exactly the same.","created_at":"2015-03-24T17:58:04Z","updated_at":"2015-03-27T17:16:17Z","closed_at":"2015-03-27T00:39:29Z","merged_at":"2015-03-27T00:39:29Z","merge_commit_sha":"0e106915268f9eaa7979bce98dc666e02dd609a7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Theano/Theano/pulls/2664/commits","review_comments_url":"https://api.github.com/repos/Theano/Theano/pulls/2664/comments","review_comment_url":"https://api.github.com/repos/Theano/Theano/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Theano/Theano/issues/2664/comments","statuses_url":"https://api.github.com/repos/Theano/Theano/statuses/8fcb85e505456ef9cdcafbec548ab7d47f4f3db6","head":{"label":"f0k:gpu-alloc-empty","ref":"gpu-alloc-empty","sha":"8fcb85e505456ef9cdcafbec548ab7d47f4f3db6","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},"repo":{"id":9244648,"name":"Theano","full_name":"f0k/Theano","owner":{"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},"private":false,"html_url":"https://github.com/f0k/Theano","description":"Optimizing GPU-meta-programming code generating array oriented optimizing math compiler in Python","fork":true,"url":"https://api.github.com/repos/f0k/Theano","forks_url":"https://api.github.com/repos/f0k/Theano/forks","keys_url":"https://api.github.com/repos/f0k/Theano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/f0k/Theano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/f0k/Theano/teams","hooks_url":"https://api.github.com/repos/f0k/Theano/hooks","issue_events_url":"https://api.github.com/repos/f0k/Theano/issues/events{/number}","events_url":"https://api.github.com/repos/f0k/Theano/events","assignees_url":"https://api.github.com/repos/f0k/Theano/assignees{/user}","branches_url":"https://api.github.com/repos/f0k/Theano/branches{/branch}","tags_url":"https://api.github.com/repos/f0k/Theano/tags","blobs_url":"https://api.github.com/repos/f0k/Theano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/f0k/Theano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/f0k/Theano/git/refs{/sha}","trees_url":"https://api.github.com/repos/f0k/Theano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/f0k/Theano/statuses/{sha}","languages_url":"https://api.github.com/repos/f0k/Theano/languages","stargazers_url":"https://api.github.com/repos/f0k/Theano/stargazers","contributors_url":"https://api.github.com/repos/f0k/Theano/contributors","subscribers_url":"https://api.github.com/repos/f0k/Theano/subscribers","subscription_url":"https://api.github.com/repos/f0k/Theano/subscription","commits_url":"https://api.github.com/repos/f0k/Theano/commits{/sha}","git_commits_url":"https://api.github.com/repos/f0k/Theano/git/commits{/sha}","comments_url":"https://api.github.com/repos/f0k/Theano/comments{/number}","issue_comment_url":"https://api.github.com/repos/f0k/Theano/issues/comments{/number}","contents_url":"https://api.github.com/repos/f0k/Theano/contents/{+path}","compare_url":"https://api.github.com/repos/f0k/Theano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/f0k/Theano/merges","archive_url":"https://api.github.com/repos/f0k/Theano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/f0k/Theano/downloads","issues_url":"https://api.github.com/repos/f0k/Theano/issues{/number}","pulls_url":"https://api.github.com/repos/f0k/Theano/pulls{/number}","milestones_url":"https://api.github.com/repos/f0k/Theano/milestones{/number}","notifications_url":"https://api.github.com/repos/f0k/Theano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/f0k/Theano/labels{/name}","releases_url":"https://api.github.com/repos/f0k/Theano/releases{/id}","created_at":"2013-04-05T15:52:31Z","updated_at":"2014-06-06T16:11:50Z","pushed_at":"2015-03-26T12:24:57Z","git_url":"git://github.com/f0k/Theano.git","ssh_url":"git@github.com:f0k/Theano.git","clone_url":"https://github.com/f0k/Theano.git","svn_url":"https://github.com/f0k/Theano","homepage":"http://www.deeplearning.net/software/theano","size":27594,"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":"26f29455a6f8f389f0b67d8b1dc41b9bc860120d","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}","created_at":"2011-08-10T03:48:06Z","updated_at":"2015-03-27T16:32:11Z","pushed_at":"2015-03-27T16:52:55Z","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":41287,"stargazers_count":1310,"watchers_count":1310,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":487,"mirror_url":null,"open_issues_count":336,"forks":487,"open_issues":336,"watchers":1310,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2664"},"html":{"href":"https://github.com/Theano/Theano/pull/2664"},"issue":{"href":"https://api.github.com/repos/Theano/Theano/issues/2664"},"comments":{"href":"https://api.github.com/repos/Theano/Theano/issues/2664/comments"},"review_comments":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2664/comments"},"review_comment":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2664/commits"},"statuses":{"href":"https://api.github.com/repos/Theano/Theano/statuses/8fcb85e505456ef9cdcafbec548ab7d47f4f3db6"}}}}