{"action":"created","comment":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/236421798","pull_request_review_id":178494825,"id":236421798,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNjQyMTc5OA==","diff_hunk":"@@ -1009,14 +1019,236 @@ Operator(                                                                      \\\n });\n \n \n+// checking one of size & scale_factor is set\n+// if scale_factor is a double list check that it's len == dim\n+// reference: _check_size_scale_factor in torch/nn/functional.py\n+void _check_size_factor(size_t dim, const IValue& size, IValue scale_factor) {\n+  if (size.isNone() && scale_factor.isNone()) {\n+    throw std::runtime_error(\"either size or scale_factor should be defined\");\n+  }\n+  if (!size.isNone() && !scale_factor.isNone()) {\n+    throw std::runtime_error(\"only one of size or scale_factor should be defined\");\n+  }\n+  if (scale_factor.isDoubleList()) {\n+    auto scale_len = scale_factor.toDoubleListRef().size();\n+    if (scale_len != dim) {\n+      std::stringstream str;\n+      str << \"scale_factor shape must match input shape. Input is \" << dim\n+        << \"D, scale_factor size is \" << scale_len;\n+      throw std::runtime_error(\"only one of size or scale_factor should be defined\");\n+    }\n+  }\n+}\n+\n+// reference: _output_size in torch/nn/functional.py\n+// size can be none, int or intlist\n+// scale_factors can be none, float, or floatlist\n+std::vector<int64_t> _output_size(at::Tensor input, size_t dim, IValue size, IValue scale_factors) {\n+  if (!size.isNone()) {\n+    if (size.isInt()) {\n+      std::vector<int64_t> repeated(dim, size.toInt());\n+      return repeated;\n+    } else {\n+      return size.toIntListRef();\n+    }\n+  }\n+  std::vector<double> scale_repeated;\n+  if (scale_factors.isDouble()) {\n+    scale_repeated = std::vector<double>(dim, scale_factors.toDouble());\n+  } else {\n+    scale_repeated = scale_factors.toDoubleListRef();\n+  }\n+  std::vector<int64_t> ret;\n+  for (size_t i = 0; i < dim; ++i) {\n+    ret.push_back(std::floor(input.size(i + 2) * scale_repeated[i]));\n+  }\n+  return ret;\n+}\n+\n+// reference: interpolate in torch/nn/functional.py\n+// size can be none, int or intlist\n+// scale_factors can be none, float, or floatlist\n+at::Tensor interpolate(at::Tensor input, IValue size, IValue scale_factors,","path":"torch/csrc/jit/register_prim_ops.cpp","position":70,"original_position":70,"commit_id":"6a34860b6747d254e3a6ea147a876b4a599c936b","original_commit_id":"6a34860b6747d254e3a6ea147a876b4a599c936b","user":{"login":"eellison","id":11477974,"node_id":"MDQ6VXNlcjExNDc3OTc0","avatar_url":"https://avatars2.githubusercontent.com/u/11477974?v=4","gravatar_id":"","url":"https://api.github.com/users/eellison","html_url":"https://github.com/eellison","followers_url":"https://api.github.com/users/eellison/followers","following_url":"https://api.github.com/users/eellison/following{/other_user}","gists_url":"https://api.github.com/users/eellison/gists{/gist_id}","starred_url":"https://api.github.com/users/eellison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eellison/subscriptions","organizations_url":"https://api.github.com/users/eellison/orgs","repos_url":"https://api.github.com/users/eellison/repos","events_url":"https://api.github.com/users/eellison/events{/privacy}","received_events_url":"https://api.github.com/users/eellison/received_events","type":"User","site_admin":false},"body":"If it were a native function the function would have to have 4 different variants, one for each combination of size & scale_factor. Plus doing it this way makes the logic in c++ and the existing python function 1-1. \r\n\r\nIt is kind of annoying case. It might be better to move it to builtin_functions.cpp, but it would require having 4 variants and/or adding some overhead to support them, plus there are other features that are not yet implemented in builtin_functions that this would require. ","created_at":"2018-11-26T20:52:37Z","updated_at":"2018-11-26T20:52:37Z","html_url":"https://github.com/pytorch/pytorch/pull/14123#discussion_r236421798","pull_request_url":"https://api.github.com/repos/pytorch/pytorch/pulls/14123","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/236421798"},"html":{"href":"https://github.com/pytorch/pytorch/pull/14123#discussion_r236421798"},"pull_request":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/14123"}},"in_reply_to_id":236388080},"pull_request":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/14123","id":231668043,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxNjY4MDQz","html_url":"https://github.com/pytorch/pytorch/pull/14123","diff_url":"https://github.com/pytorch/pytorch/pull/14123.diff","patch_url":"https://github.com/pytorch/pytorch/pull/14123.patch","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/14123","number":14123,"state":"open","locked":false,"title":"interpolate","user":{"login":"eellison","id":11477974,"node_id":"MDQ6VXNlcjExNDc3OTc0","avatar_url":"https://avatars2.githubusercontent.com/u/11477974?v=4","gravatar_id":"","url":"https://api.github.com/users/eellison","html_url":"https://github.com/eellison","followers_url":"https://api.github.com/users/eellison/followers","following_url":"https://api.github.com/users/eellison/following{/other_user}","gists_url":"https://api.github.com/users/eellison/gists{/gist_id}","starred_url":"https://api.github.com/users/eellison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eellison/subscriptions","organizations_url":"https://api.github.com/users/eellison/orgs","repos_url":"https://api.github.com/users/eellison/repos","events_url":"https://api.github.com/users/eellison/events{/privacy}","received_events_url":"https://api.github.com/users/eellison/received_events","type":"User","site_admin":false},"body":"Add support for interpolate and upsampling in weak_script mode.\r\n\r\nBecause the function parameters are overloaded, i had to add it as a builtin op. For interpolate:\r\nsize can be ?int | int[]?, and scale_factor can be ?float | float[]?. Every combination of the two parameters needs to be supported. \r\n\r\nThe same logic applies for upsample_nearest, upsample_bilinear, and upsample. \r\n\r\nThere are a few fixes that I came to along the way.","created_at":"2018-11-16T22:03:29Z","updated_at":"2018-11-26T20:52:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aba6a8a868ca90dbf9715d5db035eae7954a9620","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":679953983,"node_id":"MDU6TGFiZWw2Nzk5NTM5ODM=","url":"https://api.github.com/repos/pytorch/pytorch/labels/jit","name":"jit","color":"c5def5","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pytorch/pytorch/pulls/14123/commits","review_comments_url":"https://api.github.com/repos/pytorch/pytorch/pulls/14123/comments","review_comment_url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/14123/comments","statuses_url":"https://api.github.com/repos/pytorch/pytorch/statuses/6a34860b6747d254e3a6ea147a876b4a599c936b","head":{"label":"eellison:interpolate","ref":"interpolate","sha":"6a34860b6747d254e3a6ea147a876b4a599c936b","user":{"login":"eellison","id":11477974,"node_id":"MDQ6VXNlcjExNDc3OTc0","avatar_url":"https://avatars2.githubusercontent.com/u/11477974?v=4","gravatar_id":"","url":"https://api.github.com/users/eellison","html_url":"https://github.com/eellison","followers_url":"https://api.github.com/users/eellison/followers","following_url":"https://api.github.com/users/eellison/following{/other_user}","gists_url":"https://api.github.com/users/eellison/gists{/gist_id}","starred_url":"https://api.github.com/users/eellison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eellison/subscriptions","organizations_url":"https://api.github.com/users/eellison/orgs","repos_url":"https://api.github.com/users/eellison/repos","events_url":"https://api.github.com/users/eellison/events{/privacy}","received_events_url":"https://api.github.com/users/eellison/received_events","type":"User","site_admin":false},"repo":{"id":138344849,"node_id":"MDEwOlJlcG9zaXRvcnkxMzgzNDQ4NDk=","name":"pytorch","full_name":"eellison/pytorch","private":false,"owner":{"login":"eellison","id":11477974,"node_id":"MDQ6VXNlcjExNDc3OTc0","avatar_url":"https://avatars2.githubusercontent.com/u/11477974?v=4","gravatar_id":"","url":"https://api.github.com/users/eellison","html_url":"https://github.com/eellison","followers_url":"https://api.github.com/users/eellison/followers","following_url":"https://api.github.com/users/eellison/following{/other_user}","gists_url":"https://api.github.com/users/eellison/gists{/gist_id}","starred_url":"https://api.github.com/users/eellison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eellison/subscriptions","organizations_url":"https://api.github.com/users/eellison/orgs","repos_url":"https://api.github.com/users/eellison/repos","events_url":"https://api.github.com/users/eellison/events{/privacy}","received_events_url":"https://api.github.com/users/eellison/received_events","type":"User","site_admin":false},"html_url":"https://github.com/eellison/pytorch","description":"Tensors and Dynamic neural networks in Python  with strong GPU acceleration","fork":true,"url":"https://api.github.com/repos/eellison/pytorch","forks_url":"https://api.github.com/repos/eellison/pytorch/forks","keys_url":"https://api.github.com/repos/eellison/pytorch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eellison/pytorch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eellison/pytorch/teams","hooks_url":"https://api.github.com/repos/eellison/pytorch/hooks","issue_events_url":"https://api.github.com/repos/eellison/pytorch/issues/events{/number}","events_url":"https://api.github.com/repos/eellison/pytorch/events","assignees_url":"https://api.github.com/repos/eellison/pytorch/assignees{/user}","branches_url":"https://api.github.com/repos/eellison/pytorch/branches{/branch}","tags_url":"https://api.github.com/repos/eellison/pytorch/tags","blobs_url":"https://api.github.com/repos/eellison/pytorch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eellison/pytorch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eellison/pytorch/git/refs{/sha}","trees_url":"https://api.github.com/repos/eellison/pytorch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eellison/pytorch/statuses/{sha}","languages_url":"https://api.github.com/repos/eellison/pytorch/languages","stargazers_url":"https://api.github.com/repos/eellison/pytorch/stargazers","contributors_url":"https://api.github.com/repos/eellison/pytorch/contributors","subscribers_url":"https://api.github.com/repos/eellison/pytorch/subscribers","subscription_url":"https://api.github.com/repos/eellison/pytorch/subscription","commits_url":"https://api.github.com/repos/eellison/pytorch/commits{/sha}","git_commits_url":"https://api.github.com/repos/eellison/pytorch/git/commits{/sha}","comments_url":"https://api.github.com/repos/eellison/pytorch/comments{/number}","issue_comment_url":"https://api.github.com/repos/eellison/pytorch/issues/comments{/number}","contents_url":"https://api.github.com/repos/eellison/pytorch/contents/{+path}","compare_url":"https://api.github.com/repos/eellison/pytorch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eellison/pytorch/merges","archive_url":"https://api.github.com/repos/eellison/pytorch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eellison/pytorch/downloads","issues_url":"https://api.github.com/repos/eellison/pytorch/issues{/number}","pulls_url":"https://api.github.com/repos/eellison/pytorch/pulls{/number}","milestones_url":"https://api.github.com/repos/eellison/pytorch/milestones{/number}","notifications_url":"https://api.github.com/repos/eellison/pytorch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eellison/pytorch/labels{/name}","releases_url":"https://api.github.com/repos/eellison/pytorch/releases{/id}","deployments_url":"https://api.github.com/repos/eellison/pytorch/deployments","created_at":"2018-06-22T20:20:04Z","updated_at":"2018-07-11T00:38:23Z","pushed_at":"2018-11-21T17:45:32Z","git_url":"git://github.com/eellison/pytorch.git","ssh_url":"git@github.com:eellison/pytorch.git","clone_url":"https://github.com/eellison/pytorch.git","svn_url":"https://github.com/eellison/pytorch","homepage":"http://pytorch.org","size":86689,"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":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pytorch:master","ref":"master","sha":"8610ff1072574a9b5772add8d6b63298d9ec9acb","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","private":false,"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},"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-11-26T20:45:04Z","pushed_at":"2018-11-26T20:35:22Z","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":89767,"stargazers_count":21662,"watchers_count":21662,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5163,"mirror_url":null,"archived":false,"open_issues_count":2208,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":5163,"open_issues":2208,"watchers":21662,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/14123"},"html":{"href":"https://github.com/pytorch/pytorch/pull/14123"},"issue":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/14123"},"comments":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/14123/comments"},"review_comments":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/14123/comments"},"review_comment":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/14123/commits"},"statuses":{"href":"https://api.github.com/repos/pytorch/pytorch/statuses/6a34860b6747d254e3a6ea147a876b4a599c936b"}},"author_association":"NONE"}}
{"actor":{"display_login":"eellison"}}