{"action":"created","comment":{"url":"https://api.github.com/repos/Theano/Theano/pulls/comments/25070531","id":25070531,"diff_hunk":"@@ -1985,8 +1987,41 @@ def local_useless_subtensor(node):\n                 pass\n             else:\n                 return False\n+    elif isinstance(node.op, AdvancedSubtensor1):\n+        # get length of the indexed tensor along the first axis\n+        try:\n+            length = get_scalar_constant_value(shape_of[node.inputs[0]][0])\n+        except NotScalarConstantError:\n+            pass","path":"theano/tensor/opt.py","position":33,"original_position":33,"commit_id":"4e1721bfdde903d1cf2670da832c4d5b48962cdc","original_commit_id":"4e1721bfdde903d1cf2670da832c4d5b48962cdc","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":"I think it should be return False here","created_at":"2015-02-20T14:00:26Z","updated_at":"2015-02-20T14:00:26Z","html_url":"https://github.com/Theano/Theano/pull/2515#discussion_r25070531","pull_request_url":"https://api.github.com/repos/Theano/Theano/pulls/2515","_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments/25070531"},"html":{"href":"https://github.com/Theano/Theano/pull/2515#discussion_r25070531"},"pull_request":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2515"}}},"pull_request":{"url":"https://api.github.com/repos/Theano/Theano/pulls/2515","id":29692688,"html_url":"https://github.com/Theano/Theano/pull/2515","diff_url":"https://github.com/Theano/Theano/pull/2515.diff","patch_url":"https://github.com/Theano/Theano/pull/2515.patch","issue_url":"https://api.github.com/repos/Theano/Theano/issues/2515","number":2515,"state":"open","locked":false,"title":"AdvancedSubtensor1 support for local_useless_subtensor optimization","user":{"login":"sisp","id":2206639,"avatar_url":"https://avatars.githubusercontent.com/u/2206639?v=3","gravatar_id":"","url":"https://api.github.com/users/sisp","html_url":"https://github.com/sisp","followers_url":"https://api.github.com/users/sisp/followers","following_url":"https://api.github.com/users/sisp/following{/other_user}","gists_url":"https://api.github.com/users/sisp/gists{/gist_id}","starred_url":"https://api.github.com/users/sisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sisp/subscriptions","organizations_url":"https://api.github.com/users/sisp/orgs","repos_url":"https://api.github.com/users/sisp/repos","events_url":"https://api.github.com/users/sisp/events{/privacy}","received_events_url":"https://api.github.com/users/sisp/received_events","type":"User","site_admin":false},"body":"I added `AdvancedSubtensor1` support for the `local_useless_subtensor` optimization where the following cases are optimized:\r\n* `x[[0,1,...,#rows(x) - 1]] -> x` with a constant vector\r\n* `x[T.arange(x.shape[0])] -> x`\r\n\r\nI'm not sure if there is an `AdvancedSubtensor` case, too. The only one I could imagine would be `x[[0,0,...,1,1,...,#rows(x),#rows(x),...], [0,1,...,#cols(x),0,1,...,#cols(x),...]].reshape((#rows(x), #cols(x))` given `x` is a matrix (could be generalized for all tensors). Is this worth the effort? It seems like a very unlikely case, but I could do it if you feel it should be included. What I'm no clear about, though, is if that's actually a case for this optimization because the `AdvancedSubtensor` op will give a vector in any case. Only combined with `reshape` will this be a equivalent to just using `x` instead of the indexing + reshaping.","created_at":"2015-02-20T12:37:30Z","updated_at":"2015-02-20T14:00:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7a0f1a6cb3530492277727f12707cd9c95cad08","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Theano/Theano/pulls/2515/commits","review_comments_url":"https://api.github.com/repos/Theano/Theano/pulls/2515/comments","review_comment_url":"https://api.github.com/repos/Theano/Theano/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Theano/Theano/issues/2515/comments","statuses_url":"https://api.github.com/repos/Theano/Theano/statuses/4e1721bfdde903d1cf2670da832c4d5b48962cdc","head":{"label":"sisp:local_useless_subtensor","ref":"local_useless_subtensor","sha":"4e1721bfdde903d1cf2670da832c4d5b48962cdc","user":{"login":"sisp","id":2206639,"avatar_url":"https://avatars.githubusercontent.com/u/2206639?v=3","gravatar_id":"","url":"https://api.github.com/users/sisp","html_url":"https://github.com/sisp","followers_url":"https://api.github.com/users/sisp/followers","following_url":"https://api.github.com/users/sisp/following{/other_user}","gists_url":"https://api.github.com/users/sisp/gists{/gist_id}","starred_url":"https://api.github.com/users/sisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sisp/subscriptions","organizations_url":"https://api.github.com/users/sisp/orgs","repos_url":"https://api.github.com/users/sisp/repos","events_url":"https://api.github.com/users/sisp/events{/privacy}","received_events_url":"https://api.github.com/users/sisp/received_events","type":"User","site_admin":false},"repo":{"id":25789060,"name":"Theano","full_name":"sisp/Theano","owner":{"login":"sisp","id":2206639,"avatar_url":"https://avatars.githubusercontent.com/u/2206639?v=3","gravatar_id":"","url":"https://api.github.com/users/sisp","html_url":"https://github.com/sisp","followers_url":"https://api.github.com/users/sisp/followers","following_url":"https://api.github.com/users/sisp/following{/other_user}","gists_url":"https://api.github.com/users/sisp/gists{/gist_id}","starred_url":"https://api.github.com/users/sisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sisp/subscriptions","organizations_url":"https://api.github.com/users/sisp/orgs","repos_url":"https://api.github.com/users/sisp/repos","events_url":"https://api.github.com/users/sisp/events{/privacy}","received_events_url":"https://api.github.com/users/sisp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sisp/Theano","description":"Optimizing GPU-meta-programming code generating array oriented optimizing math compiler in Python","fork":true,"url":"https://api.github.com/repos/sisp/Theano","forks_url":"https://api.github.com/repos/sisp/Theano/forks","keys_url":"https://api.github.com/repos/sisp/Theano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sisp/Theano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sisp/Theano/teams","hooks_url":"https://api.github.com/repos/sisp/Theano/hooks","issue_events_url":"https://api.github.com/repos/sisp/Theano/issues/events{/number}","events_url":"https://api.github.com/repos/sisp/Theano/events","assignees_url":"https://api.github.com/repos/sisp/Theano/assignees{/user}","branches_url":"https://api.github.com/repos/sisp/Theano/branches{/branch}","tags_url":"https://api.github.com/repos/sisp/Theano/tags","blobs_url":"https://api.github.com/repos/sisp/Theano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sisp/Theano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sisp/Theano/git/refs{/sha}","trees_url":"https://api.github.com/repos/sisp/Theano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sisp/Theano/statuses/{sha}","languages_url":"https://api.github.com/repos/sisp/Theano/languages","stargazers_url":"https://api.github.com/repos/sisp/Theano/stargazers","contributors_url":"https://api.github.com/repos/sisp/Theano/contributors","subscribers_url":"https://api.github.com/repos/sisp/Theano/subscribers","subscription_url":"https://api.github.com/repos/sisp/Theano/subscription","commits_url":"https://api.github.com/repos/sisp/Theano/commits{/sha}","git_commits_url":"https://api.github.com/repos/sisp/Theano/git/commits{/sha}","comments_url":"https://api.github.com/repos/sisp/Theano/comments{/number}","issue_comment_url":"https://api.github.com/repos/sisp/Theano/issues/comments/{number}","contents_url":"https://api.github.com/repos/sisp/Theano/contents/{+path}","compare_url":"https://api.github.com/repos/sisp/Theano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sisp/Theano/merges","archive_url":"https://api.github.com/repos/sisp/Theano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sisp/Theano/downloads","issues_url":"https://api.github.com/repos/sisp/Theano/issues{/number}","pulls_url":"https://api.github.com/repos/sisp/Theano/pulls{/number}","milestones_url":"https://api.github.com/repos/sisp/Theano/milestones{/number}","notifications_url":"https://api.github.com/repos/sisp/Theano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sisp/Theano/labels{/name}","releases_url":"https://api.github.com/repos/sisp/Theano/releases{/id}","created_at":"2014-10-26T20:13:50Z","updated_at":"2015-02-20T11:20:54Z","pushed_at":"2015-02-20T12:16:46Z","git_url":"git://github.com/sisp/Theano.git","ssh_url":"git@github.com:sisp/Theano.git","clone_url":"https://github.com/sisp/Theano.git","svn_url":"https://github.com/sisp/Theano","homepage":"http://www.deeplearning.net/software/theano","size":22843,"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":"00ed78d28c3b0a1d894e6be6f3271e27c076f4de","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-19T18:44:01Z","pushed_at":"2015-02-19T18:43:58Z","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":1159,"watchers_count":1159,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":433,"mirror_url":null,"open_issues_count":321,"forks":433,"open_issues":321,"watchers":1159,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2515"},"html":{"href":"https://github.com/Theano/Theano/pull/2515"},"issue":{"href":"https://api.github.com/repos/Theano/Theano/issues/2515"},"comments":{"href":"https://api.github.com/repos/Theano/Theano/issues/2515/comments"},"review_comments":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2515/comments"},"review_comment":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Theano/Theano/pulls/2515/commits"},"statuses":{"href":"https://api.github.com/repos/Theano/Theano/statuses/4e1721bfdde903d1cf2670da832c4d5b48962cdc"}}}}