{"action":"created","comment":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/130235131","pull_request_review_id":53090174,"id":130235131,"diff_hunk":"@@ -164,6 +170,80 @@ class Tensor {\n   size_t offset_;\n };\n \n+/*\n+ * LODTensor\n+ */\n+class LODTensor {\n+ public:\n+// level_t save offsets of each unit.\n+#ifdef PADDLE_ONLY_CPU\n+  using level_t = std::vector<uint32_t>;\n+#else\n+  using level_t = thrust::device_vector<uint32_t>;\n+#endif\n+  // LOD stores offsets of each level of units, the largest units level first,\n+  // then the smaller units level. Each level_t stores the offsets of units in\n+  // Tesor.\n+  typedef std::vector<level_t> lod_t;\n+\n+  explicit LODTensor() {}\n+\n+  LODTensor(LODTensor&& other)\n+      : lod_start_pos_(std::move(other.lod_start_pos_)),\n+        tensor_(other.tensor_) {}\n+\n+  /*\n+   * Number of LODTensor's levels, each level has units of data, for example,\n+   * in the sentence's view, article, paragraph, sentence are 3 levels.\n+   */\n+  size_t Levels() const {\n+    return lod_start_pos_.get() ? lod_start_pos_->size() : 0UL;\n+  }\n+  /*\n+   * Number of elements in a level.\n+   */\n+  size_t Elements(uint32_t level = 0) const {\n+    PADDLE_ENFORCE(level < Levels(), \"level [%d] out of range [%d]\", level,\n+                   Levels());\n+    return lod_start_pos_->at(level).size();\n+  }\n+\n+  /*\n+   * Slice of a level.\n+   */\n+  LODTensor Slice(uint32_t level) const;\n+\n+  /*\n+   * Slice of elements of a level, [elem_begin: elem_end]\n+   * NOTE low performance in slice seq_start_positions_.","path":"paddle/framework/tensor.h","position":62,"original_position":62,"commit_id":"32c948ac96919e8b5b2f3282b641e27e80542eb3","original_commit_id":"32c948ac96919e8b5b2f3282b641e27e80542eb3","user":{"login":"reyoung","id":728699,"avatar_url":"https://avatars2.githubusercontent.com/u/728699?v=4","gravatar_id":"","url":"https://api.github.com/users/reyoung","html_url":"https://github.com/reyoung","followers_url":"https://api.github.com/users/reyoung/followers","following_url":"https://api.github.com/users/reyoung/following{/other_user}","gists_url":"https://api.github.com/users/reyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/reyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reyoung/subscriptions","organizations_url":"https://api.github.com/users/reyoung/orgs","repos_url":"https://api.github.com/users/reyoung/repos","events_url":"https://api.github.com/users/reyoung/events{/privacy}","received_events_url":"https://api.github.com/users/reyoung/received_events","type":"User","site_admin":false},"body":"`seq_start_positions_` --> `lod_start_pos_`","created_at":"2017-07-30T07:19:01Z","updated_at":"2017-07-30T07:46:18Z","html_url":"https://github.com/PaddlePaddle/Paddle/pull/3109#discussion_r130235131","pull_request_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/3109","_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/130235131"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/3109#discussion_r130235131"},"pull_request":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/3109"}}},"pull_request":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/3109","id":133118918,"html_url":"https://github.com/PaddlePaddle/Paddle/pull/3109","diff_url":"https://github.com/PaddlePaddle/Paddle/pull/3109.diff","patch_url":"https://github.com/PaddlePaddle/Paddle/pull/3109.patch","issue_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/3109","number":3109,"state":"open","locked":false,"title":"LOTTensor","user":{"login":"Superjom","id":328693,"avatar_url":"https://avatars1.githubusercontent.com/u/328693?v=4","gravatar_id":"","url":"https://api.github.com/users/Superjom","html_url":"https://github.com/Superjom","followers_url":"https://api.github.com/users/Superjom/followers","following_url":"https://api.github.com/users/Superjom/following{/other_user}","gists_url":"https://api.github.com/users/Superjom/gists{/gist_id}","starred_url":"https://api.github.com/users/Superjom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Superjom/subscriptions","organizations_url":"https://api.github.com/users/Superjom/orgs","repos_url":"https://api.github.com/users/Superjom/repos","events_url":"https://api.github.com/users/Superjom/events{/privacy}","received_events_url":"https://api.github.com/users/Superjom/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-07-30T07:10:54Z","updated_at":"2017-07-30T07:46:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3ed7fa2d4fc4cc3ed82495c1b3c832f151b227e2","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/3109/commits","review_comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/3109/comments","review_comment_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/3109/comments","statuses_url":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/32c948ac96919e8b5b2f3282b641e27e80542eb3","head":{"label":"Superjom:lottensor","ref":"lottensor","sha":"32c948ac96919e8b5b2f3282b641e27e80542eb3","user":{"login":"Superjom","id":328693,"avatar_url":"https://avatars1.githubusercontent.com/u/328693?v=4","gravatar_id":"","url":"https://api.github.com/users/Superjom","html_url":"https://github.com/Superjom","followers_url":"https://api.github.com/users/Superjom/followers","following_url":"https://api.github.com/users/Superjom/following{/other_user}","gists_url":"https://api.github.com/users/Superjom/gists{/gist_id}","starred_url":"https://api.github.com/users/Superjom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Superjom/subscriptions","organizations_url":"https://api.github.com/users/Superjom/orgs","repos_url":"https://api.github.com/users/Superjom/repos","events_url":"https://api.github.com/users/Superjom/events{/privacy}","received_events_url":"https://api.github.com/users/Superjom/received_events","type":"User","site_admin":false},"repo":{"id":66896049,"name":"Paddle","full_name":"Superjom/Paddle","owner":{"login":"Superjom","id":328693,"avatar_url":"https://avatars1.githubusercontent.com/u/328693?v=4","gravatar_id":"","url":"https://api.github.com/users/Superjom","html_url":"https://github.com/Superjom","followers_url":"https://api.github.com/users/Superjom/followers","following_url":"https://api.github.com/users/Superjom/following{/other_user}","gists_url":"https://api.github.com/users/Superjom/gists{/gist_id}","starred_url":"https://api.github.com/users/Superjom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Superjom/subscriptions","organizations_url":"https://api.github.com/users/Superjom/orgs","repos_url":"https://api.github.com/users/Superjom/repos","events_url":"https://api.github.com/users/Superjom/events{/privacy}","received_events_url":"https://api.github.com/users/Superjom/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Superjom/Paddle","description":"PArallel Distributed Deep LEarning","fork":true,"url":"https://api.github.com/repos/Superjom/Paddle","forks_url":"https://api.github.com/repos/Superjom/Paddle/forks","keys_url":"https://api.github.com/repos/Superjom/Paddle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Superjom/Paddle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Superjom/Paddle/teams","hooks_url":"https://api.github.com/repos/Superjom/Paddle/hooks","issue_events_url":"https://api.github.com/repos/Superjom/Paddle/issues/events{/number}","events_url":"https://api.github.com/repos/Superjom/Paddle/events","assignees_url":"https://api.github.com/repos/Superjom/Paddle/assignees{/user}","branches_url":"https://api.github.com/repos/Superjom/Paddle/branches{/branch}","tags_url":"https://api.github.com/repos/Superjom/Paddle/tags","blobs_url":"https://api.github.com/repos/Superjom/Paddle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Superjom/Paddle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Superjom/Paddle/git/refs{/sha}","trees_url":"https://api.github.com/repos/Superjom/Paddle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Superjom/Paddle/statuses/{sha}","languages_url":"https://api.github.com/repos/Superjom/Paddle/languages","stargazers_url":"https://api.github.com/repos/Superjom/Paddle/stargazers","contributors_url":"https://api.github.com/repos/Superjom/Paddle/contributors","subscribers_url":"https://api.github.com/repos/Superjom/Paddle/subscribers","subscription_url":"https://api.github.com/repos/Superjom/Paddle/subscription","commits_url":"https://api.github.com/repos/Superjom/Paddle/commits{/sha}","git_commits_url":"https://api.github.com/repos/Superjom/Paddle/git/commits{/sha}","comments_url":"https://api.github.com/repos/Superjom/Paddle/comments{/number}","issue_comment_url":"https://api.github.com/repos/Superjom/Paddle/issues/comments{/number}","contents_url":"https://api.github.com/repos/Superjom/Paddle/contents/{+path}","compare_url":"https://api.github.com/repos/Superjom/Paddle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Superjom/Paddle/merges","archive_url":"https://api.github.com/repos/Superjom/Paddle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Superjom/Paddle/downloads","issues_url":"https://api.github.com/repos/Superjom/Paddle/issues{/number}","pulls_url":"https://api.github.com/repos/Superjom/Paddle/pulls{/number}","milestones_url":"https://api.github.com/repos/Superjom/Paddle/milestones{/number}","notifications_url":"https://api.github.com/repos/Superjom/Paddle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Superjom/Paddle/labels{/name}","releases_url":"https://api.github.com/repos/Superjom/Paddle/releases{/id}","deployments_url":"https://api.github.com/repos/Superjom/Paddle/deployments","created_at":"2016-08-30T01:45:54Z","updated_at":"2016-08-30T01:45:57Z","pushed_at":"2017-07-30T02:35:46Z","git_url":"git://github.com/Superjom/Paddle.git","ssh_url":"git@github.com:Superjom/Paddle.git","clone_url":"https://github.com/Superjom/Paddle.git","svn_url":"https://github.com/Superjom/Paddle","homepage":null,"size":22946,"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,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"PaddlePaddle:develop","ref":"develop","sha":"0973c2c97bf943edcf091112947c110280bcc623","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":"2017-07-30T04:30:30Z","pushed_at":"2017-07-30T07:10:55Z","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":42590,"stargazers_count":5220,"watchers_count":5220,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1386,"mirror_url":null,"open_issues_count":508,"forks":1386,"open_issues":508,"watchers":5220,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/3109"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/3109"},"issue":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/3109"},"comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/3109/comments"},"review_comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/3109/comments"},"review_comment":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/3109/commits"},"statuses":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/32c948ac96919e8b5b2f3282b641e27e80542eb3"}}}}
{"actor":{"display_login":"reyoung"}}