{"action":"created","comment":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/207771192","pull_request_review_id":143449005,"id":207771192,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNzc3MTE5Mg==","diff_hunk":"@@ -674,25 +674,40 @@ Caffe2Ops Caffe2Backend::CreateGemm(\n \n   auto trans_a = onnx_node->attributes.get<int64_t>(\"transA\", 0L);\n   auto trans_b = onnx_node->attributes.get<int64_t>(\"transB\", 0L);\n-  auto broadcast = onnx_node->attributes.get<int64_t>(\"broadcast\", 0L);\n+  // Support broadcast by default when opset_version > 6.\n+  auto broadcast =\n+    onnx_node->attributes.get<int64_t>(\"broadcast\",\n+                                       (ctx.opset_version() > 6) ? 1L : 0L);\n \n   bool use_fc = false;\n-  if ((!trans_a) && trans_b) {\n-    if (broadcast) {\n-      use_fc = true;\n-    } else {\n-      const auto input_c_vi_iter = ctx.value_infos().find(node.input(2));\n-      if (input_c_vi_iter != ctx.value_infos().end() &&\n-          input_c_vi_iter->second.type().tensor_type().shape().dim_size() ==\n-              1) {\n-        use_fc = true;\n+  if (!trans_a && broadcast) {\n+    // If we have broadcast and the input_c's dim matching the FC requirement,\n+    // we could convert this onnx op to caffe2 FC op.\n+    const auto input_c_vi_iter = ctx.value_infos().find(node.input(2));\n+    const auto input_b_vi_iter = ctx.value_infos().find(node.input(1));\n+    if (input_c_vi_iter != ctx.value_infos().end() &&\n+        input_c_vi_iter->second.type().tensor_type().has_shape() &&\n+        input_b_vi_iter != ctx.value_infos().end() &&\n+        input_b_vi_iter->second.type().tensor_type().has_shape()) {\n+      const auto input_c_shape = input_c_vi_iter->second.type().tensor_type().shape();\n+      const auto input_b_shape = input_b_vi_iter->second.type().tensor_type().shape();\n+      int input_b_last_dim_index = (trans_b) ? 0 : 1;\n+      if (input_c_shape.dim_size()==1 && input_c_shape.dim(0).has_dim_value() &&\n+          input_b_shape.dim_size()==2 && input_b_shape.dim(input_b_last_dim_index).has_dim_value()) {\n+        if (input_c_shape.dim(0).dim_value()==input_b_shape.dim(input_b_last_dim_index).dim_value()) {","path":"caffe2/onnx/backend.cc","position":34,"original_position":34,"commit_id":"05c571fcd0aef9c63b071ce6a1b213e243acf495","original_commit_id":"05c571fcd0aef9c63b071ce6a1b213e243acf495","user":{"login":"houseroad","id":30275821,"node_id":"MDQ6VXNlcjMwMjc1ODIx","avatar_url":"https://avatars0.githubusercontent.com/u/30275821?v=4","gravatar_id":"","url":"https://api.github.com/users/houseroad","html_url":"https://github.com/houseroad","followers_url":"https://api.github.com/users/houseroad/followers","following_url":"https://api.github.com/users/houseroad/following{/other_user}","gists_url":"https://api.github.com/users/houseroad/gists{/gist_id}","starred_url":"https://api.github.com/users/houseroad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houseroad/subscriptions","organizations_url":"https://api.github.com/users/houseroad/orgs","repos_url":"https://api.github.com/users/houseroad/repos","events_url":"https://api.github.com/users/houseroad/events{/privacy}","received_events_url":"https://api.github.com/users/houseroad/received_events","type":"User","site_admin":false},"body":"Very legit. @JerryShih could you address the above comments?","created_at":"2018-08-06T04:25:47Z","updated_at":"2018-08-06T04:25:47Z","html_url":"https://github.com/pytorch/pytorch/pull/10108#discussion_r207771192","pull_request_url":"https://api.github.com/repos/pytorch/pytorch/pulls/10108","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments/207771192"},"html":{"href":"https://github.com/pytorch/pytorch/pull/10108#discussion_r207771192"},"pull_request":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/10108"}},"in_reply_to_id":207768393},"pull_request":{"url":"https://api.github.com/repos/pytorch/pytorch/pulls/10108","id":205302571,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1MzAyNTcx","html_url":"https://github.com/pytorch/pytorch/pull/10108","diff_url":"https://github.com/pytorch/pytorch/pull/10108.diff","patch_url":"https://github.com/pytorch/pytorch/pull/10108.patch","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/10108","number":10108,"state":"open","locked":false,"title":"Update the onnx Gemm op to FC logic in caffe2 onnx backend","user":{"login":"JerryShih","id":5842681,"node_id":"MDQ6VXNlcjU4NDI2ODE=","avatar_url":"https://avatars3.githubusercontent.com/u/5842681?v=4","gravatar_id":"","url":"https://api.github.com/users/JerryShih","html_url":"https://github.com/JerryShih","followers_url":"https://api.github.com/users/JerryShih/followers","following_url":"https://api.github.com/users/JerryShih/following{/other_user}","gists_url":"https://api.github.com/users/JerryShih/gists{/gist_id}","starred_url":"https://api.github.com/users/JerryShih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JerryShih/subscriptions","organizations_url":"https://api.github.com/users/JerryShih/orgs","repos_url":"https://api.github.com/users/JerryShih/repos","events_url":"https://api.github.com/users/JerryShih/events{/privacy}","received_events_url":"https://api.github.com/users/JerryShih/received_events","type":"User","site_admin":false},"body":"The broadcast is used by default when the opset version is greater then 6.\r\n#9874\r\n","created_at":"2018-08-01T03:58:51Z","updated_at":"2018-08-06T04:25:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3de86b09e782edcf58f364872926b057d00aedcc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pytorch/pytorch/pulls/10108/commits","review_comments_url":"https://api.github.com/repos/pytorch/pytorch/pulls/10108/comments","review_comment_url":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/10108/comments","statuses_url":"https://api.github.com/repos/pytorch/pytorch/statuses/05c571fcd0aef9c63b071ce6a1b213e243acf495","head":{"label":"JerryShih:use-FC-for-Gemm","ref":"use-FC-for-Gemm","sha":"05c571fcd0aef9c63b071ce6a1b213e243acf495","user":{"login":"JerryShih","id":5842681,"node_id":"MDQ6VXNlcjU4NDI2ODE=","avatar_url":"https://avatars3.githubusercontent.com/u/5842681?v=4","gravatar_id":"","url":"https://api.github.com/users/JerryShih","html_url":"https://github.com/JerryShih","followers_url":"https://api.github.com/users/JerryShih/followers","following_url":"https://api.github.com/users/JerryShih/following{/other_user}","gists_url":"https://api.github.com/users/JerryShih/gists{/gist_id}","starred_url":"https://api.github.com/users/JerryShih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JerryShih/subscriptions","organizations_url":"https://api.github.com/users/JerryShih/orgs","repos_url":"https://api.github.com/users/JerryShih/repos","events_url":"https://api.github.com/users/JerryShih/events{/privacy}","received_events_url":"https://api.github.com/users/JerryShih/received_events","type":"User","site_admin":false},"repo":{"id":133468710,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM0Njg3MTA=","name":"pytorch","full_name":"JerryShih/pytorch","owner":{"login":"JerryShih","id":5842681,"node_id":"MDQ6VXNlcjU4NDI2ODE=","avatar_url":"https://avatars3.githubusercontent.com/u/5842681?v=4","gravatar_id":"","url":"https://api.github.com/users/JerryShih","html_url":"https://github.com/JerryShih","followers_url":"https://api.github.com/users/JerryShih/followers","following_url":"https://api.github.com/users/JerryShih/following{/other_user}","gists_url":"https://api.github.com/users/JerryShih/gists{/gist_id}","starred_url":"https://api.github.com/users/JerryShih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JerryShih/subscriptions","organizations_url":"https://api.github.com/users/JerryShih/orgs","repos_url":"https://api.github.com/users/JerryShih/repos","events_url":"https://api.github.com/users/JerryShih/events{/privacy}","received_events_url":"https://api.github.com/users/JerryShih/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JerryShih/pytorch","description":"Tensors and Dynamic neural networks in Python  with strong GPU acceleration","fork":true,"url":"https://api.github.com/repos/JerryShih/pytorch","forks_url":"https://api.github.com/repos/JerryShih/pytorch/forks","keys_url":"https://api.github.com/repos/JerryShih/pytorch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JerryShih/pytorch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JerryShih/pytorch/teams","hooks_url":"https://api.github.com/repos/JerryShih/pytorch/hooks","issue_events_url":"https://api.github.com/repos/JerryShih/pytorch/issues/events{/number}","events_url":"https://api.github.com/repos/JerryShih/pytorch/events","assignees_url":"https://api.github.com/repos/JerryShih/pytorch/assignees{/user}","branches_url":"https://api.github.com/repos/JerryShih/pytorch/branches{/branch}","tags_url":"https://api.github.com/repos/JerryShih/pytorch/tags","blobs_url":"https://api.github.com/repos/JerryShih/pytorch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JerryShih/pytorch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JerryShih/pytorch/git/refs{/sha}","trees_url":"https://api.github.com/repos/JerryShih/pytorch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JerryShih/pytorch/statuses/{sha}","languages_url":"https://api.github.com/repos/JerryShih/pytorch/languages","stargazers_url":"https://api.github.com/repos/JerryShih/pytorch/stargazers","contributors_url":"https://api.github.com/repos/JerryShih/pytorch/contributors","subscribers_url":"https://api.github.com/repos/JerryShih/pytorch/subscribers","subscription_url":"https://api.github.com/repos/JerryShih/pytorch/subscription","commits_url":"https://api.github.com/repos/JerryShih/pytorch/commits{/sha}","git_commits_url":"https://api.github.com/repos/JerryShih/pytorch/git/commits{/sha}","comments_url":"https://api.github.com/repos/JerryShih/pytorch/comments{/number}","issue_comment_url":"https://api.github.com/repos/JerryShih/pytorch/issues/comments{/number}","contents_url":"https://api.github.com/repos/JerryShih/pytorch/contents/{+path}","compare_url":"https://api.github.com/repos/JerryShih/pytorch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JerryShih/pytorch/merges","archive_url":"https://api.github.com/repos/JerryShih/pytorch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JerryShih/pytorch/downloads","issues_url":"https://api.github.com/repos/JerryShih/pytorch/issues{/number}","pulls_url":"https://api.github.com/repos/JerryShih/pytorch/pulls{/number}","milestones_url":"https://api.github.com/repos/JerryShih/pytorch/milestones{/number}","notifications_url":"https://api.github.com/repos/JerryShih/pytorch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JerryShih/pytorch/labels{/name}","releases_url":"https://api.github.com/repos/JerryShih/pytorch/releases{/id}","deployments_url":"https://api.github.com/repos/JerryShih/pytorch/deployments","created_at":"2018-05-15T06:22:50Z","updated_at":"2018-05-15T06:23:01Z","pushed_at":"2018-08-05T09:55:21Z","git_url":"git://github.com/JerryShih/pytorch.git","ssh_url":"git@github.com:JerryShih/pytorch.git","clone_url":"https://github.com/JerryShih/pytorch.git","svn_url":"https://github.com/JerryShih/pytorch","homepage":"http://pytorch.org","size":66410,"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":"f57e4ce1d59aab53e48b0ae93a7ef7e9a4dc1e2e","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-08-06T04:25:03Z","pushed_at":"2018-08-06T04:24:15Z","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":66786,"stargazers_count":17625,"watchers_count":17625,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4133,"mirror_url":null,"archived":false,"open_issues_count":1555,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4133,"open_issues":1555,"watchers":17625,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/10108"},"html":{"href":"https://github.com/pytorch/pytorch/pull/10108"},"issue":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/10108"},"comments":{"href":"https://api.github.com/repos/pytorch/pytorch/issues/10108/comments"},"review_comments":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/10108/comments"},"review_comment":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pytorch/pytorch/pulls/10108/commits"},"statuses":{"href":"https://api.github.com/repos/pytorch/pytorch/statuses/05c571fcd0aef9c63b071ce6a1b213e243acf495"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"houseroad"}}