diff --git a/src/framework/operator.h b/src/framework/operator.h index a44d264a188fc846454ec3612e6d1a226e997bbe..0d61761775394b3e23825db2883c2d4a2c071f33 100644 --- a/src/framework/operator.h +++ b/src/framework/operator.h @@ -50,7 +50,8 @@ static std::unordered_map< {"lrn", {{"X"}, {"Out"}}}, {"concat", {{"X"}, {"Out"}}}, {"feed", {{"X"}, {"Out"}}}, - {"fetch", {{"X"}, {"Out"}}}}; + {"fetch", {{"X"}, {"Out"}}}, + {"reshape", {{"X"}, {"Out"}}}}; template class OperatorBase : PaddleMobileObject { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f464c3bd94f92e8cbec1509c4e82df18658a7b1f..c80d34c22e566df0397105bba75022218e5f85f9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -84,10 +84,18 @@ target_link_libraries(test-gemm paddle-mobile) ADD_EXECUTABLE(test-enforce common/test_enforce.cpp) target_link_libraries(test-enforce paddle-mobile) +# gen test +ADD_EXECUTABLE(test-yolo net/test_yolo.cpp test_helper.h test_include.h executor_for_test.h) +target_link_libraries(test-yolo paddle-mobile) + # gen test ADD_EXECUTABLE(test-googlenet net/test_googlenet.cpp test_helper.h test_include.h executor_for_test.h) target_link_libraries(test-googlenet paddle-mobile) +# gen test +ADD_EXECUTABLE(test-mobilenet net/test_mobilenet.cpp test_helper.h test_include.h executor_for_test.h) +target_link_libraries(test-mobilenet paddle-mobile) + # gen test ADD_EXECUTABLE(test-sigmoid operators/test_sigmoid_op.cpp test_include.h) target_link_libraries(test-sigmoid paddle-mobile) diff --git a/test/net/test_mobilenet.cpp b/test/net/test_mobilenet.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e686ad85be767c0000a74d7bc11add89d299226e --- /dev/null +++ b/test/net/test_mobilenet.cpp @@ -0,0 +1,39 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#include +#include "../test_helper.h" +#include "../test_include.h" + +int main() { + paddle_mobile::Loader loader; + auto time1 = time(); + auto program = loader.Load(g_mobilenet); + auto time2 = time(); + DLOG << "load cost :" << time_diff(time1, time1) << "ms"; + paddle_mobile::Executor executor(program, 1); + + std::vector dims{1, 3, 224, 224}; + Tensor input_tensor; + SetupTensor(&input_tensor, {1, 3, 224, 224}, static_cast(0), + static_cast(1)); + + std::vector input(input_tensor.data(), + input_tensor.data() + input_tensor.numel()); + auto time3 = time(); + executor.predict(input, dims); + auto time4 = time(); + DLOG << "predict cost :" << time_diff(time3, time4) << "ms"; + return 0; +} diff --git a/test/net/test_yolo.cpp b/test/net/test_yolo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ab61fb250e3083a106bc6967a29e145e89606c74 --- /dev/null +++ b/test/net/test_yolo.cpp @@ -0,0 +1,41 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#include +#include "../test_helper.h" +#include "../test_include.h" + +int main() { + paddle_mobile::Loader loader; + // ../../../test/models/googlenet + // ../../../test/models/mobilenet + auto time1 = time(); + auto program = loader.Load(g_yolo); + auto time2 = time(); + DLOG << "load cost :" << time_diff(time1, time1) << "ms"; + paddle_mobile::Executor executor(program, 1); + + std::vector dims{1, 3, 227, 227}; + Tensor input_tensor; + SetupTensor(&input_tensor, {1, 3, 227, 227}, static_cast(0), + static_cast(1)); + + std::vector input(input_tensor.data(), + input_tensor.data() + input_tensor.numel()); + auto time3 = time(); + executor.predict(input, dims); + auto time4 = time(); + DLOG << "predict cost :" << time_diff(time3, time4) << "ms"; + return 0; +} diff --git a/test/test_helper.h b/test/test_helper.h index dba4dec9bbc0a8066eef6c6dea9828dfb9954200..fc4ed6c91dc9b03c1f4dadfd8a4bc94efe3a724e 100644 --- a/test/test_helper.h +++ b/test/test_helper.h @@ -28,6 +28,7 @@ static const std::string g_mobilenet_ssd = "../models/mobilenet+ssd"; static const std::string g_squeezenet = "../models/squeezenet"; static const std::string g_resnet = "../models/image_classification_resnet.inference.model"; +static const std::string g_yolo = "../models/yolo"; static const std::string g_test_image_1x3x224x224 = "../images/test_image_1x3x224x224_float"; using paddle_mobile::framework::DDim;