{"action":"created","comment":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/198011633","pull_request_review_id":131862644,"id":198011633,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODAxMTYzMw==","diff_hunk":"@@ -0,0 +1,105 @@\n+//   Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+#pragma once\n+\n+#include <memory>\n+#include <vector>\n+\n+#include \"paddle/fluid/framework/ddim.h\"\n+#include \"paddle/fluid/framework/lod_tensor.h\"\n+#include \"paddle/fluid/operators/reader/blocking_queue.h\"\n+#include \"paddle/fluid/platform/place.h\"\n+\n+namespace paddle {\n+namespace operators {\n+namespace reader {\n+\n+class LoDTensorBlockingQueueHolder;\n+\n+class LoDTensorBlockingQueue {\n+  friend class LoDTensorBlockingQueueHolder;\n+\n+ private:\n+  LoDTensorBlockingQueue(size_t capacity,\n+                         const std::vector<framework::DDim>& dims)\n+      : queue_(capacity), dims_(dims) {}\n+\n+ public:\n+  bool Push(const std::vector<framework::LoDTensor>& lod_tensor_vec) {\n+    CheckDims(lod_tensor_vec);\n+    return queue_.Send(lod_tensor_vec);\n+  }\n+\n+  bool Push(std::vector<framework::LoDTensor>&& lod_tensor_vec) {\n+    CheckDims(lod_tensor_vec);\n+    return queue_.Send(std::move(lod_tensor_vec));\n+  }\n+\n+  std::vector<framework::LoDTensor> Pop(bool* ok = nullptr) {\n+    std::vector<framework::LoDTensor> lod_tensor_vec;\n+    bool success = queue_.Receive(&lod_tensor_vec);\n+    if (ok != nullptr) *ok = success;\n+    return lod_tensor_vec;\n+  }\n+\n+  inline size_t Cap() const { return queue_.Cap(); }\n+\n+  inline size_t Size() const { return queue_.Size(); }\n+\n+  inline void Close() { return queue_.Close(); }\n+\n+  inline bool IsClosed() const { return queue_.IsClosed(); }\n+\n+ private:\n+  void CheckDims(const std::vector<framework::LoDTensor>& lod_tensor_vec) {\n+    PADDLE_ENFORCE(dims_.size() == lod_tensor_vec.size(),\n+                   \"Expect input size is %d but found %s\", dims_.size(),\n+                   lod_tensor_vec.size());\n+    for (size_t i = 0; i < dims_.size(); ++i) {\n+      const auto& in_dims = framework::slice_ddim(\n+          lod_tensor_vec[i].dims(), 1, lod_tensor_vec[i].dims().size());\n+      const auto& expect_dims =\n+          framework::slice_ddim(dims_[i], 1, dims_[i].size());\n+      PADDLE_ENFORCE(in_dims == expect_dims,\n+                     \"Dims of the %d-th input tensor do not match\", i);\n+    }\n+  }\n+\n+  BlockingQueue<std::vector<framework::LoDTensor>> queue_;\n+  std::vector<framework::DDim> dims_;\n+};\n+\n+class LoDTensorBlockingQueueHolder {\n+ public:\n+  void InitOnce(size_t capacity, const std::vector<framework::DDim>& dims) {\n+    PADDLE_ENFORCE(\n+        queue_ == nullptr,\n+        \"LoDTensorBlockingQueueHolder::InitOnce() can only be called once\");\n+    queue_.reset(new LoDTensorBlockingQueue(capacity, dims));\n+  }\n+\n+  inline std::shared_ptr<LoDTensorBlockingQueue> GetQueue() { return queue_; }","path":"paddle/fluid/operators/reader/lod_tensor_blocking_queue.h","position":93,"original_position":93,"commit_id":"0045ae7c9eeded303e2089b23967a75c538a4eba","original_commit_id":"0045ae7c9eeded303e2089b23967a75c538a4eba","user":{"login":"sneaxiy","id":32832641,"node_id":"MDQ6VXNlcjMyODMyNjQx","avatar_url":"https://avatars1.githubusercontent.com/u/32832641?v=4","gravatar_id":"","url":"https://api.github.com/users/sneaxiy","html_url":"https://github.com/sneaxiy","followers_url":"https://api.github.com/users/sneaxiy/followers","following_url":"https://api.github.com/users/sneaxiy/following{/other_user}","gists_url":"https://api.github.com/users/sneaxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/sneaxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sneaxiy/subscriptions","organizations_url":"https://api.github.com/users/sneaxiy/orgs","repos_url":"https://api.github.com/users/sneaxiy/repos","events_url":"https://api.github.com/users/sneaxiy/events{/privacy}","received_events_url":"https://api.github.com/users/sneaxiy/received_events","type":"User","site_admin":false},"body":"LGTM","created_at":"2018-06-26T04:39:54Z","updated_at":"2018-06-26T04:39:55Z","html_url":"https://github.com/PaddlePaddle/Paddle/pull/11695#discussion_r198011633","pull_request_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/11695","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/198011633"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/11695#discussion_r198011633"},"pull_request":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/11695"}},"in_reply_to_id":197997038},"pull_request":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/11695","id":197080684,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3MDgwNjg0","html_url":"https://github.com/PaddlePaddle/Paddle/pull/11695","diff_url":"https://github.com/PaddlePaddle/Paddle/pull/11695.diff","patch_url":"https://github.com/PaddlePaddle/Paddle/pull/11695.patch","issue_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/11695","number":11695,"state":"open","locked":false,"title":"Add Python Reader Op (CPP side)","user":{"login":"sneaxiy","id":32832641,"node_id":"MDQ6VXNlcjMyODMyNjQx","avatar_url":"https://avatars1.githubusercontent.com/u/32832641?v=4","gravatar_id":"","url":"https://api.github.com/users/sneaxiy","html_url":"https://github.com/sneaxiy","followers_url":"https://api.github.com/users/sneaxiy/followers","following_url":"https://api.github.com/users/sneaxiy/following{/other_user}","gists_url":"https://api.github.com/users/sneaxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/sneaxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sneaxiy/subscriptions","organizations_url":"https://api.github.com/users/sneaxiy/orgs","repos_url":"https://api.github.com/users/sneaxiy/repos","events_url":"https://api.github.com/users/sneaxiy/events{/privacy}","received_events_url":"https://api.github.com/users/sneaxiy/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-25T11:20:50Z","updated_at":"2018-06-26T04:39:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"798428328e912b3df09b9b755e6925bdab0c3aa6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/11695/commits","review_comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/11695/comments","review_comment_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/11695/comments","statuses_url":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/0045ae7c9eeded303e2089b23967a75c538a4eba","head":{"label":"sneaxiy:complete_py_reader_cpp","ref":"complete_py_reader_cpp","sha":"0045ae7c9eeded303e2089b23967a75c538a4eba","user":{"login":"sneaxiy","id":32832641,"node_id":"MDQ6VXNlcjMyODMyNjQx","avatar_url":"https://avatars1.githubusercontent.com/u/32832641?v=4","gravatar_id":"","url":"https://api.github.com/users/sneaxiy","html_url":"https://github.com/sneaxiy","followers_url":"https://api.github.com/users/sneaxiy/followers","following_url":"https://api.github.com/users/sneaxiy/following{/other_user}","gists_url":"https://api.github.com/users/sneaxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/sneaxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sneaxiy/subscriptions","organizations_url":"https://api.github.com/users/sneaxiy/orgs","repos_url":"https://api.github.com/users/sneaxiy/repos","events_url":"https://api.github.com/users/sneaxiy/events{/privacy}","received_events_url":"https://api.github.com/users/sneaxiy/received_events","type":"User","site_admin":false},"repo":{"id":135393132,"node_id":"MDEwOlJlcG9zaXRvcnkxMzUzOTMxMzI=","name":"Paddle","full_name":"sneaxiy/Paddle","owner":{"login":"sneaxiy","id":32832641,"node_id":"MDQ6VXNlcjMyODMyNjQx","avatar_url":"https://avatars1.githubusercontent.com/u/32832641?v=4","gravatar_id":"","url":"https://api.github.com/users/sneaxiy","html_url":"https://github.com/sneaxiy","followers_url":"https://api.github.com/users/sneaxiy/followers","following_url":"https://api.github.com/users/sneaxiy/following{/other_user}","gists_url":"https://api.github.com/users/sneaxiy/gists{/gist_id}","starred_url":"https://api.github.com/users/sneaxiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sneaxiy/subscriptions","organizations_url":"https://api.github.com/users/sneaxiy/orgs","repos_url":"https://api.github.com/users/sneaxiy/repos","events_url":"https://api.github.com/users/sneaxiy/events{/privacy}","received_events_url":"https://api.github.com/users/sneaxiy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sneaxiy/Paddle","description":"PArallel Distributed Deep LEarning","fork":true,"url":"https://api.github.com/repos/sneaxiy/Paddle","forks_url":"https://api.github.com/repos/sneaxiy/Paddle/forks","keys_url":"https://api.github.com/repos/sneaxiy/Paddle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sneaxiy/Paddle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sneaxiy/Paddle/teams","hooks_url":"https://api.github.com/repos/sneaxiy/Paddle/hooks","issue_events_url":"https://api.github.com/repos/sneaxiy/Paddle/issues/events{/number}","events_url":"https://api.github.com/repos/sneaxiy/Paddle/events","assignees_url":"https://api.github.com/repos/sneaxiy/Paddle/assignees{/user}","branches_url":"https://api.github.com/repos/sneaxiy/Paddle/branches{/branch}","tags_url":"https://api.github.com/repos/sneaxiy/Paddle/tags","blobs_url":"https://api.github.com/repos/sneaxiy/Paddle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sneaxiy/Paddle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sneaxiy/Paddle/git/refs{/sha}","trees_url":"https://api.github.com/repos/sneaxiy/Paddle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sneaxiy/Paddle/statuses/{sha}","languages_url":"https://api.github.com/repos/sneaxiy/Paddle/languages","stargazers_url":"https://api.github.com/repos/sneaxiy/Paddle/stargazers","contributors_url":"https://api.github.com/repos/sneaxiy/Paddle/contributors","subscribers_url":"https://api.github.com/repos/sneaxiy/Paddle/subscribers","subscription_url":"https://api.github.com/repos/sneaxiy/Paddle/subscription","commits_url":"https://api.github.com/repos/sneaxiy/Paddle/commits{/sha}","git_commits_url":"https://api.github.com/repos/sneaxiy/Paddle/git/commits{/sha}","comments_url":"https://api.github.com/repos/sneaxiy/Paddle/comments{/number}","issue_comment_url":"https://api.github.com/repos/sneaxiy/Paddle/issues/comments{/number}","contents_url":"https://api.github.com/repos/sneaxiy/Paddle/contents/{+path}","compare_url":"https://api.github.com/repos/sneaxiy/Paddle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sneaxiy/Paddle/merges","archive_url":"https://api.github.com/repos/sneaxiy/Paddle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sneaxiy/Paddle/downloads","issues_url":"https://api.github.com/repos/sneaxiy/Paddle/issues{/number}","pulls_url":"https://api.github.com/repos/sneaxiy/Paddle/pulls{/number}","milestones_url":"https://api.github.com/repos/sneaxiy/Paddle/milestones{/number}","notifications_url":"https://api.github.com/repos/sneaxiy/Paddle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sneaxiy/Paddle/labels{/name}","releases_url":"https://api.github.com/repos/sneaxiy/Paddle/releases{/id}","deployments_url":"https://api.github.com/repos/sneaxiy/Paddle/deployments","created_at":"2018-05-30T05:38:44Z","updated_at":"2018-06-25T07:46:44Z","pushed_at":"2018-06-26T04:33:18Z","git_url":"git://github.com/sneaxiy/Paddle.git","ssh_url":"git@github.com:sneaxiy/Paddle.git","clone_url":"https://github.com/sneaxiy/Paddle.git","svn_url":"https://github.com/sneaxiy/Paddle","homepage":"http://www.paddlepaddle.org/","size":109741,"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":"develop"}},"base":{"label":"PaddlePaddle:develop","ref":"develop","sha":"e0f65642d08d38e01da74a8fc3875c72d8604192","user":{"login":"PaddlePaddle","id":23534030,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNTM0MDMw","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,"node_id":"MDEwOlJlcG9zaXRvcnk2NTcxMTUyMg==","name":"Paddle","full_name":"PaddlePaddle/Paddle","owner":{"login":"PaddlePaddle","id":23534030,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNTM0MDMw","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-06-26T03:47:23Z","pushed_at":"2018-06-26T04:04:22Z","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":109658,"stargazers_count":7116,"watchers_count":7116,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1947,"mirror_url":null,"archived":false,"open_issues_count":1304,"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":1947,"open_issues":1304,"watchers":7116,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/11695"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/11695"},"issue":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/11695"},"comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/11695/comments"},"review_comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/11695/comments"},"review_comment":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/11695/commits"},"statuses":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/0045ae7c9eeded303e2089b23967a75c538a4eba"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"sneaxiy"}}