{"action":"created","comment":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/108405332","pull_request_review_id":29432674,"id":108405332,"diff_hunk":"@@ -66,3 +66,59 @@ def unbind(tensor, dim=0):\n         dim (int): dimension to remove.\n     \"\"\"\n     return tuple(tensor.select(dim, i) for i in _range(tensor.size(dim)))\n+\n+\n+def btriunpack(LU_data, LU_pivots, mode='E', dtype=None):\n+    \"\"\"Unpacks the data and pivots from a batched LU factorization (btrifact) of a tensor.\n+\n+    Returns a tuple indexed by:\n+      0: The pivots.\n+      1: The L tensor.\n+      2: The U tensor.\n+\n+    The mode flag indicates what should be unpacked:\n+      'E' unpacks everything (data and pivots)\n+      'D' unpacks just the data\n+      'P' unpacks just the pivots\n+\n+    Arguments:\n+        LU_data (Tensor): The packed LU factorization data.\n+        LU_pivots (Tensor): The packed LU factorization pivots.\n+        mode (str): The mode indicating what should be unpacked.\n+    \"\"\"\n+    assert mode in ('E', 'D', 'P')\n+\n+    if mode in ('E', 'D'):\n+        nBatch, sz, _ = LU_data.size()\n+        I_U = torch.triu(torch.ones(sz, sz)).unsqueeze(0).expand(nBatch, sz, sz).type_as(LU_data).byte()\n+        I_L = 1 - I_U\n+        L = torch.zeros(LU_data.size()).type_as(LU_data)\n+        U = L.clone()\n+        if dtype is not None:\n+            L = L.type(dtype)\n+            U = U.type(dtype)\n+        L[torch.eye(sz).unsqueeze(0).expand(nBatch, sz, sz).type_as(LU_data).byte()] = 1.0","path":"torch/functional.py","position":35,"original_position":35,"commit_id":"f2028e913d8cf258eb80d3b26f38863be754d44a","original_commit_id":"f2028e913d8cf258eb80d3b26f38863be754d44a","user":{"login":"apaszke","id":4583066,"avatar_url":"https://avatars0.githubusercontent.com/u/4583066?v=3","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},"body":"See my comments above. It would be nice to separate it to a variable.","created_at":"2017-03-28T12:23:49Z","updated_at":"2017-03-28T12:28:18Z","html_url":"https://github.com/pytorch/pytorch/pull/1118#discussion_r108405332","pull_request_url":"https://api.github.com/repos/pytorch/pytorch/pulls/1118","_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/108405332"},"html":{"href":"https://github.com/pytorch/pytorch/pull/1118#discussion_r108405332"},"pull_request":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/1118"}}},"pull_request":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/1118","id":112857485,"html_url":"https://github.com/pytorch/pytorch/pull/1118","diff_url":"https://github.com/pytorch/pytorch/pull/1118.diff","patch_url":"https://github.com/pytorch/pytorch/pull/1118.patch","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/1118","number":1118,"state":"open","locked":false,"title":"Add btriunpack and update the btrifact test to use it.","user":{"login":"bamos","id":707462,"avatar_url":"https://avatars2.githubusercontent.com/u/707462?v=3","gravatar_id":"","url":"https://api.github.com/users/bamos","html_url":"https://github.com/bamos","followers_url":"https://api.github.com/users/bamos/followers","following_url":"https://api.github.com/users/bamos/following{/other_user}","gists_url":"https://api.github.com/users/bamos/gists{/gist_id}","starred_url":"https://api.github.com/users/bamos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bamos/subscriptions","organizations_url":"https://api.github.com/users/bamos/orgs","repos_url":"https://api.github.com/users/bamos/repos","events_url":"https://api.github.com/users/bamos/events{/privacy}","received_events_url":"https://api.github.com/users/bamos/received_events","type":"User","site_admin":false},"body":"I'm open to changes in the interface. I included `mode` for efficiency so that both aren't extracted if somebody only needs one. I included `dtype` for convenience because when only the pivots are being extracted, there is no way to know the type of the main LU data because the pivots are ints.","created_at":"2017-03-27T23:03:44Z","updated_at":"2017-03-28T12:28:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed8c47729672c489b5369cc9fbe08d851d5f4bd5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pytorch/pytorch/pulls/1118/commits","review_comments_url":"https://api.github.com/repos/pytorch/pytorch/pulls/1118/comments","review_comment_url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/1118/comments","statuses_url":"https://api.github.com/repos/pytorch/pytorch/statuses/f2028e913d8cf258eb80d3b26f38863be754d44a","head":{"label":"bamos:master","ref":"master","sha":"f2028e913d8cf258eb80d3b26f38863be754d44a","user":{"login":"bamos","id":707462,"avatar_url":"https://avatars2.githubusercontent.com/u/707462?v=3","gravatar_id":"","url":"https://api.github.com/users/bamos","html_url":"https://github.com/bamos","followers_url":"https://api.github.com/users/bamos/followers","following_url":"https://api.github.com/users/bamos/following{/other_user}","gists_url":"https://api.github.com/users/bamos/gists{/gist_id}","starred_url":"https://api.github.com/users/bamos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bamos/subscriptions","organizations_url":"https://api.github.com/users/bamos/orgs","repos_url":"https://api.github.com/users/bamos/repos","events_url":"https://api.github.com/users/bamos/events{/privacy}","received_events_url":"https://api.github.com/users/bamos/received_events","type":"User","site_admin":false},"repo":{"id":86391760,"name":"pytorch","full_name":"bamos/pytorch","owner":{"login":"bamos","id":707462,"avatar_url":"https://avatars2.githubusercontent.com/u/707462?v=3","gravatar_id":"","url":"https://api.github.com/users/bamos","html_url":"https://github.com/bamos","followers_url":"https://api.github.com/users/bamos/followers","following_url":"https://api.github.com/users/bamos/following{/other_user}","gists_url":"https://api.github.com/users/bamos/gists{/gist_id}","starred_url":"https://api.github.com/users/bamos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bamos/subscriptions","organizations_url":"https://api.github.com/users/bamos/orgs","repos_url":"https://api.github.com/users/bamos/repos","events_url":"https://api.github.com/users/bamos/events{/privacy}","received_events_url":"https://api.github.com/users/bamos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bamos/pytorch","description":"Tensors and Dynamic neural networks in Python  with strong GPU acceleration","fork":true,"url":"https://api.github.com/repos/bamos/pytorch","forks_url":"https://api.github.com/repos/bamos/pytorch/forks","keys_url":"https://api.github.com/repos/bamos/pytorch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bamos/pytorch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bamos/pytorch/teams","hooks_url":"https://api.github.com/repos/bamos/pytorch/hooks","issue_events_url":"https://api.github.com/repos/bamos/pytorch/issues/events{/number}","events_url":"https://api.github.com/repos/bamos/pytorch/events","assignees_url":"https://api.github.com/repos/bamos/pytorch/assignees{/user}","branches_url":"https://api.github.com/repos/bamos/pytorch/branches{/branch}","tags_url":"https://api.github.com/repos/bamos/pytorch/tags","blobs_url":"https://api.github.com/repos/bamos/pytorch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bamos/pytorch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bamos/pytorch/git/refs{/sha}","trees_url":"https://api.github.com/repos/bamos/pytorch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bamos/pytorch/statuses/{sha}","languages_url":"https://api.github.com/repos/bamos/pytorch/languages","stargazers_url":"https://api.github.com/repos/bamos/pytorch/stargazers","contributors_url":"https://api.github.com/repos/bamos/pytorch/contributors","subscribers_url":"https://api.github.com/repos/bamos/pytorch/subscribers","subscription_url":"https://api.github.com/repos/bamos/pytorch/subscription","commits_url":"https://api.github.com/repos/bamos/pytorch/commits{/sha}","git_commits_url":"https://api.github.com/repos/bamos/pytorch/git/commits{/sha}","comments_url":"https://api.github.com/repos/bamos/pytorch/comments{/number}","issue_comment_url":"https://api.github.com/repos/bamos/pytorch/issues/comments{/number}","contents_url":"https://api.github.com/repos/bamos/pytorch/contents/{+path}","compare_url":"https://api.github.com/repos/bamos/pytorch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bamos/pytorch/merges","archive_url":"https://api.github.com/repos/bamos/pytorch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bamos/pytorch/downloads","issues_url":"https://api.github.com/repos/bamos/pytorch/issues{/number}","pulls_url":"https://api.github.com/repos/bamos/pytorch/pulls{/number}","milestones_url":"https://api.github.com/repos/bamos/pytorch/milestones{/number}","notifications_url":"https://api.github.com/repos/bamos/pytorch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bamos/pytorch/labels{/name}","releases_url":"https://api.github.com/repos/bamos/pytorch/releases{/id}","deployments_url":"https://api.github.com/repos/bamos/pytorch/deployments","created_at":"2017-03-27T22:54:17Z","updated_at":"2017-03-27T22:54:21Z","pushed_at":"2017-03-27T23:00:19Z","git_url":"git://github.com/bamos/pytorch.git","ssh_url":"git@github.com:bamos/pytorch.git","clone_url":"https://github.com/bamos/pytorch.git","svn_url":"https://github.com/bamos/pytorch","homepage":"http://pytorch.org","size":9439,"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":"pytorch:master","ref":"master","sha":"e4b4e515cd5bd0246b38f6a41e38c6fe285eb084","user":{"login":"pytorch","id":21003710,"avatar_url":"https://avatars0.githubusercontent.com/u/21003710?v=3","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,"name":"pytorch","full_name":"pytorch/pytorch","owner":{"login":"pytorch","id":21003710,"avatar_url":"https://avatars0.githubusercontent.com/u/21003710?v=3","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":"2017-03-28T09:53:25Z","pushed_at":"2017-03-28T12:21:41Z","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":9438,"stargazers_count":4046,"watchers_count":4046,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":530,"mirror_url":null,"open_issues_count":138,"forks":530,"open_issues":138,"watchers":4046,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/1118"},"html":{"href":"https://github.com/pytorch/pytorch/pull/1118"},"issue":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/1118"},"comments":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/1118/comments"},"review_comments":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/1118/comments"},"review_comment":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/1118/commits"},"statuses":{"href":"https://api.github.com/repos/pytorch/pytorch/statuses/f2028e913d8cf258eb80d3b26f38863be754d44a"}}}}
{"actor":{"display_login":"apaszke"}}