{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-mxnet/pulls/comments/141460286","pull_request_review_id":65678084,"id":141460286,"diff_hunk":"@@ -253,6 +300,48 @@ inline bool type_assign(int *y, const int& x) {\n   }\n #endif\n \n+/*! \\brief assign stype to target_stype, if successful,\n+ *         assign dispatch_mode to target_dispatch\n+ */\n+inline bool storage_type_assign(int* stype,\n+                                const NDArrayStorageType target_stype,\n+                                DispatchMode* dispatch,\n+                                const DispatchMode target_dispatch) {","path":"src/operator/operator_common.h","position":135,"original_position":135,"commit_id":"473f6f9e63af79f59c71907caa32022ebf9b70ea","original_commit_id":"473f6f9e63af79f59c71907caa32022ebf9b70ea","user":{"login":"eric-haibin-lin","id":5545640,"avatar_url":"https://avatars1.githubusercontent.com/u/5545640?v=4","gravatar_id":"","url":"https://api.github.com/users/eric-haibin-lin","html_url":"https://github.com/eric-haibin-lin","followers_url":"https://api.github.com/users/eric-haibin-lin/followers","following_url":"https://api.github.com/users/eric-haibin-lin/following{/other_user}","gists_url":"https://api.github.com/users/eric-haibin-lin/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-haibin-lin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-haibin-lin/subscriptions","organizations_url":"https://api.github.com/users/eric-haibin-lin/orgs","repos_url":"https://api.github.com/users/eric-haibin-lin/repos","events_url":"https://api.github.com/users/eric-haibin-lin/events{/privacy}","received_events_url":"https://api.github.com/users/eric-haibin-lin/received_events","type":"User","site_admin":false},"body":"Usually you'll check whether the stype_assign is successful or not before assigning dispatch mode. If you want to separate the two, it makes all infer_storage function very lengthy. Such logic is common and I think we should use one function for convenience. I still think the original name `dispatch_on_storage` is better","created_at":"2017-09-27T20:34:45Z","updated_at":"2017-09-27T20:34:45Z","html_url":"https://github.com/apache/incubator-mxnet/pull/7947#discussion_r141460286","pull_request_url":"https://api.github.com/repos/apache/incubator-mxnet/pulls/7947","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-mxnet/pulls/comments/141460286"},"html":{"href":"https://github.com/apache/incubator-mxnet/pull/7947#discussion_r141460286"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-mxnet/pulls/7947"}},"in_reply_to_id":141441547},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-mxnet/pulls/7947","id":141915015,"html_url":"https://github.com/apache/incubator-mxnet/pull/7947","diff_url":"https://github.com/apache/incubator-mxnet/pull/7947.diff","patch_url":"https://github.com/apache/incubator-mxnet/pull/7947.patch","issue_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/7947","number":7947,"state":"open","locked":false,"title":"Refactor infer storage function for sparse operators.","user":{"login":"eric-haibin-lin","id":5545640,"avatar_url":"https://avatars1.githubusercontent.com/u/5545640?v=4","gravatar_id":"","url":"https://api.github.com/users/eric-haibin-lin","html_url":"https://github.com/eric-haibin-lin","followers_url":"https://api.github.com/users/eric-haibin-lin/followers","following_url":"https://api.github.com/users/eric-haibin-lin/following{/other_user}","gists_url":"https://api.github.com/users/eric-haibin-lin/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-haibin-lin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-haibin-lin/subscriptions","organizations_url":"https://api.github.com/users/eric-haibin-lin/orgs","repos_url":"https://api.github.com/users/eric-haibin-lin/repos","events_url":"https://api.github.com/users/eric-haibin-lin/events{/privacy}","received_events_url":"https://api.github.com/users/eric-haibin-lin/received_events","type":"User","site_admin":false},"body":"####  Background:\r\nThe current rule for graph executor to dispatch on `FCompute` & `FComputeEx` is naive: if any input/output contains non-default storage, `FComputeEx` will be preferred; otherwise, choose `FCompute`. \r\n\r\n#### Why it's bad:\r\n- Such dispatch rule may lead to the case where `FComputeEx` is registered and chosen to dispatch, but it's not capable of handle specific storage types, and need to fallback inside `FComputeEx`. Ideally, we want `FComputeEx` functions to be \"fallback-free\". \r\n- Since fallback requires temp resource on gpu, when fallback happens inside `FComputeEx`, the resource needs to be requested on the fly. This leads to unclear responsibility since all resource requests are expected to be handled in attach_exec_resource_pass. \r\n\r\n#### The new interface to fix it:\r\nWe should incorporate dispatch logic inside infer_storage_type pass with the new interface below:\r\n```cpp\r\nenum FcompDispatchMode {\r\n  kDispatchFCompute;\r\n  kDispatchFComputeEx;\r\n  kDispatchFComputeFallback;\r\n  ... \r\n}\r\n\r\ninline bool InferStorageType(const nnvm::NodeAttrs& attrs,\r\n    const int dev_mask,    // useful for MKL related storage inference\r\n    int *dispatch_mode,   // useful to determine if fallback is required\r\n    std::vector<int> *in_attrs,\r\n    std::vector<int> *out_attrs,\r\n) {}\r\n```\r\n\r\nDuring infer_storage_type pass, we will decide whether to dispatch for FComputeEx or FCompute based on attrs. When dispatch type is kFComputeFallback, extra resources are requested. \r\n\r\n#### Changes Summary\r\n- Updated infer_attr pass function for graph_executor, which now is able to infer attribute for node entries ((storage_type) and for the node itself (dispatch_mode). \r\n- The stype of gradients are [provided as inputs](https://github.com/apache/incubator-mxnet/pull/7947/files#diff-d8b5a5b027d00584737fb6486cba38b9R585) to InferStorage during Executor::Bind. \r\n- Added default [infer storage type](https://github.com/apache/incubator-mxnet/pull/7947/files#diff-4ccbea6a44e3cc4c99195a1e7c55c09eR321 ) function. If an operator doesn't have FInferStorageType attr set, this infer storage type function will be called. \r\n- Added warning messages when storage fallback is detected during inferstorage. It can be turned off via environment variable.\r\n-  Updated the infer storage function for all sparse operators and custom operators. \r\n-  Removed all FComputeFallback call inside FComputeEx\r\n-  Removed ad-hot storage resource requests in `cast_storage` \r\n-  Removed a kernel for SGD with dense grad and row_sparse weight.\r\n-  Disabled elemwise_binary_op for CSR inputs since we don't have any unit test for them. We should turn it back on after the test is in place. The operator should set `FResourceRequest` to get temp storage instead of doing that inside the operator \r\n- Added registration for many unary operators on gpu. They're already covered in `test_sparse_operator` when default_ctx is gpu. \r\n- Removed some unused functions in `test_sparse_operator.py`\r\n\r\n\r\n","created_at":"2017-09-19T17:54:09Z","updated_at":"2017-09-27T20:34:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9003b57d51d53932b2bad841bc60e46f89453fd4","assignee":null,"assignees":[],"requested_reviewers":[{"login":"mli","id":421857,"avatar_url":"https://avatars1.githubusercontent.com/u/421857?v=4","gravatar_id":"","url":"https://api.github.com/users/mli","html_url":"https://github.com/mli","followers_url":"https://api.github.com/users/mli/followers","following_url":"https://api.github.com/users/mli/following{/other_user}","gists_url":"https://api.github.com/users/mli/gists{/gist_id}","starred_url":"https://api.github.com/users/mli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mli/subscriptions","organizations_url":"https://api.github.com/users/mli/orgs","repos_url":"https://api.github.com/users/mli/repos","events_url":"https://api.github.com/users/mli/events{/privacy}","received_events_url":"https://api.github.com/users/mli/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-mxnet/pulls/7947/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-mxnet/pulls/7947/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-mxnet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/7947/comments","statuses_url":"https://api.github.com/repos/apache/incubator-mxnet/statuses/473f6f9e63af79f59c71907caa32022ebf9b70ea","head":{"label":"eric-haibin-lin:refactor","ref":"refactor","sha":"473f6f9e63af79f59c71907caa32022ebf9b70ea","user":{"login":"eric-haibin-lin","id":5545640,"avatar_url":"https://avatars1.githubusercontent.com/u/5545640?v=4","gravatar_id":"","url":"https://api.github.com/users/eric-haibin-lin","html_url":"https://github.com/eric-haibin-lin","followers_url":"https://api.github.com/users/eric-haibin-lin/followers","following_url":"https://api.github.com/users/eric-haibin-lin/following{/other_user}","gists_url":"https://api.github.com/users/eric-haibin-lin/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-haibin-lin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-haibin-lin/subscriptions","organizations_url":"https://api.github.com/users/eric-haibin-lin/orgs","repos_url":"https://api.github.com/users/eric-haibin-lin/repos","events_url":"https://api.github.com/users/eric-haibin-lin/events{/privacy}","received_events_url":"https://api.github.com/users/eric-haibin-lin/received_events","type":"User","site_admin":false},"repo":{"id":54802325,"name":"mxnet","full_name":"eric-haibin-lin/mxnet","owner":{"login":"eric-haibin-lin","id":5545640,"avatar_url":"https://avatars1.githubusercontent.com/u/5545640?v=4","gravatar_id":"","url":"https://api.github.com/users/eric-haibin-lin","html_url":"https://github.com/eric-haibin-lin","followers_url":"https://api.github.com/users/eric-haibin-lin/followers","following_url":"https://api.github.com/users/eric-haibin-lin/following{/other_user}","gists_url":"https://api.github.com/users/eric-haibin-lin/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-haibin-lin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-haibin-lin/subscriptions","organizations_url":"https://api.github.com/users/eric-haibin-lin/orgs","repos_url":"https://api.github.com/users/eric-haibin-lin/repos","events_url":"https://api.github.com/users/eric-haibin-lin/events{/privacy}","received_events_url":"https://api.github.com/users/eric-haibin-lin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eric-haibin-lin/mxnet","description":"Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Go, Javascript and more","fork":true,"url":"https://api.github.com/repos/eric-haibin-lin/mxnet","forks_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/forks","keys_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/teams","hooks_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/hooks","issue_events_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/issues/events{/number}","events_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/events","assignees_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/assignees{/user}","branches_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/branches{/branch}","tags_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/tags","blobs_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/statuses/{sha}","languages_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/languages","stargazers_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/stargazers","contributors_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/contributors","subscribers_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/subscribers","subscription_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/subscription","commits_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/contents/{+path}","compare_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/merges","archive_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/downloads","issues_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/issues{/number}","pulls_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/pulls{/number}","milestones_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/milestones{/number}","notifications_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/labels{/name}","releases_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/releases{/id}","deployments_url":"https://api.github.com/repos/eric-haibin-lin/mxnet/deployments","created_at":"2016-03-26T22:27:07Z","updated_at":"2017-08-16T18:29:36Z","pushed_at":"2017-09-27T06:06:09Z","git_url":"git://github.com/eric-haibin-lin/mxnet.git","ssh_url":"git@github.com:eric-haibin-lin/mxnet.git","clone_url":"https://github.com/eric-haibin-lin/mxnet.git","svn_url":"https://github.com/eric-haibin-lin/mxnet","homepage":"http://mxnet.rtfd.org","size":23332,"stargazers_count":7,"watchers_count":7,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":8,"forks":2,"open_issues":8,"watchers":7,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"4c0df6249d03841f5eb30e1428aa25fc230fed30","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":34864402,"name":"incubator-mxnet","full_name":"apache/incubator-mxnet","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-mxnet","description":"Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more","fork":false,"url":"https://api.github.com/repos/apache/incubator-mxnet","forks_url":"https://api.github.com/repos/apache/incubator-mxnet/forks","keys_url":"https://api.github.com/repos/apache/incubator-mxnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-mxnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-mxnet/teams","hooks_url":"https://api.github.com/repos/apache/incubator-mxnet/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-mxnet/events","assignees_url":"https://api.github.com/repos/apache/incubator-mxnet/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-mxnet/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-mxnet/tags","blobs_url":"https://api.github.com/repos/apache/incubator-mxnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-mxnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-mxnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-mxnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-mxnet/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-mxnet/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-mxnet/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-mxnet/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-mxnet/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-mxnet/subscription","commits_url":"https://api.github.com/repos/apache/incubator-mxnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-mxnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-mxnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-mxnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-mxnet/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-mxnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-mxnet/merges","archive_url":"https://api.github.com/repos/apache/incubator-mxnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-mxnet/downloads","issues_url":"https://api.github.com/repos/apache/incubator-mxnet/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-mxnet/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-mxnet/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-mxnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-mxnet/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-mxnet/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-mxnet/deployments","created_at":"2015-04-30T16:21:15Z","updated_at":"2017-09-27T18:54:50Z","pushed_at":"2017-09-27T20:23:57Z","git_url":"git://github.com/apache/incubator-mxnet.git","ssh_url":"git@github.com:apache/incubator-mxnet.git","clone_url":"https://github.com/apache/incubator-mxnet.git","svn_url":"https://github.com/apache/incubator-mxnet","homepage":"http://mxnet.io","size":21598,"stargazers_count":11309,"watchers_count":11309,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4239,"mirror_url":null,"open_issues_count":2053,"forks":4239,"open_issues":2053,"watchers":11309,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-mxnet/pulls/7947"},"html":{"href":"https://github.com/apache/incubator-mxnet/pull/7947"},"issue":{"href":"https://api.github.com/repos/apache/incubator-mxnet/issues/7947"},"comments":{"href":"https://api.github.com/repos/apache/incubator-mxnet/issues/7947/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-mxnet/pulls/7947/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-mxnet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-mxnet/pulls/7947/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-mxnet/statuses/473f6f9e63af79f59c71907caa32022ebf9b70ea"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"eric-haibin-lin"}}