{"action":"created","comment":{"url":"https://api.github.com/repos/pytorch/glow/pulls/comments/225258538","pull_request_review_id":164821750,"id":225258538,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNTI1ODUzOA==","diff_hunk":"@@ -43,6 +43,51 @@ void Event::wait() {\n   cond_.wait(guard, [this] { return fired_ == true; });\n }\n \n+constexpr std::chrono::microseconds ThreadPool::kThreadBreakDuration;\n+\n+ThreadPool::ThreadPool(unsigned numWorkers) : shouldStop_(false) {\n+  // Intialize all workers and make each one run threadPoolWorkerMain.\n+  for (unsigned i = 0; i < numWorkers; i++) {\n+    std::thread th(std::bind(&ThreadPool::threadPoolWorkerMain, this));\n+    workers_.push_back(std::move(th));\n+  }\n+}\n+\n+ThreadPool::~ThreadPool() {\n+  // Signal to workers to stop.\n+  shouldStop_ = true;\n+\n+  // Join all worker threads.\n+  for (auto &w : workers_) {\n+    w.join();\n+  }\n+  workers_.clear();\n+}\n+\n+void ThreadPool::submit(const std::function<void(void)> &fn) {\n+  // Add fn to the work queue.\n+  std::lock_guard<std::mutex> lock(workQueueMtx_);\n+  workQueue_.push(std::move(fn));\n+}\n+\n+void ThreadPool::threadPoolWorkerMain() {\n+  while (!shouldStop_) {\n+    std::lock_guard<std::mutex> lock(workQueueMtx_);\n+\n+    if (!workQueue_.empty()) {\n+      // Pop and process a work item.\n+      auto workItem = std::move(workQueue_.front());\n+      workQueue_.pop();\n+      workItem();\n+    } else {\n+      // Wait for a while and then check the queue again.\n+      std::this_thread::sleep_for(kThreadBreakDuration);","path":"lib/Onnxifi/Base.cpp","position":42,"original_position":42,"commit_id":"3edfc83c3401e7bc4ec1a784216ebd37b2ce7cf2","original_commit_id":"3edfc83c3401e7bc4ec1a784216ebd37b2ce7cf2","user":{"login":"bertmaher","id":4441820,"node_id":"MDQ6VXNlcjQ0NDE4MjA=","avatar_url":"https://avatars1.githubusercontent.com/u/4441820?v=4","gravatar_id":"","url":"https://api.github.com/users/bertmaher","html_url":"https://github.com/bertmaher","followers_url":"https://api.github.com/users/bertmaher/followers","following_url":"https://api.github.com/users/bertmaher/following{/other_user}","gists_url":"https://api.github.com/users/bertmaher/gists{/gist_id}","starred_url":"https://api.github.com/users/bertmaher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bertmaher/subscriptions","organizations_url":"https://api.github.com/users/bertmaher/orgs","repos_url":"https://api.github.com/users/bertmaher/repos","events_url":"https://api.github.com/users/bertmaher/events{/privacy}","received_events_url":"https://api.github.com/users/bertmaher/received_events","type":"User","site_admin":false},"body":"Also probably want to release the mutex before sleeping.","created_at":"2018-10-15T17:50:09Z","updated_at":"2018-10-15T17:58:42Z","html_url":"https://github.com/pytorch/glow/pull/1870#discussion_r225258538","pull_request_url":"https://api.github.com/repos/pytorch/glow/pulls/1870","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/pytorch/glow/pulls/comments/225258538"},"html":{"href":"https://github.com/pytorch/glow/pull/1870#discussion_r225258538"},"pull_request":{"href":"https://api.github.com/repos/pytorch/glow/pulls/1870"}}},"pull_request":{"url":"https://api.github.com/repos/pytorch/glow/pulls/1870","id":222982945,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyOTgyOTQ1","html_url":"https://github.com/pytorch/glow/pull/1870","diff_url":"https://github.com/pytorch/glow/pull/1870.diff","patch_url":"https://github.com/pytorch/glow/pull/1870.patch","issue_url":"https://api.github.com/repos/pytorch/glow/issues/1870","number":1870,"state":"open","locked":false,"title":"[ONNXifi][WIP] Make onnxRunGraph execute Glow graph asynchronously","user":{"login":"SplitInfinity","id":4392003,"node_id":"MDQ6VXNlcjQzOTIwMDM=","avatar_url":"https://avatars0.githubusercontent.com/u/4392003?v=4","gravatar_id":"","url":"https://api.github.com/users/SplitInfinity","html_url":"https://github.com/SplitInfinity","followers_url":"https://api.github.com/users/SplitInfinity/followers","following_url":"https://api.github.com/users/SplitInfinity/following{/other_user}","gists_url":"https://api.github.com/users/SplitInfinity/gists{/gist_id}","starred_url":"https://api.github.com/users/SplitInfinity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SplitInfinity/subscriptions","organizations_url":"https://api.github.com/users/SplitInfinity/orgs","repos_url":"https://api.github.com/users/SplitInfinity/repos","events_url":"https://api.github.com/users/SplitInfinity/events{/privacy}","received_events_url":"https://api.github.com/users/SplitInfinity/received_events","type":"User","site_admin":false},"body":"**Description**\r\nThis commit modifies `onnxRunGraph` to make graph execution asynchronous\r\nby submitting it as a lambda to an instance of `ThreadPool` (a new class\r\nencapsulating a thread pool) stored in the `Graph` class. `ThreadPool`\r\nconsists of an adjustable number of threads that continuously pop and\r\nexecute an item from a common queue of `std::function<void(void)>` objects.\r\n\r\nThis commit fixes #1570.\r\n\r\n**Testing**\r\nThis commit has been tested on two known good ONNXifi tests, `test_concat_2d_axis_1`\r\nand `test_concat_2d_axis_1`:\r\n\r\n```\r\n$ .setuptools-cmake-build/onnxifi_test_driver_gtests /tmp/onnx_tests\r\n[==========] Running 2 tests from 1 test case.\r\n[----------] Global test environment set-up.\r\n[----------] 2 tests from ONNXCppAllTest/ONNXCppDriverTest\r\n[ RUN      ] ONNXCppAllTest/ONNXCppDriverTest.ONNXCppDriverUnitTest/test_concat_2d_axis_1\r\n[       OK ] ONNXCppAllTest/ONNXCppDriverTest.ONNXCppDriverUnitTest/test_concat_2d_axis_1 (89 ms)\r\n[ RUN      ] ONNXCppAllTest/ONNXCppDriverTest.ONNXCppDriverUnitTest/test_concat_3d_axis_1\r\n[       OK ] ONNXCppAllTest/ONNXCppDriverTest.ONNXCppDriverUnitTest/test_concat_3d_axis_1 (59 ms)\r\n[----------] 2 tests from ONNXCppAllTest/ONNXCppDriverTest (148 ms total)\r\n\r\n[----------] Global test environment tear-down\r\n[==========] 2 tests from 1 test case ran. (148 ms total)\r\n[  PASSED  ] 2 tests.\r\n```\r\n","created_at":"2018-10-15T17:24:56Z","updated_at":"2018-10-15T17:58:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93af7ba994dbd1a9eb85dc5053f2c62868069cd2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":706497924,"node_id":"MDU6TGFiZWw3MDY0OTc5MjQ=","url":"https://api.github.com/repos/pytorch/glow/labels/CLA%20Signed","name":"CLA Signed","color":"009900","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pytorch/glow/pulls/1870/commits","review_comments_url":"https://api.github.com/repos/pytorch/glow/pulls/1870/comments","review_comment_url":"https://api.github.com/repos/pytorch/glow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pytorch/glow/issues/1870/comments","statuses_url":"https://api.github.com/repos/pytorch/glow/statuses/3edfc83c3401e7bc4ec1a784216ebd37b2ce7cf2","head":{"label":"SplitInfinity:make-runGraph-async","ref":"make-runGraph-async","sha":"3edfc83c3401e7bc4ec1a784216ebd37b2ce7cf2","user":{"login":"SplitInfinity","id":4392003,"node_id":"MDQ6VXNlcjQzOTIwMDM=","avatar_url":"https://avatars0.githubusercontent.com/u/4392003?v=4","gravatar_id":"","url":"https://api.github.com/users/SplitInfinity","html_url":"https://github.com/SplitInfinity","followers_url":"https://api.github.com/users/SplitInfinity/followers","following_url":"https://api.github.com/users/SplitInfinity/following{/other_user}","gists_url":"https://api.github.com/users/SplitInfinity/gists{/gist_id}","starred_url":"https://api.github.com/users/SplitInfinity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SplitInfinity/subscriptions","organizations_url":"https://api.github.com/users/SplitInfinity/orgs","repos_url":"https://api.github.com/users/SplitInfinity/repos","events_url":"https://api.github.com/users/SplitInfinity/events{/privacy}","received_events_url":"https://api.github.com/users/SplitInfinity/received_events","type":"User","site_admin":false},"repo":{"id":148347894,"node_id":"MDEwOlJlcG9zaXRvcnkxNDgzNDc4OTQ=","name":"glow","full_name":"SplitInfinity/glow","private":false,"owner":{"login":"SplitInfinity","id":4392003,"node_id":"MDQ6VXNlcjQzOTIwMDM=","avatar_url":"https://avatars0.githubusercontent.com/u/4392003?v=4","gravatar_id":"","url":"https://api.github.com/users/SplitInfinity","html_url":"https://github.com/SplitInfinity","followers_url":"https://api.github.com/users/SplitInfinity/followers","following_url":"https://api.github.com/users/SplitInfinity/following{/other_user}","gists_url":"https://api.github.com/users/SplitInfinity/gists{/gist_id}","starred_url":"https://api.github.com/users/SplitInfinity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SplitInfinity/subscriptions","organizations_url":"https://api.github.com/users/SplitInfinity/orgs","repos_url":"https://api.github.com/users/SplitInfinity/repos","events_url":"https://api.github.com/users/SplitInfinity/events{/privacy}","received_events_url":"https://api.github.com/users/SplitInfinity/received_events","type":"User","site_admin":false},"html_url":"https://github.com/SplitInfinity/glow","description":"Compiler for Neural Network hardware accelerators","fork":true,"url":"https://api.github.com/repos/SplitInfinity/glow","forks_url":"https://api.github.com/repos/SplitInfinity/glow/forks","keys_url":"https://api.github.com/repos/SplitInfinity/glow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SplitInfinity/glow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SplitInfinity/glow/teams","hooks_url":"https://api.github.com/repos/SplitInfinity/glow/hooks","issue_events_url":"https://api.github.com/repos/SplitInfinity/glow/issues/events{/number}","events_url":"https://api.github.com/repos/SplitInfinity/glow/events","assignees_url":"https://api.github.com/repos/SplitInfinity/glow/assignees{/user}","branches_url":"https://api.github.com/repos/SplitInfinity/glow/branches{/branch}","tags_url":"https://api.github.com/repos/SplitInfinity/glow/tags","blobs_url":"https://api.github.com/repos/SplitInfinity/glow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SplitInfinity/glow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SplitInfinity/glow/git/refs{/sha}","trees_url":"https://api.github.com/repos/SplitInfinity/glow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SplitInfinity/glow/statuses/{sha}","languages_url":"https://api.github.com/repos/SplitInfinity/glow/languages","stargazers_url":"https://api.github.com/repos/SplitInfinity/glow/stargazers","contributors_url":"https://api.github.com/repos/SplitInfinity/glow/contributors","subscribers_url":"https://api.github.com/repos/SplitInfinity/glow/subscribers","subscription_url":"https://api.github.com/repos/SplitInfinity/glow/subscription","commits_url":"https://api.github.com/repos/SplitInfinity/glow/commits{/sha}","git_commits_url":"https://api.github.com/repos/SplitInfinity/glow/git/commits{/sha}","comments_url":"https://api.github.com/repos/SplitInfinity/glow/comments{/number}","issue_comment_url":"https://api.github.com/repos/SplitInfinity/glow/issues/comments{/number}","contents_url":"https://api.github.com/repos/SplitInfinity/glow/contents/{+path}","compare_url":"https://api.github.com/repos/SplitInfinity/glow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SplitInfinity/glow/merges","archive_url":"https://api.github.com/repos/SplitInfinity/glow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SplitInfinity/glow/downloads","issues_url":"https://api.github.com/repos/SplitInfinity/glow/issues{/number}","pulls_url":"https://api.github.com/repos/SplitInfinity/glow/pulls{/number}","milestones_url":"https://api.github.com/repos/SplitInfinity/glow/milestones{/number}","notifications_url":"https://api.github.com/repos/SplitInfinity/glow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SplitInfinity/glow/labels{/name}","releases_url":"https://api.github.com/repos/SplitInfinity/glow/releases{/id}","deployments_url":"https://api.github.com/repos/SplitInfinity/glow/deployments","created_at":"2018-09-11T16:36:14Z","updated_at":"2018-10-12T17:18:10Z","pushed_at":"2018-10-15T17:22:37Z","git_url":"git://github.com/SplitInfinity/glow.git","ssh_url":"git@github.com:SplitInfinity/glow.git","clone_url":"https://github.com/SplitInfinity/glow.git","svn_url":"https://github.com/SplitInfinity/glow","homepage":null,"size":9404,"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","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pytorch:master","ref":"master","sha":"8d9c9811bec0b176fb56f5fc483a6d47ccef4c32","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":105281531,"node_id":"MDEwOlJlcG9zaXRvcnkxMDUyODE1MzE=","name":"glow","full_name":"pytorch/glow","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/glow","description":"Compiler for Neural Network hardware accelerators","fork":false,"url":"https://api.github.com/repos/pytorch/glow","forks_url":"https://api.github.com/repos/pytorch/glow/forks","keys_url":"https://api.github.com/repos/pytorch/glow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pytorch/glow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pytorch/glow/teams","hooks_url":"https://api.github.com/repos/pytorch/glow/hooks","issue_events_url":"https://api.github.com/repos/pytorch/glow/issues/events{/number}","events_url":"https://api.github.com/repos/pytorch/glow/events","assignees_url":"https://api.github.com/repos/pytorch/glow/assignees{/user}","branches_url":"https://api.github.com/repos/pytorch/glow/branches{/branch}","tags_url":"https://api.github.com/repos/pytorch/glow/tags","blobs_url":"https://api.github.com/repos/pytorch/glow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pytorch/glow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pytorch/glow/git/refs{/sha}","trees_url":"https://api.github.com/repos/pytorch/glow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pytorch/glow/statuses/{sha}","languages_url":"https://api.github.com/repos/pytorch/glow/languages","stargazers_url":"https://api.github.com/repos/pytorch/glow/stargazers","contributors_url":"https://api.github.com/repos/pytorch/glow/contributors","subscribers_url":"https://api.github.com/repos/pytorch/glow/subscribers","subscription_url":"https://api.github.com/repos/pytorch/glow/subscription","commits_url":"https://api.github.com/repos/pytorch/glow/commits{/sha}","git_commits_url":"https://api.github.com/repos/pytorch/glow/git/commits{/sha}","comments_url":"https://api.github.com/repos/pytorch/glow/comments{/number}","issue_comment_url":"https://api.github.com/repos/pytorch/glow/issues/comments{/number}","contents_url":"https://api.github.com/repos/pytorch/glow/contents/{+path}","compare_url":"https://api.github.com/repos/pytorch/glow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pytorch/glow/merges","archive_url":"https://api.github.com/repos/pytorch/glow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pytorch/glow/downloads","issues_url":"https://api.github.com/repos/pytorch/glow/issues{/number}","pulls_url":"https://api.github.com/repos/pytorch/glow/pulls{/number}","milestones_url":"https://api.github.com/repos/pytorch/glow/milestones{/number}","notifications_url":"https://api.github.com/repos/pytorch/glow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pytorch/glow/labels{/name}","releases_url":"https://api.github.com/repos/pytorch/glow/releases{/id}","deployments_url":"https://api.github.com/repos/pytorch/glow/deployments","created_at":"2017-09-29T14:28:18Z","updated_at":"2018-10-15T17:38:44Z","pushed_at":"2018-10-15T17:45:11Z","git_url":"git://github.com/pytorch/glow.git","ssh_url":"git@github.com:pytorch/glow.git","clone_url":"https://github.com/pytorch/glow.git","svn_url":"https://github.com/pytorch/glow","homepage":null,"size":9432,"stargazers_count":921,"watchers_count":921,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":120,"mirror_url":null,"archived":false,"open_issues_count":72,"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":120,"open_issues":72,"watchers":921,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytorch/glow/pulls/1870"},"html":{"href":"https://github.com/pytorch/glow/pull/1870"},"issue":{"href":"https://api.github.com/repos/pytorch/glow/issues/1870"},"comments":{"href":"https://api.github.com/repos/pytorch/glow/issues/1870/comments"},"review_comments":{"href":"https://api.github.com/repos/pytorch/glow/pulls/1870/comments"},"review_comment":{"href":"https://api.github.com/repos/pytorch/glow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pytorch/glow/pulls/1870/commits"},"statuses":{"href":"https://api.github.com/repos/pytorch/glow/statuses/3edfc83c3401e7bc4ec1a784216ebd37b2ce7cf2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"bertmaher"}}