{"action":"created","comment":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/147883722","pull_request_review_id":73041650,"id":147883722,"diff_hunk":"@@ -0,0 +1,125 @@\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 <gtest/gtest.h>\n+#include <string>\n+#include <vector>\n+\n+#include \"LayerGradUtil.h\"\n+#include \"paddle/testing/TestUtil.h\"\n+\n+using namespace paddle;  // NOLINT\n+using namespace std;     // NOLINT\n+\n+// Do one forward pass of expand layer and check to see if its output\n+// matches the given result.(Test onlyCPU currently.)\n+void doOneExpandTest(string trans_type,\n+                     bool hasSubseq,\n+                     bool useGpu,\n+                     Argument& input1,\n+                     Argument& input2,\n+                     Argument& result) {\n+  FLAGS_use_gpu = false;\n+  // Setting up the expand layer\n+  TestConfig config;\n+  config.layerConfig.set_type(\"expand\");\n+\n+  auto inputType1 =\n+      trans_type == \"non-seq\" ? INPUT_DENSE_DIM_DATA : INPUT_SEQUENCE_DATA;\n+  config.inputDefs.push_back({inputType1, \"layer0\", 1, 0});\n+  auto inputType2 =\n+      hasSubseq ? INPUT_HASSUB_SEQUENCE_DATA : INPUT_SEQUENCE_DATA;\n+\n+  config.inputDefs.push_back({inputType2, \"layer1\", 1, 0});\n+  config.layerConfig.add_inputs();\n+  config.layerConfig.add_inputs();\n+  config.layerConfig.set_trans_type(trans_type);\n+\n+  // data layer initialize\n+  std::vector<DataLayerPtr> dataLayers;\n+  LayerMap layerMap;\n+  vector<Argument> datas;\n+  initDataLayer(\n+      config, &dataLayers, &datas, &layerMap, \"expand\", 1, false, useGpu);\n+  dataLayers[0]->getOutput() = input1;\n+  dataLayers[1]->getOutput() = input2;\n+\n+  // test layer initialize\n+  std::vector<ParameterPtr> parameters;\n+  LayerPtr expandLayer;\n+  initTestLayer(config, &layerMap, &parameters, &expandLayer);\n+  expandLayer->forward(PASS_GC);\n+  checkMatrixEqual(expandLayer->getOutputValue(), result.value);\n+}\n+\n+TEST(Layer, ExpandLayerFwd) {\n+  bool useGpu = false;\n+\n+  // Assume batch_size =3 in all cases.\n+\n+  // CPU case 1. non-seq expand to seq\n+  // input1 = 1,2,3\n+  // input2 = [4,5],[6],[7,8,9]\n+  // result = [1,1],[2],[3,3,3]\n+  Argument input1, input2, result;\n+  input1.value = Matrix::create(3, 1, false, useGpu);\n+  real input1Data[] = {1, 2, 3};\n+  input1.value->setData(input1Data);\n+\n+  input2.value = Matrix::create(6, 1, false, useGpu);\n+  real input2Data[] = {4, 5, 6, 7, 8, 9};\n+  input2.value->setData(input2Data);\n+  input2.sequenceStartPositions = ICpuGpuVector::create(4, useGpu);\n+  int input2Seq[] = {0, 2, 3, 6};\n+  input2.sequenceStartPositions->copyFrom(input2Seq, 4, useGpu);\n+\n+  result.value = Matrix::create(6, 1, false, useGpu);\n+  real resultData[] = {1, 1, 2, 3, 3, 3};\n+  result.value->setData(resultData);\n+\n+  doOneExpandTest(\"non-seq\", false, useGpu, input1, input2, result);\n+\n+  // CPU case 2. non-seq expand to sub-seq\n+  // input1 = 1,2,3\n+  // input2 = [[4,5]],[[6]],[[7],[8,9]]\n+  // result = [[1,1]],[[2]],[[3],[3,3]]","path":"paddle/gserver/tests/test_Expand.cpp","position":96,"original_position":96,"commit_id":"0f67a8272896bed63efd777133a3cafb6bc572f8","original_commit_id":"0f67a8272896bed63efd777133a3cafb6bc572f8","user":{"login":"wanghaoshuang","id":7534971,"avatar_url":"https://avatars0.githubusercontent.com/u/7534971?v=4","gravatar_id":"","url":"https://api.github.com/users/wanghaoshuang","html_url":"https://github.com/wanghaoshuang","followers_url":"https://api.github.com/users/wanghaoshuang/followers","following_url":"https://api.github.com/users/wanghaoshuang/following{/other_user}","gists_url":"https://api.github.com/users/wanghaoshuang/gists{/gist_id}","starred_url":"https://api.github.com/users/wanghaoshuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wanghaoshuang/subscriptions","organizations_url":"https://api.github.com/users/wanghaoshuang/orgs","repos_url":"https://api.github.com/users/wanghaoshuang/repos","events_url":"https://api.github.com/users/wanghaoshuang/events{/privacy}","received_events_url":"https://api.github.com/users/wanghaoshuang/received_events","type":"User","site_admin":false},"body":"如果input1 = 1,2,3,4\r\nresult应该等于多少？","created_at":"2017-10-31T02:39:38Z","updated_at":"2017-10-31T02:42:54Z","html_url":"https://github.com/PaddlePaddle/Paddle/pull/5076#discussion_r147883722","pull_request_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/5076","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments/147883722"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/5076#discussion_r147883722"},"pull_request":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/5076"}}},"pull_request":{"url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/5076","id":148602175,"html_url":"https://github.com/PaddlePaddle/Paddle/pull/5076","diff_url":"https://github.com/PaddlePaddle/Paddle/pull/5076.diff","patch_url":"https://github.com/PaddlePaddle/Paddle/pull/5076.patch","issue_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/5076","number":5076,"state":"open","locked":false,"title":"add test_Expand and simply the gserver/tests/CMakeLists","user":{"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},"body":"fix #5013 ","created_at":"2017-10-25T08:35:34Z","updated_at":"2017-10-31T02:42:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"695e5dda414a71b8d7427ce3cf7f906266699af7","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/5076/commits","review_comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/5076/comments","review_comment_url":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/5076/comments","statuses_url":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/0f67a8272896bed63efd777133a3cafb6bc572f8","head":{"label":"luotao1:expand_test","ref":"expand_test","sha":"0f67a8272896bed63efd777133a3cafb6bc572f8","user":{"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},"repo":{"id":68666112,"name":"Paddle","full_name":"luotao1/Paddle","owner":{"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},"private":false,"html_url":"https://github.com/luotao1/Paddle","description":"PArallel Distributed Deep LEarning","fork":true,"url":"https://api.github.com/repos/luotao1/Paddle","forks_url":"https://api.github.com/repos/luotao1/Paddle/forks","keys_url":"https://api.github.com/repos/luotao1/Paddle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/luotao1/Paddle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/luotao1/Paddle/teams","hooks_url":"https://api.github.com/repos/luotao1/Paddle/hooks","issue_events_url":"https://api.github.com/repos/luotao1/Paddle/issues/events{/number}","events_url":"https://api.github.com/repos/luotao1/Paddle/events","assignees_url":"https://api.github.com/repos/luotao1/Paddle/assignees{/user}","branches_url":"https://api.github.com/repos/luotao1/Paddle/branches{/branch}","tags_url":"https://api.github.com/repos/luotao1/Paddle/tags","blobs_url":"https://api.github.com/repos/luotao1/Paddle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/luotao1/Paddle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/luotao1/Paddle/git/refs{/sha}","trees_url":"https://api.github.com/repos/luotao1/Paddle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/luotao1/Paddle/statuses/{sha}","languages_url":"https://api.github.com/repos/luotao1/Paddle/languages","stargazers_url":"https://api.github.com/repos/luotao1/Paddle/stargazers","contributors_url":"https://api.github.com/repos/luotao1/Paddle/contributors","subscribers_url":"https://api.github.com/repos/luotao1/Paddle/subscribers","subscription_url":"https://api.github.com/repos/luotao1/Paddle/subscription","commits_url":"https://api.github.com/repos/luotao1/Paddle/commits{/sha}","git_commits_url":"https://api.github.com/repos/luotao1/Paddle/git/commits{/sha}","comments_url":"https://api.github.com/repos/luotao1/Paddle/comments{/number}","issue_comment_url":"https://api.github.com/repos/luotao1/Paddle/issues/comments{/number}","contents_url":"https://api.github.com/repos/luotao1/Paddle/contents/{+path}","compare_url":"https://api.github.com/repos/luotao1/Paddle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/luotao1/Paddle/merges","archive_url":"https://api.github.com/repos/luotao1/Paddle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/luotao1/Paddle/downloads","issues_url":"https://api.github.com/repos/luotao1/Paddle/issues{/number}","pulls_url":"https://api.github.com/repos/luotao1/Paddle/pulls{/number}","milestones_url":"https://api.github.com/repos/luotao1/Paddle/milestones{/number}","notifications_url":"https://api.github.com/repos/luotao1/Paddle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/luotao1/Paddle/labels{/name}","releases_url":"https://api.github.com/repos/luotao1/Paddle/releases{/id}","deployments_url":"https://api.github.com/repos/luotao1/Paddle/deployments","created_at":"2016-09-20T02:32:06Z","updated_at":"2016-10-25T09:52:35Z","pushed_at":"2017-10-31T01:31:59Z","git_url":"git://github.com/luotao1/Paddle.git","ssh_url":"git@github.com:luotao1/Paddle.git","clone_url":"https://github.com/luotao1/Paddle.git","svn_url":"https://github.com/luotao1/Paddle","homepage":"http://www.paddlepaddle.org/","size":34473,"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,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"PaddlePaddle:develop","ref":"develop","sha":"516f54728d07e86b3f638eacc44a4298b66fc944","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-31T00:37:46Z","pushed_at":"2017-10-31T02:39: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":59956,"stargazers_count":5661,"watchers_count":5661,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1510,"mirror_url":null,"archived":false,"open_issues_count":755,"forks":1510,"open_issues":755,"watchers":5661,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/5076"},"html":{"href":"https://github.com/PaddlePaddle/Paddle/pull/5076"},"issue":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/5076"},"comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/issues/5076/comments"},"review_comments":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/5076/comments"},"review_comment":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/pulls/5076/commits"},"statuses":{"href":"https://api.github.com/repos/PaddlePaddle/Paddle/statuses/0f67a8272896bed63efd777133a3cafb6bc572f8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"wanghaoshuang"}}