{"action":"created","comment":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/204228057","pull_request_review_id":139275698,"id":204228057,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDIyODA1Nw==","diff_hunk":"@@ -69,9 +80,17 @@ struct SparseTensorImpl : public TensorImpl {\n   // TODO: Figure out a more safe way to provide this functionality\n   std::vector<int64_t>& _sizes_mut() { return size_; }\n \n+#ifndef USE_TH_SIZE_ZERO_DIM\n   // WARNING: This function does NOT preserve invariants of sparseDims/denseDims with\n   // respect to indices and values\n+#else\n+  // NOTE: This function checks and preserves invariants of sparseDims/denseDims with\n+  // respect to indices and values, but doesn't check whether any indices are\n+  // out of boundaries of `size`.\n+  // This function should only be called from the resize_and_clear_sparse_ function.","path":"aten/src/ATen/SparseTensorImpl.h","position":null,"original_position":50,"commit_id":"26d31a7c29b38b5d9742c66d7c6912e9b89c5e3e","original_commit_id":"baf404175555d7f375798f64e49e777e5c6a43ed","user":{"login":"yf225","id":4063635,"node_id":"MDQ6VXNlcjQwNjM2MzU=","avatar_url":"https://avatars0.githubusercontent.com/u/4063635?v=4","gravatar_id":"","url":"https://api.github.com/users/yf225","html_url":"https://github.com/yf225","followers_url":"https://api.github.com/users/yf225/followers","following_url":"https://api.github.com/users/yf225/following{/other_user}","gists_url":"https://api.github.com/users/yf225/gists{/gist_id}","starred_url":"https://api.github.com/users/yf225/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yf225/subscriptions","organizations_url":"https://api.github.com/users/yf225/orgs","repos_url":"https://api.github.com/users/yf225/repos","events_url":"https://api.github.com/users/yf225/events{/privacy}","received_events_url":"https://api.github.com/users/yf225/received_events","type":"User","site_admin":false},"body":"Fixed","created_at":"2018-07-22T05:05:52Z","updated_at":"2018-07-22T05:05:52Z","html_url":"https://github.com/pytorch/pytorch/pull/9279#discussion_r204228057","pull_request_url":"https://api.github.com/repos/pytorch/pytorch/pulls/9279","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/204228057"},"html":{"href":"https://github.com/pytorch/pytorch/pull/9279#discussion_r204228057"},"pull_request":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/9279"}},"in_reply_to_id":204176357},"pull_request":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/9279","id":200196735,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwMTk2NzM1","html_url":"https://github.com/pytorch/pytorch/pull/9279","diff_url":"https://github.com/pytorch/pytorch/pull/9279.diff","patch_url":"https://github.com/pytorch/pytorch/pull/9279.patch","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/9279","number":9279,"state":"open","locked":false,"title":"[READY] Preserve sparse tensor shape and dim invariants, and add scalar tensor support","user":{"login":"yf225","id":4063635,"node_id":"MDQ6VXNlcjQwNjM2MzU=","avatar_url":"https://avatars0.githubusercontent.com/u/4063635?v=4","gravatar_id":"","url":"https://api.github.com/users/yf225","html_url":"https://github.com/yf225","followers_url":"https://api.github.com/users/yf225/followers","following_url":"https://api.github.com/users/yf225/following{/other_user}","gists_url":"https://api.github.com/users/yf225/gists{/gist_id}","starred_url":"https://api.github.com/users/yf225/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yf225/subscriptions","organizations_url":"https://api.github.com/users/yf225/orgs","repos_url":"https://api.github.com/users/yf225/repos","events_url":"https://api.github.com/users/yf225/events{/privacy}","received_events_url":"https://api.github.com/users/yf225/received_events","type":"User","site_admin":false},"body":"When 0-sized dimension support is added, we expect an empty sparse tensor to be a 1-dimensional tensor of size `[0]`, with `sparseDims == 1` and `denseDims == 0`. Also, we expect the following invariants to be preserved at all times:\r\n\r\n```\r\n_sparseDims + _denseDims = len(shape)\r\n_indices.shape: dimensionality: 2,  shape: (_sparseDims, nnz)\r\n_values.shape:  dimensionality: 1 + _denseDims.  shape: (nnz, shape[_sparseDims:])\r\n```\r\n\r\nThis PR fixes various places where the invariants are not strictly enforced when 0-sized dimension support is enabled.\r\n\r\nTested and `test_sparse.py` passes locally on both CPU and CUDA with the `USE_TH_SIZE_ZERO_DIM` flag.","created_at":"2018-07-09T19:28:32Z","updated_at":"2018-07-22T05:05:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"72a720d73e3fa1c9021e7b7d5067f846499d0218","assignee":null,"assignees":[],"requested_reviewers":[{"login":"ezyang","id":13564,"node_id":"MDQ6VXNlcjEzNTY0","avatar_url":"https://avatars0.githubusercontent.com/u/13564?v=4","gravatar_id":"","url":"https://api.github.com/users/ezyang","html_url":"https://github.com/ezyang","followers_url":"https://api.github.com/users/ezyang/followers","following_url":"https://api.github.com/users/ezyang/following{/other_user}","gists_url":"https://api.github.com/users/ezyang/gists{/gist_id}","starred_url":"https://api.github.com/users/ezyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezyang/subscriptions","organizations_url":"https://api.github.com/users/ezyang/orgs","repos_url":"https://api.github.com/users/ezyang/repos","events_url":"https://api.github.com/users/ezyang/events{/privacy}","received_events_url":"https://api.github.com/users/ezyang/received_events","type":"User","site_admin":false},{"login":"zdevito","id":370202,"node_id":"MDQ6VXNlcjM3MDIwMg==","avatar_url":"https://avatars0.githubusercontent.com/u/370202?v=4","gravatar_id":"","url":"https://api.github.com/users/zdevito","html_url":"https://github.com/zdevito","followers_url":"https://api.github.com/users/zdevito/followers","following_url":"https://api.github.com/users/zdevito/following{/other_user}","gists_url":"https://api.github.com/users/zdevito/gists{/gist_id}","starred_url":"https://api.github.com/users/zdevito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zdevito/subscriptions","organizations_url":"https://api.github.com/users/zdevito/orgs","repos_url":"https://api.github.com/users/zdevito/repos","events_url":"https://api.github.com/users/zdevito/events{/privacy}","received_events_url":"https://api.github.com/users/zdevito/received_events","type":"User","site_admin":false},{"login":"colesbury","id":655866,"node_id":"MDQ6VXNlcjY1NTg2Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/655866?v=4","gravatar_id":"","url":"https://api.github.com/users/colesbury","html_url":"https://github.com/colesbury","followers_url":"https://api.github.com/users/colesbury/followers","following_url":"https://api.github.com/users/colesbury/following{/other_user}","gists_url":"https://api.github.com/users/colesbury/gists{/gist_id}","starred_url":"https://api.github.com/users/colesbury/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colesbury/subscriptions","organizations_url":"https://api.github.com/users/colesbury/orgs","repos_url":"https://api.github.com/users/colesbury/repos","events_url":"https://api.github.com/users/colesbury/events{/privacy}","received_events_url":"https://api.github.com/users/colesbury/received_events","type":"User","site_admin":false},{"login":"soumith","id":1310570,"node_id":"MDQ6VXNlcjEzMTA1NzA=","avatar_url":"https://avatars0.githubusercontent.com/u/1310570?v=4","gravatar_id":"","url":"https://api.github.com/users/soumith","html_url":"https://github.com/soumith","followers_url":"https://api.github.com/users/soumith/followers","following_url":"https://api.github.com/users/soumith/following{/other_user}","gists_url":"https://api.github.com/users/soumith/gists{/gist_id}","starred_url":"https://api.github.com/users/soumith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soumith/subscriptions","organizations_url":"https://api.github.com/users/soumith/orgs","repos_url":"https://api.github.com/users/soumith/repos","events_url":"https://api.github.com/users/soumith/events{/privacy}","received_events_url":"https://api.github.com/users/soumith/received_events","type":"User","site_admin":false},{"login":"apaszke","id":4583066,"node_id":"MDQ6VXNlcjQ1ODMwNjY=","avatar_url":"https://avatars3.githubusercontent.com/u/4583066?v=4","gravatar_id":"","url":"https://api.github.com/users/apaszke","html_url":"https://github.com/apaszke","followers_url":"https://api.github.com/users/apaszke/followers","following_url":"https://api.github.com/users/apaszke/following{/other_user}","gists_url":"https://api.github.com/users/apaszke/gists{/gist_id}","starred_url":"https://api.github.com/users/apaszke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apaszke/subscriptions","organizations_url":"https://api.github.com/users/apaszke/orgs","repos_url":"https://api.github.com/users/apaszke/repos","events_url":"https://api.github.com/users/apaszke/events{/privacy}","received_events_url":"https://api.github.com/users/apaszke/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pytorch/pytorch/pulls/9279/commits","review_comments_url":"https://api.github.com/repos/pytorch/pytorch/pulls/9279/comments","review_comment_url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/9279/comments","statuses_url":"https://api.github.com/repos/pytorch/pytorch/statuses/26d31a7c29b38b5d9742c66d7c6912e9b89c5e3e","head":{"label":"yf225:sparse_zero_dim","ref":"sparse_zero_dim","sha":"26d31a7c29b38b5d9742c66d7c6912e9b89c5e3e","user":{"login":"yf225","id":4063635,"node_id":"MDQ6VXNlcjQwNjM2MzU=","avatar_url":"https://avatars0.githubusercontent.com/u/4063635?v=4","gravatar_id":"","url":"https://api.github.com/users/yf225","html_url":"https://github.com/yf225","followers_url":"https://api.github.com/users/yf225/followers","following_url":"https://api.github.com/users/yf225/following{/other_user}","gists_url":"https://api.github.com/users/yf225/gists{/gist_id}","starred_url":"https://api.github.com/users/yf225/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yf225/subscriptions","organizations_url":"https://api.github.com/users/yf225/orgs","repos_url":"https://api.github.com/users/yf225/repos","events_url":"https://api.github.com/users/yf225/events{/privacy}","received_events_url":"https://api.github.com/users/yf225/received_events","type":"User","site_admin":false},"repo":{"id":113096813,"node_id":"MDEwOlJlcG9zaXRvcnkxMTMwOTY4MTM=","name":"pytorch","full_name":"yf225/pytorch","owner":{"login":"yf225","id":4063635,"node_id":"MDQ6VXNlcjQwNjM2MzU=","avatar_url":"https://avatars0.githubusercontent.com/u/4063635?v=4","gravatar_id":"","url":"https://api.github.com/users/yf225","html_url":"https://github.com/yf225","followers_url":"https://api.github.com/users/yf225/followers","following_url":"https://api.github.com/users/yf225/following{/other_user}","gists_url":"https://api.github.com/users/yf225/gists{/gist_id}","starred_url":"https://api.github.com/users/yf225/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yf225/subscriptions","organizations_url":"https://api.github.com/users/yf225/orgs","repos_url":"https://api.github.com/users/yf225/repos","events_url":"https://api.github.com/users/yf225/events{/privacy}","received_events_url":"https://api.github.com/users/yf225/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yf225/pytorch","description":"Tensors and Dynamic neural networks in Python  with strong GPU acceleration","fork":true,"url":"https://api.github.com/repos/yf225/pytorch","forks_url":"https://api.github.com/repos/yf225/pytorch/forks","keys_url":"https://api.github.com/repos/yf225/pytorch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yf225/pytorch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yf225/pytorch/teams","hooks_url":"https://api.github.com/repos/yf225/pytorch/hooks","issue_events_url":"https://api.github.com/repos/yf225/pytorch/issues/events{/number}","events_url":"https://api.github.com/repos/yf225/pytorch/events","assignees_url":"https://api.github.com/repos/yf225/pytorch/assignees{/user}","branches_url":"https://api.github.com/repos/yf225/pytorch/branches{/branch}","tags_url":"https://api.github.com/repos/yf225/pytorch/tags","blobs_url":"https://api.github.com/repos/yf225/pytorch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yf225/pytorch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yf225/pytorch/git/refs{/sha}","trees_url":"https://api.github.com/repos/yf225/pytorch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yf225/pytorch/statuses/{sha}","languages_url":"https://api.github.com/repos/yf225/pytorch/languages","stargazers_url":"https://api.github.com/repos/yf225/pytorch/stargazers","contributors_url":"https://api.github.com/repos/yf225/pytorch/contributors","subscribers_url":"https://api.github.com/repos/yf225/pytorch/subscribers","subscription_url":"https://api.github.com/repos/yf225/pytorch/subscription","commits_url":"https://api.github.com/repos/yf225/pytorch/commits{/sha}","git_commits_url":"https://api.github.com/repos/yf225/pytorch/git/commits{/sha}","comments_url":"https://api.github.com/repos/yf225/pytorch/comments{/number}","issue_comment_url":"https://api.github.com/repos/yf225/pytorch/issues/comments{/number}","contents_url":"https://api.github.com/repos/yf225/pytorch/contents/{+path}","compare_url":"https://api.github.com/repos/yf225/pytorch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yf225/pytorch/merges","archive_url":"https://api.github.com/repos/yf225/pytorch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yf225/pytorch/downloads","issues_url":"https://api.github.com/repos/yf225/pytorch/issues{/number}","pulls_url":"https://api.github.com/repos/yf225/pytorch/pulls{/number}","milestones_url":"https://api.github.com/repos/yf225/pytorch/milestones{/number}","notifications_url":"https://api.github.com/repos/yf225/pytorch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yf225/pytorch/labels{/name}","releases_url":"https://api.github.com/repos/yf225/pytorch/releases{/id}","deployments_url":"https://api.github.com/repos/yf225/pytorch/deployments","created_at":"2017-12-04T21:25:08Z","updated_at":"2018-07-18T20:08:50Z","pushed_at":"2018-07-22T05:04:51Z","git_url":"git://github.com/yf225/pytorch.git","ssh_url":"git@github.com:yf225/pytorch.git","clone_url":"https://github.com/yf225/pytorch.git","svn_url":"https://github.com/yf225/pytorch","homepage":"http://pytorch.org","size":63889,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pytorch:master","ref":"master","sha":"8769fec03fcf9318f19da538b5d488d2f97ecbaa","user":{"login":"pytorch","id":21003710,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMDAzNzEw","avatar_url":"https://avatars3.githubusercontent.com/u/21003710?v=4","gravatar_id":"","url":"https://api.github.com/users/pytorch","html_url":"https://github.com/pytorch","followers_url":"https://api.github.com/users/pytorch/followers","following_url":"https://api.github.com/users/pytorch/following{/other_user}","gists_url":"https://api.github.com/users/pytorch/gists{/gist_id}","starred_url":"https://api.github.com/users/pytorch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pytorch/subscriptions","organizations_url":"https://api.github.com/users/pytorch/orgs","repos_url":"https://api.github.com/users/pytorch/repos","events_url":"https://api.github.com/users/pytorch/events{/privacy}","received_events_url":"https://api.github.com/users/pytorch/received_events","type":"Organization","site_admin":false},"repo":{"id":65600975,"node_id":"MDEwOlJlcG9zaXRvcnk2NTYwMDk3NQ==","name":"pytorch","full_name":"pytorch/pytorch","owner":{"login":"pytorch","id":21003710,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMDAzNzEw","avatar_url":"https://avatars3.githubusercontent.com/u/21003710?v=4","gravatar_id":"","url":"https://api.github.com/users/pytorch","html_url":"https://github.com/pytorch","followers_url":"https://api.github.com/users/pytorch/followers","following_url":"https://api.github.com/users/pytorch/following{/other_user}","gists_url":"https://api.github.com/users/pytorch/gists{/gist_id}","starred_url":"https://api.github.com/users/pytorch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pytorch/subscriptions","organizations_url":"https://api.github.com/users/pytorch/orgs","repos_url":"https://api.github.com/users/pytorch/repos","events_url":"https://api.github.com/users/pytorch/events{/privacy}","received_events_url":"https://api.github.com/users/pytorch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pytorch/pytorch","description":"Tensors and Dynamic neural networks in Python  with strong GPU acceleration","fork":false,"url":"https://api.github.com/repos/pytorch/pytorch","forks_url":"https://api.github.com/repos/pytorch/pytorch/forks","keys_url":"https://api.github.com/repos/pytorch/pytorch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pytorch/pytorch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pytorch/pytorch/teams","hooks_url":"https://api.github.com/repos/pytorch/pytorch/hooks","issue_events_url":"https://api.github.com/repos/pytorch/pytorch/issues/events{/number}","events_url":"https://api.github.com/repos/pytorch/pytorch/events","assignees_url":"https://api.github.com/repos/pytorch/pytorch/assignees{/user}","branches_url":"https://api.github.com/repos/pytorch/pytorch/branches{/branch}","tags_url":"https://api.github.com/repos/pytorch/pytorch/tags","blobs_url":"https://api.github.com/repos/pytorch/pytorch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pytorch/pytorch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pytorch/pytorch/git/refs{/sha}","trees_url":"https://api.github.com/repos/pytorch/pytorch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pytorch/pytorch/statuses/{sha}","languages_url":"https://api.github.com/repos/pytorch/pytorch/languages","stargazers_url":"https://api.github.com/repos/pytorch/pytorch/stargazers","contributors_url":"https://api.github.com/repos/pytorch/pytorch/contributors","subscribers_url":"https://api.github.com/repos/pytorch/pytorch/subscribers","subscription_url":"https://api.github.com/repos/pytorch/pytorch/subscription","commits_url":"https://api.github.com/repos/pytorch/pytorch/commits{/sha}","git_commits_url":"https://api.github.com/repos/pytorch/pytorch/git/commits{/sha}","comments_url":"https://api.github.com/repos/pytorch/pytorch/comments{/number}","issue_comment_url":"https://api.github.com/repos/pytorch/pytorch/issues/comments{/number}","contents_url":"https://api.github.com/repos/pytorch/pytorch/contents/{+path}","compare_url":"https://api.github.com/repos/pytorch/pytorch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pytorch/pytorch/merges","archive_url":"https://api.github.com/repos/pytorch/pytorch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pytorch/pytorch/downloads","issues_url":"https://api.github.com/repos/pytorch/pytorch/issues{/number}","pulls_url":"https://api.github.com/repos/pytorch/pytorch/pulls{/number}","milestones_url":"https://api.github.com/repos/pytorch/pytorch/milestones{/number}","notifications_url":"https://api.github.com/repos/pytorch/pytorch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pytorch/pytorch/labels{/name}","releases_url":"https://api.github.com/repos/pytorch/pytorch/releases{/id}","deployments_url":"https://api.github.com/repos/pytorch/pytorch/deployments","created_at":"2016-08-13T05:26:41Z","updated_at":"2018-07-22T04:40:02Z","pushed_at":"2018-07-22T05:04:52Z","git_url":"git://github.com/pytorch/pytorch.git","ssh_url":"git@github.com:pytorch/pytorch.git","clone_url":"https://github.com/pytorch/pytorch.git","svn_url":"https://github.com/pytorch/pytorch","homepage":"http://pytorch.org","size":64187,"stargazers_count":17249,"watchers_count":17249,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4023,"mirror_url":null,"archived":false,"open_issues_count":1484,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4023,"open_issues":1484,"watchers":17249,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/9279"},"html":{"href":"https://github.com/pytorch/pytorch/pull/9279"},"issue":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/9279"},"comments":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/9279/comments"},"review_comments":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/9279/comments"},"review_comment":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/9279/commits"},"statuses":{"href":"https://api.github.com/repos/pytorch/pytorch/statuses/26d31a7c29b38b5d9742c66d7c6912e9b89c5e3e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"yf225"}}