{"action":"created","comment":{"url":"https://api.github.com/repos/Theano/Theano/pulls/comments/25086694","id":25086694,"diff_hunk":"@@ -599,50 +681,53 @@ def c_code(self, node, name, inputs, outputs, sub):\n     def c_code_cache_version(self):\n         return (3,)\n \n-\n cuda_from_gpu = CudaFromGpu()\n \n \n class GpuAlloc(HideC, Alloc):\n-    def __init__(self, memset_0=False):\n+    __props__ = ('memset_0', 'context') + Alloc.__props__\n+\n+    context_type = gpu_context_type\n+\n+    def __init__(self, context, memset_0=False):\n         \"\"\"memset_0 is only an optimized version. True, it mean the\n         value is always 0, so the c code call memset as it is faster.\n         \"\"\"\n+        self.context = context\n         self.memset_0 = memset_0\n \n-    def __eq__(self, other):\n-        return type(self) == type(other) and self.memset_0 == other.memset_0\n-\n-    def __hash__(self):\n-        return hash(type(self)) ^ hash(self.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+            s = \"%s<%s>{memset_0=%s}\" % (self.__class__.__name__,\n+                                         self.context, self.memset_0)\n         else:\n-            s = self.__class__.__name__\n+            s = \"%s<%s>\" % (self.__class__.__name__, self.context)\n         return s\n \n     def make_node(self, value, *shape):\n         res = Alloc.make_node(self, value, *shape)\n-        value = as_gpuarray_variable(value)\n+        value = as_gpuarray_variable(value, context=self.context)\n         otype = GpuArrayType(dtype=res.outputs[0].dtype,\n-                             broadcastable=res.outputs[0].broadcastable)\n+                             broadcastable=res.outputs[0].broadcastable,\n+                             context=self.context)\n         return Apply(self, [value] + res.inputs[1:], [otype()])\n \n+    def get_context(self, node):\n+        return self.context\n+\n     def c_headers(self):\n         return ['<numpy_compat.h>']\n \n-    def perform(self, node, inputs, outs):\n+    def perform(self, node, inputs, outs, ctx):\n         out, = outs\n         v = inputs[0]\n         sh = tuple(map(int, inputs[1:]))\n         if out[0] is None or out[0].shape != sh:","path":"theano/sandbox/gpuarray/basic_ops.py","position":527,"original_position":530,"commit_id":"76ae81306451d49938571a16bb8c453ca489518e","original_commit_id":"b62eaadc5f2695eb7be5742bf07542169a6a2bb7","user":{"login":"abergeron","id":1002504,"avatar_url":"https://avatars.githubusercontent.com/u/1002504?v=3","gravatar_id":"","url":"https://api.github.com/users/abergeron","html_url":"https://github.com/abergeron","followers_url":"https://api.github.com/users/abergeron/followers","following_url":"https://api.github.com/users/abergeron/following{/other_user}","gists_url":"https://api.github.com/users/abergeron/gists{/gist_id}","starred_url":"https://api.github.com/users/abergeron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abergeron/subscriptions","organizations_url":"https://api.github.com/users/abergeron/orgs","repos_url":"https://api.github.com/users/abergeron/repos","events_url":"https://api.github.com/users/abergeron/events{/privacy}","received_events_url":"https://api.github.com/users/abergeron/received_events","type":"User","site_admin":false},"body":"I think it should be done though the type (the filter method already does this, I don't remember about the C code).\r\n\r\nAlso, I would disagree about doing this in the \"FAST_RUN\" case since we don't want to have a lot of type checking overhead.  A DebugMode-light or something that performs those checks would be good.","created_at":"2015-02-20T17:34:14Z","updated_at":"2015-02-20T17:34:14Z","html_url":"https://github.com/Theano/Theano/pull/2182#discussion_r25086694","pull_request_url":"https://api.github.com/repos/Theano/Theano/pulls/2182","_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments/25086694"},"html":{"href":"https://github.com/Theano/Theano/pull/2182#discussion_r25086694"},"pull_request":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2182"}}},"pull_request":{"url":"https://api.github.com/repos/Theano/Theano/pulls/2182","id":22811939,"html_url":"https://github.com/Theano/Theano/pull/2182","diff_url":"https://github.com/Theano/Theano/pull/2182.diff","patch_url":"https://github.com/Theano/Theano/pull/2182.patch","issue_url":"https://api.github.com/repos/Theano/Theano/issues/2182","number":2182,"state":"open","locked":false,"title":"Add a mechanism to use more than one (gpu) context in a single theano function","user":{"login":"abergeron","id":1002504,"avatar_url":"https://avatars.githubusercontent.com/u/1002504?v=3","gravatar_id":"","url":"https://api.github.com/users/abergeron","html_url":"https://github.com/abergeron","followers_url":"https://api.github.com/users/abergeron/followers","following_url":"https://api.github.com/users/abergeron/following{/other_user}","gists_url":"https://api.github.com/users/abergeron/gists{/gist_id}","starred_url":"https://api.github.com/users/abergeron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abergeron/subscriptions","organizations_url":"https://api.github.com/users/abergeron/orgs","repos_url":"https://api.github.com/users/abergeron/repos","events_url":"https://api.github.com/users/abergeron/events{/privacy}","received_events_url":"https://api.github.com/users/abergeron/received_events","type":"User","site_admin":false},"body":"__Disclaimer:__ This is work in progress.  Some changes made here will cause a lot of code to not work anymore, so don't use this branch unless you are prepared to deal with that.\r\n\r\nThis add some optional methods on Ops that will trigger CLinker to pass a context argument that will be available at init and runtime.  This context is typed according to the the type specified by the op.\r\n\r\nAlso this makes the context a part of the theano Type for GpuArray.  This way, most Ops will know what context they are going to work with and it makes it easy for the context to propagate through the graph.\r\n\r\nTODO:\r\n\r\n - [x] Trivial example with 2 dots on different GPUs.\r\n - [x] Fix crash with tests/optimizations.\r\n - [x] add a way to copy a buffer from one context to another (without passing thought the CPU)\r\n - [x] Fix crash with tests/optimizations and non default context.\r\n - [x] add a way to specify the context of the inputs. (probably a tag with the context name)\r\n - [x] gpu to gpu transfer _as_GpuArrayVariabl\r\n - [ ] replicate Alex models?\r\n","created_at":"2014-10-15T20:20:41Z","updated_at":"2015-02-20T17:34:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c3db739611e2fe5a6a23720b6470fe69a5ac3eb1","assignee":{"login":"abergeron","id":1002504,"avatar_url":"https://avatars.githubusercontent.com/u/1002504?v=3","gravatar_id":"","url":"https://api.github.com/users/abergeron","html_url":"https://github.com/abergeron","followers_url":"https://api.github.com/users/abergeron/followers","following_url":"https://api.github.com/users/abergeron/following{/other_user}","gists_url":"https://api.github.com/users/abergeron/gists{/gist_id}","starred_url":"https://api.github.com/users/abergeron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abergeron/subscriptions","organizations_url":"https://api.github.com/users/abergeron/orgs","repos_url":"https://api.github.com/users/abergeron/repos","events_url":"https://api.github.com/users/abergeron/events{/privacy}","received_events_url":"https://api.github.com/users/abergeron/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Theano/Theano/pulls/2182/commits","review_comments_url":"https://api.github.com/repos/Theano/Theano/pulls/2182/comments","review_comment_url":"https://api.github.com/repos/Theano/Theano/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Theano/Theano/issues/2182/comments","statuses_url":"https://api.github.com/repos/Theano/Theano/statuses/76ae81306451d49938571a16bb8c453ca489518e","head":{"label":"abergeron:multi_gpu2","ref":"multi_gpu2","sha":"76ae81306451d49938571a16bb8c453ca489518e","user":{"login":"abergeron","id":1002504,"avatar_url":"https://avatars.githubusercontent.com/u/1002504?v=3","gravatar_id":"","url":"https://api.github.com/users/abergeron","html_url":"https://github.com/abergeron","followers_url":"https://api.github.com/users/abergeron/followers","following_url":"https://api.github.com/users/abergeron/following{/other_user}","gists_url":"https://api.github.com/users/abergeron/gists{/gist_id}","starred_url":"https://api.github.com/users/abergeron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abergeron/subscriptions","organizations_url":"https://api.github.com/users/abergeron/orgs","repos_url":"https://api.github.com/users/abergeron/repos","events_url":"https://api.github.com/users/abergeron/events{/privacy}","received_events_url":"https://api.github.com/users/abergeron/received_events","type":"User","site_admin":false},"repo":{"id":2264121,"name":"Theano","full_name":"abergeron/Theano","owner":{"login":"abergeron","id":1002504,"avatar_url":"https://avatars.githubusercontent.com/u/1002504?v=3","gravatar_id":"","url":"https://api.github.com/users/abergeron","html_url":"https://github.com/abergeron","followers_url":"https://api.github.com/users/abergeron/followers","following_url":"https://api.github.com/users/abergeron/following{/other_user}","gists_url":"https://api.github.com/users/abergeron/gists{/gist_id}","starred_url":"https://api.github.com/users/abergeron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abergeron/subscriptions","organizations_url":"https://api.github.com/users/abergeron/orgs","repos_url":"https://api.github.com/users/abergeron/repos","events_url":"https://api.github.com/users/abergeron/events{/privacy}","received_events_url":"https://api.github.com/users/abergeron/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abergeron/Theano","description":"Optimizing GPU-meta-programming code generating array oriented optimizing math compiler in Python","fork":true,"url":"https://api.github.com/repos/abergeron/Theano","forks_url":"https://api.github.com/repos/abergeron/Theano/forks","keys_url":"https://api.github.com/repos/abergeron/Theano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abergeron/Theano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abergeron/Theano/teams","hooks_url":"https://api.github.com/repos/abergeron/Theano/hooks","issue_events_url":"https://api.github.com/repos/abergeron/Theano/issues/events{/number}","events_url":"https://api.github.com/repos/abergeron/Theano/events","assignees_url":"https://api.github.com/repos/abergeron/Theano/assignees{/user}","branches_url":"https://api.github.com/repos/abergeron/Theano/branches{/branch}","tags_url":"https://api.github.com/repos/abergeron/Theano/tags","blobs_url":"https://api.github.com/repos/abergeron/Theano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abergeron/Theano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abergeron/Theano/git/refs{/sha}","trees_url":"https://api.github.com/repos/abergeron/Theano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abergeron/Theano/statuses/{sha}","languages_url":"https://api.github.com/repos/abergeron/Theano/languages","stargazers_url":"https://api.github.com/repos/abergeron/Theano/stargazers","contributors_url":"https://api.github.com/repos/abergeron/Theano/contributors","subscribers_url":"https://api.github.com/repos/abergeron/Theano/subscribers","subscription_url":"https://api.github.com/repos/abergeron/Theano/subscription","commits_url":"https://api.github.com/repos/abergeron/Theano/commits{/sha}","git_commits_url":"https://api.github.com/repos/abergeron/Theano/git/commits{/sha}","comments_url":"https://api.github.com/repos/abergeron/Theano/comments{/number}","issue_comment_url":"https://api.github.com/repos/abergeron/Theano/issues/comments/{number}","contents_url":"https://api.github.com/repos/abergeron/Theano/contents/{+path}","compare_url":"https://api.github.com/repos/abergeron/Theano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abergeron/Theano/merges","archive_url":"https://api.github.com/repos/abergeron/Theano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abergeron/Theano/downloads","issues_url":"https://api.github.com/repos/abergeron/Theano/issues{/number}","pulls_url":"https://api.github.com/repos/abergeron/Theano/pulls{/number}","milestones_url":"https://api.github.com/repos/abergeron/Theano/milestones{/number}","notifications_url":"https://api.github.com/repos/abergeron/Theano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abergeron/Theano/labels{/name}","releases_url":"https://api.github.com/repos/abergeron/Theano/releases{/id}","created_at":"2011-08-24T20:28:59Z","updated_at":"2015-02-04T20:45:30Z","pushed_at":"2015-02-20T17:21:34Z","git_url":"git://github.com/abergeron/Theano.git","ssh_url":"git@github.com:abergeron/Theano.git","clone_url":"https://github.com/abergeron/Theano.git","svn_url":"https://github.com/abergeron/Theano","homepage":"http://www.deeplearning.net/software/theano","size":27557,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"Theano:master","ref":"master","sha":"9636481a5de2c8331220437322eae48a6c89e9c5","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-02-20T16:26:21Z","pushed_at":"2015-02-20T16:26:19Z","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":38633,"stargazers_count":1160,"watchers_count":1160,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":433,"mirror_url":null,"open_issues_count":322,"forks":433,"open_issues":322,"watchers":1160,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2182"},"html":{"href":"https://github.com/Theano/Theano/pull/2182"},"issue":{"href":"https://api.github.com/repos/Theano/Theano/issues/2182"},"comments":{"href":"https://api.github.com/repos/Theano/Theano/issues/2182/comments"},"review_comments":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2182/comments"},"review_comment":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2182/commits"},"statuses":{"href":"https://api.github.com/repos/Theano/Theano/statuses/76ae81306451d49938571a16bb8c453ca489518e"}}}}