{"action":"created","comment":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/174967639","pull_request_review_id":104418235,"id":174967639,"diff_hunk":"@@ -0,0 +1,94 @@\n+# select_op Design\n+\n+## Introduction\n+\n+In golang, the **select** statement lets a goroutine wait on multiple \n+communication operations at the same time. The **select** blocks until\n+one of its cases can run, then executes the case.  If multiple cases\n+are ready to run, then one case is choosen at random to be executed.\n+\n+With the introduction of CSP for Paddle, we mimic this behavior by \n+creating a ***select_op***.  The ***select_op*** works in conjunction\n+with the **channel_send_op**, **channel_receive_op**, and \n+**channel_close_op**.\n+\n+## How to use it\n+\n+The **select_op** is available as a c++ operator.  However most users\n+will prefer to use the much simplier Python API.\n+\n+- **fluid.Select()**: Creates a Select block and adds it to the main\n+program block.  Within the select block, users can add cases by calling \n+**select.case** or **select.default** method.\n+\n+- **fluid.Select.case(channel_action, channel, result_variable)**: Represents\n+a fluid channel send/recv case.  This method creates a SelectCase block\n+guard and adds it to the Select block.  The arguments into this method tells\n+the select which channel operation to listen to.\n+\n+- **fluid.Select.default()**: Represents the fluid default case.  This default\n+case is executed if none of the channel send/recv cases are available to\n+execute.\n+\n+**Example:**\n+```\n+x = fill_constant(shape=[1], dtype=core.VarDesc.VarType.INT32, value=0)\n+y = fill_constant(shape=[1], dtype=core.VarDesc.VarType.INT32, value=1)\n+ \n+while_cond = fill_constant(shape=[1], dtype=core.VarDesc.VarType.BOOL, value=True)\n+while_op = While(cond=while_cond)    \n+ \n+with while_op.block():\n+    with fluid.Select() as select:\n+        with select.case(fluid.channel_send, channel, x):\n+            # Send x, then perform Fibonacci calculation on x and y\n+            x_tmp = fill_constant(shape=[1], dtype=core.VarDesc.VarType.INT32, value=0)\n+            assign(input=x, output=x_tmp)\n+            assign(input=y, output=x)\n+            assign(elementwise_add(x=x_tmp, y=y), output=y)\n+        with select.case(fluid.channel_recv, quit_channel, result2):","path":"doc/design/csp/select_op.md","position":49,"original_position":49,"commit_id":"1d120c9d9601735d634e3ea7201f9cbe6a585edc","original_commit_id":"1d120c9d9601735d634e3ea7201f9cbe6a585edc","user":{"login":"varunarora","id":629203,"avatar_url":"https://avatars0.githubusercontent.com/u/629203?v=4","gravatar_id":"","url":"https://api.github.com/users/varunarora","html_url":"https://github.com/varunarora","followers_url":"https://api.github.com/users/varunarora/followers","following_url":"https://api.github.com/users/varunarora/following{/other_user}","gists_url":"https://api.github.com/users/varunarora/gists{/gist_id}","starred_url":"https://api.github.com/users/varunarora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varunarora/subscriptions","organizations_url":"https://api.github.com/users/varunarora/orgs","repos_url":"https://api.github.com/users/varunarora/repos","events_url":"https://api.github.com/users/varunarora/events{/privacy}","received_events_url":"https://api.github.com/users/varunarora/received_events","type":"User","site_admin":false},"body":"And `quit_channel`","created_at":"2018-03-16T00:03:44Z","updated_at":"2018-03-16T00:14:09Z","html_url":"https://github.com/PaddlePaddle/Paddle/pull/9139#discussion_r174967639","pull_request_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9139","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/174967639"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/9139#discussion_r174967639"},"pull_request":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9139"}},"in_reply_to_id":174967613},"pull_request":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9139","id":175405977,"html_url":"https://github.com/PaddlePaddle/Paddle/pull/9139","diff_url":"https://github.com/PaddlePaddle/Paddle/pull/9139.diff","patch_url":"https://github.com/PaddlePaddle/Paddle/pull/9139.patch","issue_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/9139","number":9139,"state":"open","locked":false,"title":"Create select_op design document","user":{"login":"cs2be","id":403396,"avatar_url":"https://avatars3.githubusercontent.com/u/403396?v=4","gravatar_id":"","url":"https://api.github.com/users/cs2be","html_url":"https://github.com/cs2be","followers_url":"https://api.github.com/users/cs2be/followers","following_url":"https://api.github.com/users/cs2be/following{/other_user}","gists_url":"https://api.github.com/users/cs2be/gists{/gist_id}","starred_url":"https://api.github.com/users/cs2be/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cs2be/subscriptions","organizations_url":"https://api.github.com/users/cs2be/orgs","repos_url":"https://api.github.com/users/cs2be/repos","events_url":"https://api.github.com/users/cs2be/events{/privacy}","received_events_url":"https://api.github.com/users/cs2be/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-15T23:33:37Z","updated_at":"2018-03-16T00:14:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b55ebe9aa3c31285b88fc4a29a92c986863f7788","assignee":null,"assignees":[],"requested_reviewers":[{"login":"abhinavarora","id":549367,"avatar_url":"https://avatars0.githubusercontent.com/u/549367?v=4","gravatar_id":"","url":"https://api.github.com/users/abhinavarora","html_url":"https://github.com/abhinavarora","followers_url":"https://api.github.com/users/abhinavarora/followers","following_url":"https://api.github.com/users/abhinavarora/following{/other_user}","gists_url":"https://api.github.com/users/abhinavarora/gists{/gist_id}","starred_url":"https://api.github.com/users/abhinavarora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhinavarora/subscriptions","organizations_url":"https://api.github.com/users/abhinavarora/orgs","repos_url":"https://api.github.com/users/abhinavarora/repos","events_url":"https://api.github.com/users/abhinavarora/events{/privacy}","received_events_url":"https://api.github.com/users/abhinavarora/received_events","type":"User","site_admin":false},{"login":"chengduoZH","id":30176695,"avatar_url":"https://avatars2.githubusercontent.com/u/30176695?v=4","gravatar_id":"","url":"https://api.github.com/users/chengduoZH","html_url":"https://github.com/chengduoZH","followers_url":"https://api.github.com/users/chengduoZH/followers","following_url":"https://api.github.com/users/chengduoZH/following{/other_user}","gists_url":"https://api.github.com/users/chengduoZH/gists{/gist_id}","starred_url":"https://api.github.com/users/chengduoZH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chengduoZH/subscriptions","organizations_url":"https://api.github.com/users/chengduoZH/orgs","repos_url":"https://api.github.com/users/chengduoZH/repos","events_url":"https://api.github.com/users/chengduoZH/events{/privacy}","received_events_url":"https://api.github.com/users/chengduoZH/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9139/commits","review_comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9139/comments","review_comment_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/9139/comments","statuses_url":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/1d120c9d9601735d634e3ea7201f9cbe6a585edc","head":{"label":"abhinavarora:SELECT_OP_DESIGN_DOC","ref":"SELECT_OP_DESIGN_DOC","sha":"1d120c9d9601735d634e3ea7201f9cbe6a585edc","user":{"login":"abhinavarora","id":549367,"avatar_url":"https://avatars0.githubusercontent.com/u/549367?v=4","gravatar_id":"","url":"https://api.github.com/users/abhinavarora","html_url":"https://github.com/abhinavarora","followers_url":"https://api.github.com/users/abhinavarora/followers","following_url":"https://api.github.com/users/abhinavarora/following{/other_user}","gists_url":"https://api.github.com/users/abhinavarora/gists{/gist_id}","starred_url":"https://api.github.com/users/abhinavarora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhinavarora/subscriptions","organizations_url":"https://api.github.com/users/abhinavarora/orgs","repos_url":"https://api.github.com/users/abhinavarora/repos","events_url":"https://api.github.com/users/abhinavarora/events{/privacy}","received_events_url":"https://api.github.com/users/abhinavarora/received_events","type":"User","site_admin":false},"repo":{"id":104604941,"name":"Paddle","full_name":"abhinavarora/Paddle","owner":{"login":"abhinavarora","id":549367,"avatar_url":"https://avatars0.githubusercontent.com/u/549367?v=4","gravatar_id":"","url":"https://api.github.com/users/abhinavarora","html_url":"https://github.com/abhinavarora","followers_url":"https://api.github.com/users/abhinavarora/followers","following_url":"https://api.github.com/users/abhinavarora/following{/other_user}","gists_url":"https://api.github.com/users/abhinavarora/gists{/gist_id}","starred_url":"https://api.github.com/users/abhinavarora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhinavarora/subscriptions","organizations_url":"https://api.github.com/users/abhinavarora/orgs","repos_url":"https://api.github.com/users/abhinavarora/repos","events_url":"https://api.github.com/users/abhinavarora/events{/privacy}","received_events_url":"https://api.github.com/users/abhinavarora/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abhinavarora/Paddle","description":"PArallel Distributed Deep LEarning","fork":true,"url":"https://api.github.com/repos/abhinavarora/Paddle","forks_url":"https://api.github.com/repos/abhinavarora/Paddle/forks","keys_url":"https://api.github.com/repos/abhinavarora/Paddle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abhinavarora/Paddle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abhinavarora/Paddle/teams","hooks_url":"https://api.github.com/repos/abhinavarora/Paddle/hooks","issue_events_url":"https://api.github.com/repos/abhinavarora/Paddle/issues/events{/number}","events_url":"https://api.github.com/repos/abhinavarora/Paddle/events","assignees_url":"https://api.github.com/repos/abhinavarora/Paddle/assignees{/user}","branches_url":"https://api.github.com/repos/abhinavarora/Paddle/branches{/branch}","tags_url":"https://api.github.com/repos/abhinavarora/Paddle/tags","blobs_url":"https://api.github.com/repos/abhinavarora/Paddle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abhinavarora/Paddle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abhinavarora/Paddle/git/refs{/sha}","trees_url":"https://api.github.com/repos/abhinavarora/Paddle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abhinavarora/Paddle/statuses/{sha}","languages_url":"https://api.github.com/repos/abhinavarora/Paddle/languages","stargazers_url":"https://api.github.com/repos/abhinavarora/Paddle/stargazers","contributors_url":"https://api.github.com/repos/abhinavarora/Paddle/contributors","subscribers_url":"https://api.github.com/repos/abhinavarora/Paddle/subscribers","subscription_url":"https://api.github.com/repos/abhinavarora/Paddle/subscription","commits_url":"https://api.github.com/repos/abhinavarora/Paddle/commits{/sha}","git_commits_url":"https://api.github.com/repos/abhinavarora/Paddle/git/commits{/sha}","comments_url":"https://api.github.com/repos/abhinavarora/Paddle/comments{/number}","issue_comment_url":"https://api.github.com/repos/abhinavarora/Paddle/issues/comments{/number}","contents_url":"https://api.github.com/repos/abhinavarora/Paddle/contents/{+path}","compare_url":"https://api.github.com/repos/abhinavarora/Paddle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abhinavarora/Paddle/merges","archive_url":"https://api.github.com/repos/abhinavarora/Paddle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abhinavarora/Paddle/downloads","issues_url":"https://api.github.com/repos/abhinavarora/Paddle/issues{/number}","pulls_url":"https://api.github.com/repos/abhinavarora/Paddle/pulls{/number}","milestones_url":"https://api.github.com/repos/abhinavarora/Paddle/milestones{/number}","notifications_url":"https://api.github.com/repos/abhinavarora/Paddle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abhinavarora/Paddle/labels{/name}","releases_url":"https://api.github.com/repos/abhinavarora/Paddle/releases{/id}","deployments_url":"https://api.github.com/repos/abhinavarora/Paddle/deployments","created_at":"2017-09-23T23:14:49Z","updated_at":"2018-03-15T23:40:29Z","pushed_at":"2018-03-15T23:42:01Z","git_url":"git://github.com/abhinavarora/Paddle.git","ssh_url":"git@github.com:abhinavarora/Paddle.git","clone_url":"https://github.com/abhinavarora/Paddle.git","svn_url":"https://github.com/abhinavarora/Paddle","homepage":"http://www.paddlepaddle.org/","size":71792,"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":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"PaddlePaddle:develop","ref":"develop","sha":"26a92083941770cd6f380eef2de040f85779afbc","user":{"login":"PaddlePaddle","id":23534030,"avatar_url":"https://avatars3.githubusercontent.com/u/23534030?v=4","gravatar_id":"","url":"https://api.github.com/users/PaddlePaddle","html_url":"https://github.com/PaddlePaddle","followers_url":"https://api.github.com/users/PaddlePaddle/followers","following_url":"https://api.github.com/users/PaddlePaddle/following{/other_user}","gists_url":"https://api.github.com/users/PaddlePaddle/gists{/gist_id}","starred_url":"https://api.github.com/users/PaddlePaddle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaddlePaddle/subscriptions","organizations_url":"https://api.github.com/users/PaddlePaddle/orgs","repos_url":"https://api.github.com/users/PaddlePaddle/repos","events_url":"https://api.github.com/users/PaddlePaddle/events{/privacy}","received_events_url":"https://api.github.com/users/PaddlePaddle/received_events","type":"Organization","site_admin":false},"repo":{"id":65711522,"name":"Paddle","full_name":"PaddlePaddle/Paddle","owner":{"login":"PaddlePaddle","id":23534030,"avatar_url":"https://avatars3.githubusercontent.com/u/23534030?v=4","gravatar_id":"","url":"https://api.github.com/users/PaddlePaddle","html_url":"https://github.com/PaddlePaddle","followers_url":"https://api.github.com/users/PaddlePaddle/followers","following_url":"https://api.github.com/users/PaddlePaddle/following{/other_user}","gists_url":"https://api.github.com/users/PaddlePaddle/gists{/gist_id}","starred_url":"https://api.github.com/users/PaddlePaddle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaddlePaddle/subscriptions","organizations_url":"https://api.github.com/users/PaddlePaddle/orgs","repos_url":"https://api.github.com/users/PaddlePaddle/repos","events_url":"https://api.github.com/users/PaddlePaddle/events{/privacy}","received_events_url":"https://api.github.com/users/PaddlePaddle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PaddlePaddle/Paddle","description":"PArallel Distributed Deep LEarning","fork":false,"url":"https://api.github.com/repos/PaddlePaddle/Paddle","forks_url":"https://api.github.com/repos/PaddlePaddle/Paddle/forks","keys_url":"https://api.github.com/repos/PaddlePaddle/Paddle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PaddlePaddle/Paddle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PaddlePaddle/Paddle/teams","hooks_url":"https://api.github.com/repos/PaddlePaddle/Paddle/hooks","issue_events_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/events{/number}","events_url":"https://api.github.com/repos/PaddlePaddle/Paddle/events","assignees_url":"https://api.github.com/repos/PaddlePaddle/Paddle/assignees{/user}","branches_url":"https://api.github.com/repos/PaddlePaddle/Paddle/branches{/branch}","tags_url":"https://api.github.com/repos/PaddlePaddle/Paddle/tags","blobs_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/refs{/sha}","trees_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/{sha}","languages_url":"https://api.github.com/repos/PaddlePaddle/Paddle/languages","stargazers_url":"https://api.github.com/repos/PaddlePaddle/Paddle/stargazers","contributors_url":"https://api.github.com/repos/PaddlePaddle/Paddle/contributors","subscribers_url":"https://api.github.com/repos/PaddlePaddle/Paddle/subscribers","subscription_url":"https://api.github.com/repos/PaddlePaddle/Paddle/subscription","commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/commits{/sha}","git_commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/git/commits{/sha}","comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/comments{/number}","issue_comment_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/comments{/number}","contents_url":"https://api.github.com/repos/PaddlePaddle/Paddle/contents/{+path}","compare_url":"https://api.github.com/repos/PaddlePaddle/Paddle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PaddlePaddle/Paddle/merges","archive_url":"https://api.github.com/repos/PaddlePaddle/Paddle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PaddlePaddle/Paddle/downloads","issues_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues{/number}","pulls_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls{/number}","milestones_url":"https://api.github.com/repos/PaddlePaddle/Paddle/milestones{/number}","notifications_url":"https://api.github.com/repos/PaddlePaddle/Paddle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PaddlePaddle/Paddle/labels{/name}","releases_url":"https://api.github.com/repos/PaddlePaddle/Paddle/releases{/id}","deployments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/deployments","created_at":"2016-08-15T06:59:08Z","updated_at":"2018-03-15T22:14:49Z","pushed_at":"2018-03-15T23:42:03Z","git_url":"git://github.com/PaddlePaddle/Paddle.git","ssh_url":"git@github.com:PaddlePaddle/Paddle.git","clone_url":"https://github.com/PaddlePaddle/Paddle.git","svn_url":"https://github.com/PaddlePaddle/Paddle","homepage":"http://www.paddlepaddle.org/","size":96167,"stargazers_count":6546,"watchers_count":6546,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1738,"mirror_url":null,"archived":false,"open_issues_count":1264,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1738,"open_issues":1264,"watchers":6546,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9139"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/9139"},"issue":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/9139"},"comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/9139/comments"},"review_comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9139/comments"},"review_comment":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/9139/commits"},"statuses":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/1d120c9d9601735d634e3ea7201f9cbe6a585edc"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"varunarora"}}