{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/209112656","pull_request_review_id":145066265,"id":209112656,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTExMjY1Ng==","diff_hunk":"@@ -938,6 +952,11 @@ void TFFunctionPartition::diagnoseCopyToAccelerator(\n \n   // Try to determine a good source location to report.\n   auto loc = getUserSourceLocation(value);\n+  \n+  // Opaque handles can never be sent or passed as tenosr program arguments.\n+  // Deabstraction must have rejected this earlier.","path":"lib/SILOptimizer/Mandatory/TFPartition.cpp","position":null,"original_position":60,"commit_id":"50fe7a0b1a73deda50f68184e34328a001e79dc4","original_commit_id":"8b3b1726ffd2bc6e810fcb066838f6906881b6c6","user":{"login":"mhong","id":969799,"node_id":"MDQ6VXNlcjk2OTc5OQ==","avatar_url":"https://avatars3.githubusercontent.com/u/969799?v=4","gravatar_id":"","url":"https://api.github.com/users/mhong","html_url":"https://github.com/mhong","followers_url":"https://api.github.com/users/mhong/followers","following_url":"https://api.github.com/users/mhong/following{/other_user}","gists_url":"https://api.github.com/users/mhong/gists{/gist_id}","starred_url":"https://api.github.com/users/mhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhong/subscriptions","organizations_url":"https://api.github.com/users/mhong/orgs","repos_url":"https://api.github.com/users/mhong/repos","events_url":"https://api.github.com/users/mhong/events{/privacy}","received_events_url":"https://api.github.com/users/mhong/received_events","type":"User","site_admin":false},"body":"Can I write a non-@convention(tensorflow) public function today that creates a returns an opaque handle? If that's already rejected, I might have missed reading some code...\r\n\r\nOverall the reasoning looks solid. Thanks! Can you add it as a code comment to capture that piece of knowledge?","created_at":"2018-08-09T23:53:08Z","updated_at":"2018-08-09T23:53:08Z","html_url":"https://github.com/apple/swift/pull/18603#discussion_r209112656","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/18603","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/209112656"},"html":{"href":"https://github.com/apple/swift/pull/18603#discussion_r209112656"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/18603"}},"in_reply_to_id":209096055},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/18603","id":207454654,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3NDU0NjU0","html_url":"https://github.com/apple/swift/pull/18603","diff_url":"https://github.com/apple/swift/pull/18603.diff","patch_url":"https://github.com/apple/swift/pull/18603.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/18603","number":18603,"state":"open","locked":false,"title":"[GPE] Improve diagnostics for invalid use of opaque handles for send/receive or as tensor program arguments","user":{"login":"rxwei","id":856507,"node_id":"MDQ6VXNlcjg1NjUwNw==","avatar_url":"https://avatars0.githubusercontent.com/u/856507?v=4","gravatar_id":"","url":"https://api.github.com/users/rxwei","html_url":"https://github.com/rxwei","followers_url":"https://api.github.com/users/rxwei/followers","following_url":"https://api.github.com/users/rxwei/following{/other_user}","gists_url":"https://api.github.com/users/rxwei/gists{/gist_id}","starred_url":"https://api.github.com/users/rxwei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxwei/subscriptions","organizations_url":"https://api.github.com/users/rxwei/orgs","repos_url":"https://api.github.com/users/rxwei/repos","events_url":"https://api.github.com/users/rxwei/events{/privacy}","received_events_url":"https://api.github.com/users/rxwei/received_events","type":"User","site_admin":false},"body":"Opaque handles such as `VariantHandle` and `ResourceHandle` only reside in the TensorFlow graph. They cannot be sent, received, or returned from a tensor program. The diagnostics logic previously only handled cases where an opaque handle is being sent/received, but not when the opaque handle is classified as a result from the tensor program.\r\n\r\n- Diagnostics are now handled at places where they should occur, i.e., `TFFunctionPartition::diagnoseUsesFromHost` and `TFFunctionPartition::diagnoseCopyToHost`.\r\n\r\n- Method `TFFunctionPartition::diagnoseOpaqueHandleCopy` is added to generalize opaque handle diagnostics.\r\n\r\n    Given\r\n\r\n    ```swift\r\n    let dataset: SingleValueDataset = ...\r\n    _hostOp(dataset)\r\n    ```\r\n\r\n    Diagnostics will show\r\n    ```swift\r\n    let dataset: SingleValueDataset = ...\r\n        ^ value cannot be used by non-TensorFlow API\r\n    _hostOp(dataset)\r\n            ^ value used here\r\n    ```\r\n\r\n- When the function being partitioned is an accelerator-only function, it is fine to make the function return an opaque handle. In these cases, we allow `return` of opaque handles by checking whether `hostFn` is `isAcceleratorOnly()`. The `isReturning` helper function helps determine whether an instruction is returning its operand or preparing a tuple for the operand to be returned.\r\n\r\n- Extended `isUserIgnoredByPartitioning` to ignore `debug_value` consuming opaque handles even for `-Onone` builds. Since they do not have a host-side representation, they cannot be transferred to the host for debugging. More exploration for debugging opaque handles will come later.\r\n\r\n- Minor fixes for incorrect comments.\r\n\r\nThis patch resolves [SR-8498](https://bugs.swift.org/browse/SR-8498), and partially resolves [SR-8496](https://bugs.swift.org/browse/SR-8496).","created_at":"2018-08-09T21:53:19Z","updated_at":"2018-08-09T23:53:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"317afb957dbd95374e8ce178a545793ae7d50d67","assignee":null,"assignees":[],"requested_reviewers":[{"login":"lattner","id":15152540,"node_id":"MDQ6VXNlcjE1MTUyNTQw","avatar_url":"https://avatars0.githubusercontent.com/u/15152540?v=4","gravatar_id":"","url":"https://api.github.com/users/lattner","html_url":"https://github.com/lattner","followers_url":"https://api.github.com/users/lattner/followers","following_url":"https://api.github.com/users/lattner/following{/other_user}","gists_url":"https://api.github.com/users/lattner/gists{/gist_id}","starred_url":"https://api.github.com/users/lattner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lattner/subscriptions","organizations_url":"https://api.github.com/users/lattner/orgs","repos_url":"https://api.github.com/users/lattner/repos","events_url":"https://api.github.com/users/lattner/events{/privacy}","received_events_url":"https://api.github.com/users/lattner/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":955546636,"node_id":"MDU6TGFiZWw5NTU1NDY2MzY=","url":"https://api.github.com/repos/apple/swift/labels/tensorflow","name":"tensorflow","color":"EF6C00","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/18603/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/18603/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/18603/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/50fe7a0b1a73deda50f68184e34328a001e79dc4","head":{"label":"rxwei:debug_value","ref":"debug_value","sha":"50fe7a0b1a73deda50f68184e34328a001e79dc4","user":{"login":"rxwei","id":856507,"node_id":"MDQ6VXNlcjg1NjUwNw==","avatar_url":"https://avatars0.githubusercontent.com/u/856507?v=4","gravatar_id":"","url":"https://api.github.com/users/rxwei","html_url":"https://github.com/rxwei","followers_url":"https://api.github.com/users/rxwei/followers","following_url":"https://api.github.com/users/rxwei/following{/other_user}","gists_url":"https://api.github.com/users/rxwei/gists{/gist_id}","starred_url":"https://api.github.com/users/rxwei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxwei/subscriptions","organizations_url":"https://api.github.com/users/rxwei/orgs","repos_url":"https://api.github.com/users/rxwei/repos","events_url":"https://api.github.com/users/rxwei/events{/privacy}","received_events_url":"https://api.github.com/users/rxwei/received_events","type":"User","site_admin":false},"repo":{"id":136226896,"node_id":"MDEwOlJlcG9zaXRvcnkxMzYyMjY4OTY=","name":"swift","full_name":"rxwei/swift","owner":{"login":"rxwei","id":856507,"node_id":"MDQ6VXNlcjg1NjUwNw==","avatar_url":"https://avatars0.githubusercontent.com/u/856507?v=4","gravatar_id":"","url":"https://api.github.com/users/rxwei","html_url":"https://github.com/rxwei","followers_url":"https://api.github.com/users/rxwei/followers","following_url":"https://api.github.com/users/rxwei/following{/other_user}","gists_url":"https://api.github.com/users/rxwei/gists{/gist_id}","starred_url":"https://api.github.com/users/rxwei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxwei/subscriptions","organizations_url":"https://api.github.com/users/rxwei/orgs","repos_url":"https://api.github.com/users/rxwei/repos","events_url":"https://api.github.com/users/rxwei/events{/privacy}","received_events_url":"https://api.github.com/users/rxwei/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rxwei/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/rxwei/swift","forks_url":"https://api.github.com/repos/rxwei/swift/forks","keys_url":"https://api.github.com/repos/rxwei/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rxwei/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rxwei/swift/teams","hooks_url":"https://api.github.com/repos/rxwei/swift/hooks","issue_events_url":"https://api.github.com/repos/rxwei/swift/issues/events{/number}","events_url":"https://api.github.com/repos/rxwei/swift/events","assignees_url":"https://api.github.com/repos/rxwei/swift/assignees{/user}","branches_url":"https://api.github.com/repos/rxwei/swift/branches{/branch}","tags_url":"https://api.github.com/repos/rxwei/swift/tags","blobs_url":"https://api.github.com/repos/rxwei/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rxwei/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rxwei/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/rxwei/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rxwei/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/rxwei/swift/languages","stargazers_url":"https://api.github.com/repos/rxwei/swift/stargazers","contributors_url":"https://api.github.com/repos/rxwei/swift/contributors","subscribers_url":"https://api.github.com/repos/rxwei/swift/subscribers","subscription_url":"https://api.github.com/repos/rxwei/swift/subscription","commits_url":"https://api.github.com/repos/rxwei/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/rxwei/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/rxwei/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/rxwei/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/rxwei/swift/contents/{+path}","compare_url":"https://api.github.com/repos/rxwei/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rxwei/swift/merges","archive_url":"https://api.github.com/repos/rxwei/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rxwei/swift/downloads","issues_url":"https://api.github.com/repos/rxwei/swift/issues{/number}","pulls_url":"https://api.github.com/repos/rxwei/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/rxwei/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/rxwei/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rxwei/swift/labels{/name}","releases_url":"https://api.github.com/repos/rxwei/swift/releases{/id}","deployments_url":"https://api.github.com/repos/rxwei/swift/deployments","created_at":"2018-06-05T19:45:30Z","updated_at":"2018-08-01T09:36:40Z","pushed_at":"2018-08-09T23:47:58Z","git_url":"git://github.com/rxwei/swift.git","ssh_url":"git@github.com:rxwei/swift.git","clone_url":"https://github.com/rxwei/swift.git","svn_url":"https://github.com/rxwei/swift","homepage":"https://swift.org/","size":321590,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"tensorflow"}},"base":{"label":"apple:tensorflow","ref":"tensorflow","sha":"2a246dba222f09851134957e4e18cde263375f83","user":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":44838949,"node_id":"MDEwOlJlcG9zaXRvcnk0NDgzODk0OQ==","name":"swift","full_name":"apple/swift","owner":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apple/swift","description":"The Swift Programming Language","fork":false,"url":"https://api.github.com/repos/apple/swift","forks_url":"https://api.github.com/repos/apple/swift/forks","keys_url":"https://api.github.com/repos/apple/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift/teams","hooks_url":"https://api.github.com/repos/apple/swift/hooks","issue_events_url":"https://api.github.com/repos/apple/swift/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift/events","assignees_url":"https://api.github.com/repos/apple/swift/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift/tags","blobs_url":"https://api.github.com/repos/apple/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift/languages","stargazers_url":"https://api.github.com/repos/apple/swift/stargazers","contributors_url":"https://api.github.com/repos/apple/swift/contributors","subscribers_url":"https://api.github.com/repos/apple/swift/subscribers","subscription_url":"https://api.github.com/repos/apple/swift/subscription","commits_url":"https://api.github.com/repos/apple/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift/merges","archive_url":"https://api.github.com/repos/apple/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift/downloads","issues_url":"https://api.github.com/repos/apple/swift/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift/deployments","created_at":"2015-10-23T21:15:07Z","updated_at":"2018-08-09T23:29:53Z","pushed_at":"2018-08-09T23:48:53Z","git_url":"git://github.com/apple/swift.git","ssh_url":"git@github.com:apple/swift.git","clone_url":"https://github.com/apple/swift.git","svn_url":"https://github.com/apple/swift","homepage":"https://swift.org/","size":324194,"stargazers_count":44797,"watchers_count":44797,"language":"C++","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7067,"mirror_url":null,"archived":false,"open_issues_count":370,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":7067,"open_issues":370,"watchers":44797,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/18603"},"html":{"href":"https://github.com/apple/swift/pull/18603"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/18603"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/18603/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/18603/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/18603/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/50fe7a0b1a73deda50f68184e34328a001e79dc4"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"mhong"}}