{"action":"created","comment":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/143632612","pull_request_review_id":68169718,"id":143632612,"diff_hunk":"@@ -0,0 +1,114 @@\n+/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.\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+#include \"paddle/operators/sequence_concat_op.h\"\n+\n+namespace paddle {\n+namespace operators {\n+\n+class SequenceConcatOp : public framework::OperatorWithKernel {\n+ public:\n+  using framework::OperatorWithKernel::OperatorWithKernel;\n+\n+ protected:\n+  void InferShape(framework::InferShapeContextBase* ctx) const override {\n+    PADDLE_ENFORCE(ctx->HasInputs(\"X\"),\n+                   \"Inputs(X) of SequenceConcatOp should not be null.\");\n+    PADDLE_ENFORCE(ctx->HasOutput(\"Out\"),\n+                   \"Output(Out) of SequenceConcatOp should not be null.\");\n+    const size_t level = static_cast<size_t>(ctx->Attrs().Get<int>(\"level\"));\n+    const size_t axis = static_cast<size_t>(ctx->Attrs().Get<int>(\"axis\"));\n+    PADDLE_ENFORCE(level == 0UL || level == 1UL,\n+                   \"The sequence_concat operator only accepts sequence \"\n+                   \"or a nested sequence as its input.\");\n+    auto ins_dims = ctx->GetInputsDim(\"X\");\n+    framework::DDim out_dims = ins_dims[0];\n+    const size_t n = ins_dims.size();\n+    for (size_t i = 1; i < n; ++i) {\n+      out_dims[axis] += ins_dims[i][axis];\n+    }\n+    ctx->SetOutputDim(\"Out\", out_dims);\n+  }\n+};\n+\n+class SequenceConcatOpMaker : public framework::OpProtoAndCheckerMaker {\n+ public:\n+  SequenceConcatOpMaker(framework::OpProto* proto,\n+                        framework::OpAttrChecker* op_checker)\n+      : OpProtoAndCheckerMaker(proto, op_checker) {\n+    AddInput(\"X\",\n+             \"The input Multip LoDTensors, which are variable-length \"\n+             \"sequence or nested sequence.\")\n+        .AsDuplicable();\n+    AddOutput(\"Out\",\n+              \"A LoDTensor, the variable-length output of \"\n+              \"sequence_concat Op.\");\n+    AddAttr<int>(\"axis\",\n+                 \"(int, default 0)\"\n+                 \"The axis which the inputs will be joined with.\"\n+                 \"If axis is 0, the inputs will be joined with LoD index.\")\n+        .SetDefault(0);\n+    AddAttr<int>(\"level\",\n+                 \"(int, default 0)\"\n+                 \"The level which the inputs will be joined with.\"\n+                 \"If level is 0, the inputs will be joined with \"\n+                 \"nested sequences.\"\n+                 \"If level is 1, the inputs will be joined with sequences.\")\n+        .SetDefault(0);\n+    AddComment(R\"DOC(\n+    The sequence_concat operator concatenates multiple LoDTensors. \n+    It only supports sequences ( LoD Tensor with level=1) \n+    or nested sequences (LoD tensor with level=0) as its inputs.\n+    - Case1:\n+      If the axis is 1, level is 1, the LoD of Inputs are the same,\n+      LoD(x0) = {{0,2,4},{0,1,2,3,4}}; Dims(x0) = (2,3,4)\n+      LoD(x1) = {{0,2,4},{0,1,2,3,4}}; Dims(x1) = (2,4,4)\n+      LoD(Out) = {{0,2,4},{0,1,2,3,4}}; Dims(Out) = (2,7,4)\n+    - Case2:\n+      If the axis is 0, level is 1, the LoD of inputs are different,\n+      LoD(x0) = {{0,2,4}, {0,1,2,3,4}}; Dims(x0) = (2,3,4)\n+      LoD(x1) = {{0,3,5}, {0,1,3,4,5}}; Dims(x1) = (3,3,4)\n+      LoD(Out) = {{0,5,9}, {0,1,2,4,5,6,7,8,9}}; Dims(Out) = (5,3,4)","path":"paddle/operators/sequence_concat_op.cc","position":null,"original_position":82,"commit_id":"462579c416b1f9bd1173d9d56a9cbc0c5cee9de8","original_commit_id":"0028459bb031a06a7dc4adb12eca6eb1bc8a773e","user":{"login":"Yancey1989","id":1426912,"avatar_url":"https://avatars2.githubusercontent.com/u/1426912?v=4","gravatar_id":"","url":"https://api.github.com/users/Yancey1989","html_url":"https://github.com/Yancey1989","followers_url":"https://api.github.com/users/Yancey1989/followers","following_url":"https://api.github.com/users/Yancey1989/following{/other_user}","gists_url":"https://api.github.com/users/Yancey1989/gists{/gist_id}","starred_url":"https://api.github.com/users/Yancey1989/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yancey1989/subscriptions","organizations_url":"https://api.github.com/users/Yancey1989/orgs","repos_url":"https://api.github.com/users/Yancey1989/repos","events_url":"https://api.github.com/users/Yancey1989/events{/privacy}","received_events_url":"https://api.github.com/users/Yancey1989/received_events","type":"User","site_admin":false},"body":"Add a unit test with `level=0`, done.\r\n","created_at":"2017-10-10T05:27:26Z","updated_at":"2017-10-10T05:27:26Z","html_url":"https://github.com/PaddlePaddle/Paddle/pull/4508#discussion_r143632612","pull_request_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/4508","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/143632612"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/4508#discussion_r143632612"},"pull_request":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/4508"}},"in_reply_to_id":143390367},"pull_request":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/4508","id":143867146,"html_url":"https://github.com/PaddlePaddle/Paddle/pull/4508","diff_url":"https://github.com/PaddlePaddle/Paddle/pull/4508.diff","patch_url":"https://github.com/PaddlePaddle/Paddle/pull/4508.patch","issue_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/4508","number":4508,"state":"open","locked":false,"title":"Add sequence concat op","user":{"login":"Yancey1989","id":1426912,"avatar_url":"https://avatars2.githubusercontent.com/u/1426912?v=4","gravatar_id":"","url":"https://api.github.com/users/Yancey1989","html_url":"https://github.com/Yancey1989","followers_url":"https://api.github.com/users/Yancey1989/followers","following_url":"https://api.github.com/users/Yancey1989/following{/other_user}","gists_url":"https://api.github.com/users/Yancey1989/gists{/gist_id}","starred_url":"https://api.github.com/users/Yancey1989/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yancey1989/subscriptions","organizations_url":"https://api.github.com/users/Yancey1989/orgs","repos_url":"https://api.github.com/users/Yancey1989/repos","events_url":"https://api.github.com/users/Yancey1989/events{/privacy}","received_events_url":"https://api.github.com/users/Yancey1989/received_events","type":"User","site_admin":false},"body":"Fixed #4226 ","created_at":"2017-09-29T11:37:03Z","updated_at":"2017-10-10T05:27:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"03404b430e1f5cfc3d9c22cad023b1324961f742","assignee":null,"assignees":[],"requested_reviewers":[{"login":"luotao1","id":6836917,"avatar_url":"https://avatars0.githubusercontent.com/u/6836917?v=4","gravatar_id":"","url":"https://api.github.com/users/luotao1","html_url":"https://github.com/luotao1","followers_url":"https://api.github.com/users/luotao1/followers","following_url":"https://api.github.com/users/luotao1/following{/other_user}","gists_url":"https://api.github.com/users/luotao1/gists{/gist_id}","starred_url":"https://api.github.com/users/luotao1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luotao1/subscriptions","organizations_url":"https://api.github.com/users/luotao1/orgs","repos_url":"https://api.github.com/users/luotao1/repos","events_url":"https://api.github.com/users/luotao1/events{/privacy}","received_events_url":"https://api.github.com/users/luotao1/received_events","type":"User","site_admin":false},{"login":"typhoonzero","id":13348433,"avatar_url":"https://avatars1.githubusercontent.com/u/13348433?v=4","gravatar_id":"","url":"https://api.github.com/users/typhoonzero","html_url":"https://github.com/typhoonzero","followers_url":"https://api.github.com/users/typhoonzero/followers","following_url":"https://api.github.com/users/typhoonzero/following{/other_user}","gists_url":"https://api.github.com/users/typhoonzero/gists{/gist_id}","starred_url":"https://api.github.com/users/typhoonzero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typhoonzero/subscriptions","organizations_url":"https://api.github.com/users/typhoonzero/orgs","repos_url":"https://api.github.com/users/typhoonzero/repos","events_url":"https://api.github.com/users/typhoonzero/events{/privacy}","received_events_url":"https://api.github.com/users/typhoonzero/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/4508/commits","review_comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/4508/comments","review_comment_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/4508/comments","statuses_url":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/462579c416b1f9bd1173d9d56a9cbc0c5cee9de8","head":{"label":"Yancey1989:seqconcat_op","ref":"seqconcat_op","sha":"462579c416b1f9bd1173d9d56a9cbc0c5cee9de8","user":{"login":"Yancey1989","id":1426912,"avatar_url":"https://avatars2.githubusercontent.com/u/1426912?v=4","gravatar_id":"","url":"https://api.github.com/users/Yancey1989","html_url":"https://github.com/Yancey1989","followers_url":"https://api.github.com/users/Yancey1989/followers","following_url":"https://api.github.com/users/Yancey1989/following{/other_user}","gists_url":"https://api.github.com/users/Yancey1989/gists{/gist_id}","starred_url":"https://api.github.com/users/Yancey1989/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yancey1989/subscriptions","organizations_url":"https://api.github.com/users/Yancey1989/orgs","repos_url":"https://api.github.com/users/Yancey1989/repos","events_url":"https://api.github.com/users/Yancey1989/events{/privacy}","received_events_url":"https://api.github.com/users/Yancey1989/received_events","type":"User","site_admin":false},"repo":{"id":83747272,"name":"Paddle","full_name":"Yancey1989/Paddle","owner":{"login":"Yancey1989","id":1426912,"avatar_url":"https://avatars2.githubusercontent.com/u/1426912?v=4","gravatar_id":"","url":"https://api.github.com/users/Yancey1989","html_url":"https://github.com/Yancey1989","followers_url":"https://api.github.com/users/Yancey1989/followers","following_url":"https://api.github.com/users/Yancey1989/following{/other_user}","gists_url":"https://api.github.com/users/Yancey1989/gists{/gist_id}","starred_url":"https://api.github.com/users/Yancey1989/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yancey1989/subscriptions","organizations_url":"https://api.github.com/users/Yancey1989/orgs","repos_url":"https://api.github.com/users/Yancey1989/repos","events_url":"https://api.github.com/users/Yancey1989/events{/privacy}","received_events_url":"https://api.github.com/users/Yancey1989/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Yancey1989/Paddle","description":"PArallel Distributed Deep LEarning","fork":true,"url":"https://api.github.com/repos/Yancey1989/Paddle","forks_url":"https://api.github.com/repos/Yancey1989/Paddle/forks","keys_url":"https://api.github.com/repos/Yancey1989/Paddle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yancey1989/Paddle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yancey1989/Paddle/teams","hooks_url":"https://api.github.com/repos/Yancey1989/Paddle/hooks","issue_events_url":"https://api.github.com/repos/Yancey1989/Paddle/issues/events{/number}","events_url":"https://api.github.com/repos/Yancey1989/Paddle/events","assignees_url":"https://api.github.com/repos/Yancey1989/Paddle/assignees{/user}","branches_url":"https://api.github.com/repos/Yancey1989/Paddle/branches{/branch}","tags_url":"https://api.github.com/repos/Yancey1989/Paddle/tags","blobs_url":"https://api.github.com/repos/Yancey1989/Paddle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yancey1989/Paddle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yancey1989/Paddle/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yancey1989/Paddle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yancey1989/Paddle/statuses/{sha}","languages_url":"https://api.github.com/repos/Yancey1989/Paddle/languages","stargazers_url":"https://api.github.com/repos/Yancey1989/Paddle/stargazers","contributors_url":"https://api.github.com/repos/Yancey1989/Paddle/contributors","subscribers_url":"https://api.github.com/repos/Yancey1989/Paddle/subscribers","subscription_url":"https://api.github.com/repos/Yancey1989/Paddle/subscription","commits_url":"https://api.github.com/repos/Yancey1989/Paddle/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yancey1989/Paddle/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yancey1989/Paddle/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yancey1989/Paddle/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yancey1989/Paddle/contents/{+path}","compare_url":"https://api.github.com/repos/Yancey1989/Paddle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yancey1989/Paddle/merges","archive_url":"https://api.github.com/repos/Yancey1989/Paddle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yancey1989/Paddle/downloads","issues_url":"https://api.github.com/repos/Yancey1989/Paddle/issues{/number}","pulls_url":"https://api.github.com/repos/Yancey1989/Paddle/pulls{/number}","milestones_url":"https://api.github.com/repos/Yancey1989/Paddle/milestones{/number}","notifications_url":"https://api.github.com/repos/Yancey1989/Paddle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yancey1989/Paddle/labels{/name}","releases_url":"https://api.github.com/repos/Yancey1989/Paddle/releases{/id}","deployments_url":"https://api.github.com/repos/Yancey1989/Paddle/deployments","created_at":"2017-03-03T02:20:12Z","updated_at":"2017-03-03T02:20:16Z","pushed_at":"2017-10-10T05:25:55Z","git_url":"git://github.com/Yancey1989/Paddle.git","ssh_url":"git@github.com:Yancey1989/Paddle.git","clone_url":"https://github.com/Yancey1989/Paddle.git","svn_url":"https://github.com/Yancey1989/Paddle","homepage":"http://www.paddlepaddle.org/","size":35425,"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":"develop"}},"base":{"label":"PaddlePaddle:develop","ref":"develop","sha":"bb81baa19b311e2d4eb994b8fe4fdfe1d17c9cac","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-10-10T04:10:54Z","pushed_at":"2017-10-10T05:25:57Z","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":55256,"stargazers_count":5551,"watchers_count":5551,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1484,"mirror_url":null,"open_issues_count":732,"forks":1484,"open_issues":732,"watchers":5551,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/4508"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/4508"},"issue":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/4508"},"comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/4508/comments"},"review_comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/4508/comments"},"review_comment":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/4508/commits"},"statuses":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/462579c416b1f9bd1173d9d56a9cbc0c5cee9de8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Yancey1989"}}