diff --git a/CMakeLists.txt b/CMakeLists.txt index 0747101e42bffae9a9c06df6463ff794957437bf..2b491694ff0d380114e46e1fb8fcbe43d9ee26ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,12 @@ elseif(V7) add_definitions(-DARMV7) elseif(V8) add_definitions(-DARMV8) -endif(IS_MAC) +else () + add_definitions(-DX86) +endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") set(CMAKE_BUILD_TYPE RelWithDebInfo) set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -90,11 +93,4 @@ endif() add_library(paddle-mobile SHARED ${PADDLE_MOBILE_CC} ${PADDLE_MOBILE_H}) -if (googlenet) -elseif (mobilenet) -elseif (yolo) -elseif (squeezenet) -elseif(resnet) -else () -endif() add_subdirectory(test) diff --git a/src/common/protobuf-c.c b/src/common/protobuf-c.c index d90daeecc90e931d895dbb90fddde21d4a3a62ca..d0e5bab4fdfc1705440b7b3b6a689b4ec2bb3abe 100644 --- a/src/common/protobuf-c.c +++ b/src/common/protobuf-c.c @@ -918,30 +918,6 @@ static inline size_t binary_data_pack(const ProtobufCBinaryData *bd, return rv + len; } -/** - * Pack a ProtobufCMessage and return the number of bytes written. The output - * includes a length delimiter. - * - * \param message - * ProtobufCMessage object to pack. - * \param[out] out - * Packed message. - * \return - * Number of bytes written to `out`. - */ -static inline size_t prefixed_message_pack(const ProtobufCMessage *message, - uint8_t *out) { - if (message == NULL) { - out[0] = 0; - return 1; - } else { - size_t rv = protobuf_c_message_pack(message, out + 1); - uint32_t rv_packed_size = uint32_size(rv); - if (rv_packed_size != 1) memmove(out + rv_packed_size, out + 1, rv); - return uint32_pack(rv, out) + rv; - } -} - /** * Pack a field tag. * @@ -963,143 +939,6 @@ static size_t tag_pack(uint32_t id, uint8_t *out) { return uint64_pack(((uint64_t)id) << 3, out); } -/** - * Pack a required field and return the number of bytes written. - * - * \param field - * Field descriptor. - * \param member - * The field member. - * \param[out] out - * Packed value. - * \return - * Number of bytes written to `out`. - */ -static size_t required_field_pack(const ProtobufCFieldDescriptor *field, - const void *member, uint8_t *out) { - size_t rv = tag_pack(field->id, out); - - switch (field->type) { - case PROTOBUF_C_TYPE_SINT32: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + sint32_pack(*(const int32_t *)member, out + rv); - case PROTOBUF_C_TYPE_ENUM: - case PROTOBUF_C_TYPE_INT32: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + int32_pack(*(const int32_t *)member, out + rv); - case PROTOBUF_C_TYPE_UINT32: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + uint32_pack(*(const uint32_t *)member, out + rv); - case PROTOBUF_C_TYPE_SINT64: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + sint64_pack(*(const int64_t *)member, out + rv); - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + uint64_pack(*(const uint64_t *)member, out + rv); - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - out[0] |= PROTOBUF_C_WIRE_TYPE_32BIT; - return rv + fixed32_pack(*(const uint32_t *)member, out + rv); - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - out[0] |= PROTOBUF_C_WIRE_TYPE_64BIT; - return rv + fixed64_pack(*(const uint64_t *)member, out + rv); - case PROTOBUF_C_TYPE_BOOL: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + boolean_pack(*(const protobuf_c_boolean *)member, out + rv); - case PROTOBUF_C_TYPE_STRING: - out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - return rv + string_pack(*(char *const *)member, out + rv); - case PROTOBUF_C_TYPE_BYTES: - out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - return rv + - binary_data_pack((const ProtobufCBinaryData *)member, out + rv); - case PROTOBUF_C_TYPE_MESSAGE: - out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - return rv + prefixed_message_pack(*(ProtobufCMessage *const *)member, - out + rv); - } - PROTOBUF_C__ASSERT_NOT_REACHED(); - return 0; -} - -/** - * Pack a oneof field and return the number of bytes written. Only packs the - * field that is selected by the case enum. - * - * \param field - * Field descriptor. - * \param oneof_case - * Enum value that selects the field in the oneof. - * \param member - * The field member. - * \param[out] out - * Packed value. - * \return - * Number of bytes written to `out`. - */ -static size_t oneof_field_pack(const ProtobufCFieldDescriptor *field, - uint32_t oneof_case, const void *member, - uint8_t *out) { - if (oneof_case != field->id) { - return 0; - } - if (field->type == PROTOBUF_C_TYPE_MESSAGE || - field->type == PROTOBUF_C_TYPE_STRING) { - const void *ptr = *(const void *const *)member; - if (ptr == NULL || ptr == field->default_value) return 0; - } - return required_field_pack(field, member, out); -} - -/** - * Pack an optional field and return the number of bytes written. - * - * \param field - * Field descriptor. - * \param has - * Whether the field is set. - * \param member - * The field member. - * \param[out] out - * Packed value. - * \return - * Number of bytes written to `out`. - */ -static size_t optional_field_pack(const ProtobufCFieldDescriptor *field, - const protobuf_c_boolean has, - const void *member, uint8_t *out) { - if (field->type == PROTOBUF_C_TYPE_MESSAGE || - field->type == PROTOBUF_C_TYPE_STRING) { - const void *ptr = *(const void *const *)member; - if (ptr == NULL || ptr == field->default_value) return 0; - } else { - if (!has) return 0; - } - return required_field_pack(field, member, out); -} - -/** - * Pack an unlabeled field and return the number of bytes written. - * - * \param field - * Field descriptor. - * \param member - * The field member. - * \param[out] out - * Packed value. - * \return - * Number of bytes written to `out`. - */ -static size_t unlabeled_field_pack(const ProtobufCFieldDescriptor *field, - const void *member, uint8_t *out) { - if (field_is_zeroish(field, member)) return 0; - return required_field_pack(field, member, out); -} - /** * Given a field type, return the in-memory size. * diff --git a/src/framework/data_transform.h b/src/framework/data_transform.h deleted file mode 100644 index dee78b296c715d018bd7b18811d83f2c8453459e..0000000000000000000000000000000000000000 --- a/src/framework/data_transform.h +++ /dev/null @@ -1,36 +0,0 @@ -/* 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. */ - -#pragma once - -#include -#include -#include - -#include "framework/op_kernel_type.h" -#include "framework/tensor.h" -#include "framework/variable.h" - -namespace paddle_mobile { -namespace framework { - -void DataTransform(const OpKernelType &expected_kernel_type, - const OpKernelType &kernel_type_for_var, - const Tensor &input_tensor, Tensor *out); - -void CopyVariableWithTensor(const Variable &in_var, const Tensor &tensor, - Variable *out_var); - -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/program/program.cpp b/src/framework/program/program.cpp deleted file mode 100644 index 83e389917c76df50ea0380795b36ff012da01568..0000000000000000000000000000000000000000 --- a/src/framework/program/program.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* 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. */ - -namespace paddle_mobile { -namespace framework {} -} // namespace paddle_mobile diff --git a/src/framework/program/tensor_desc.cpp b/src/framework/program/tensor_desc.cpp deleted file mode 100644 index 1b4bd93f6f19426407868052e5366ebeeaedda69..0000000000000000000000000000000000000000 --- a/src/framework/program/tensor_desc.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* 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. */ - -// -// Created by liuRuiLong on 2018/5/26. -// - -#include "tensor_desc.h" diff --git a/src/framework/program/var_desc.cpp b/src/framework/program/var_desc.cpp deleted file mode 100644 index e54ae67b55c15540a0232dc6fdd97e70ae721ddb..0000000000000000000000000000000000000000 --- a/src/framework/program/var_desc.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* 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 "var_desc.h" - -namespace paddle_mobile { - -namespace framework {} // namespace framework -} // namespace paddle_mobile diff --git a/src/io/io.cpp b/src/io/io.cpp index 5c7f34f6cc4f5b7d616c0a40b2875b83851b6602..5eb1582a70b9f63925e02c41a486d30cae0c7f44 100644 --- a/src/io/io.cpp +++ b/src/io/io.cpp @@ -14,9 +14,9 @@ limitations under the License. */ #include "io.h" #include -#include "common/log.h" #include "common/enforce.h" +#include "common/log.h" #include "framework/framework.pb-c.h" #include "framework/lod_tensor.h" #include "framework/operator.h" diff --git a/src/operators/batchnorm_op.cpp b/src/operators/batchnorm_op.cpp index 815eac8806c82c2a167fc7c462d2e76f1bb233fd..0de5111d0625b45efd51c5afac989391631a3bed 100644 --- a/src/operators/batchnorm_op.cpp +++ b/src/operators/batchnorm_op.cpp @@ -15,6 +15,8 @@ limitations under the License. */ #ifdef BATCHNORM_OP #include "batchnorm_op.h" +#include "framework/op_proto_maker.h" +#include "framework/op_registry.h" namespace paddle_mobile { namespace operators { diff --git a/src/operators/pool_op.cpp b/src/operators/pool_op.cpp index e1c5b5ada3478fe35eb989a262815917205b5063..45a709d20794e9fdfad15f0a3ec499d3f32d5bf9 100644 --- a/src/operators/pool_op.cpp +++ b/src/operators/pool_op.cpp @@ -15,6 +15,8 @@ limitations under the License. */ #ifdef POOL_OP #include "pool_op.h" +#include "framework/op_proto_maker.h" +#include "framework/op_registry.h" namespace paddle_mobile { namespace operators { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c71306281e3354cd1856ecaa7278266b031b665c..a799c648b660625d0a61c89cbaf8b2b3d0eda2d1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,116 +1,136 @@ - set(dir ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${dir}/build") -# gen test -ADD_EXECUTABLE(test-conv-op operators/test_cov_op.cpp test_helper.h test_include.h executor_for_test.h) -target_link_libraries(test-conv-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-mul-op operators/test_mul_op.cpp test_helper.h test_include.h) -target_link_libraries(test-mul-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-elementwiseadd-op operators/test_elementwise_add_op.cpp test_helper.h test_include.h) -target_link_libraries(test-elementwiseadd-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-concat-op operators/test_concat_op.cpp test_helper.h test_include.h) -target_link_libraries(test-concat-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-lrn-op operators/test_lrn_op.cpp test_helper.h test_include.h) -target_link_libraries(test-lrn-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-batchnorm-op operators/test_batchnorm_op.cpp test_helper.h test_include.h) -target_link_libraries(test-batchnorm-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-priorbox-op operators/test_prior_box_op.cpp test_helper.h test_include.h) -target_link_libraries(test-priorbox-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-boxcoder-op operators/test_box_coder_op.cpp test_helper.h test_include.h) -target_link_libraries(test-boxcoder-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-transpose-op operators/test_transpose_op.cpp test_helper.h test_include.h) -target_link_libraries(test-transpose-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-multiclassnms-op operators/test_multiclass_nms_op.cpp test_helper.h test_include.h) -target_link_libraries(test-multiclassnms-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-reshape-op operators/test_reshape_op.cpp test_helper.h test_include.h) -target_link_libraries(test-reshape-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-relu-op operators/test_relu_op.cpp test_helper.h test_include.h) -target_link_libraries(test-relu-op paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-fc-op operators/test_fushion_fc_op.cpp test_helper.h test_include.h) -target_link_libraries(test-fc-op paddle-mobile) - -# gen test log -ADD_EXECUTABLE(test-log common/test_log.cpp) -target_link_libraries(test-log paddle-mobile) - -# gen test log -ADD_EXECUTABLE(test-load framework/test_load.cpp) -target_link_libraries(test-load paddle-mobile) - -# gen test log -# gen test -ADD_EXECUTABLE(test-optimize framework/test_optimize.cpp) -target_link_libraries(test-optimize paddle-mobile) - - -#gen test -ADD_EXECUTABLE(test-pool operators/test_pool_op.cpp test_helper.h test_include.h executor_for_test.h) -target_link_libraries(test-pool paddle-mobile) - -#gen test -ADD_EXECUTABLE(test-softmax operators/test_softmax_op.cpp test_helper.h test_include.h executor_for_test.h) -target_link_libraries(test-softmax paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-gemm common/test_gemm.cpp) -target_link_libraries(test-gemm paddle-mobile) +if (googlenet) + # 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) +elseif (mobilenet) + # 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) +elseif (yolo) + # 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) +elseif (squeezenet) + # gen test + ADD_EXECUTABLE(test-squeezenet net/test_squeezenet.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-squeezenet paddle-mobile) +elseif(resnet) + # gen test + ADD_EXECUTABLE(test-resnet net/test_resnet.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-resnet paddle-mobile) +else () + + # gen test + ADD_EXECUTABLE(test-resnet net/test_resnet.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-resnet paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-squeezenet net/test_squeezenet.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-squeezenet 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-conv-op operators/test_cov_op.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-conv-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-mul-op operators/test_mul_op.cpp test_helper.h test_include.h) + target_link_libraries(test-mul-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-elementwiseadd-op operators/test_elementwise_add_op.cpp test_helper.h test_include.h) + target_link_libraries(test-elementwiseadd-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-concat-op operators/test_concat_op.cpp test_helper.h test_include.h) + target_link_libraries(test-concat-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-lrn-op operators/test_lrn_op.cpp test_helper.h test_include.h) + target_link_libraries(test-lrn-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-batchnorm-op operators/test_batchnorm_op.cpp test_helper.h test_include.h) + target_link_libraries(test-batchnorm-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-priorbox-op operators/test_prior_box_op.cpp test_helper.h test_include.h) + target_link_libraries(test-priorbox-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-boxcoder-op operators/test_box_coder_op.cpp test_helper.h test_include.h) + target_link_libraries(test-boxcoder-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-transpose-op operators/test_transpose_op.cpp test_helper.h test_include.h) + target_link_libraries(test-transpose-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-multiclassnms-op operators/test_multiclass_nms_op.cpp test_helper.h test_include.h) + target_link_libraries(test-multiclassnms-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-reshape-op operators/test_reshape_op.cpp test_helper.h test_include.h) + target_link_libraries(test-reshape-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-relu-op operators/test_relu_op.cpp test_helper.h test_include.h) + target_link_libraries(test-relu-op paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-fc-op operators/test_fushion_fc_op.cpp test_helper.h test_include.h) + target_link_libraries(test-fc-op paddle-mobile) + + # gen test log + ADD_EXECUTABLE(test-log common/test_log.cpp) + target_link_libraries(test-log paddle-mobile) + + # gen test log + ADD_EXECUTABLE(test-load framework/test_load.cpp) + target_link_libraries(test-load paddle-mobile) + + # gen test log + # gen test + ADD_EXECUTABLE(test-optimize framework/test_optimize.cpp) + target_link_libraries(test-optimize paddle-mobile) + + + #gen test + ADD_EXECUTABLE(test-pool operators/test_pool_op.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-pool paddle-mobile) + + #gen test + ADD_EXECUTABLE(test-softmax operators/test_softmax_op.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-softmax paddle-mobile) + + # gen test + ADD_EXECUTABLE(test-gemm common/test_gemm.cpp) + target_link_libraries(test-gemm paddle-mobile) -# gen test -ADD_EXECUTABLE(test-enforce common/test_enforce.cpp) -target_link_libraries(test-enforce paddle-mobile) + # gen test + 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-mobilenetssd net/test_mobilenet+ssd.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-mobilenetssd 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-sigmoid operators/test_sigmoid_op.cpp test_include.h) + target_link_libraries(test-sigmoid 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-depthwise-conv-op operators/test_depthwise_conv_op.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-depthwise-conv-op paddle-mobile) -# gen test -ADD_EXECUTABLE(test-resnet net/test_resnet.cpp test_helper.h test_include.h executor_for_test.h) -target_link_libraries(test-resnet paddle-mobile) -# gen test -ADD_EXECUTABLE(test-mobilenetssd net/test_mobilenet+ssd.cpp test_helper.h test_include.h executor_for_test.h) -target_link_libraries(test-mobilenetssd paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-squeezenet net/test_squeezenet.cpp test_helper.h test_include.h executor_for_test.h) -target_link_libraries(test-squeezenet paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-sigmoid operators/test_sigmoid_op.cpp test_include.h) -target_link_libraries(test-sigmoid paddle-mobile) - -# gen test -ADD_EXECUTABLE(test-depthwise-conv-op operators/test_depthwise_conv_op.cpp test_helper.h test_include.h executor_for_test.h) -target_link_libraries(test-depthwise-conv-op paddle-mobile) +endif() diff --git a/tools/build.sh b/tools/build.sh index 2b370b93a5b8b4ee0ba2e7d679f8b0fc4b461b8f..e7869bb890429dd455fe25539974b4bc639a0d81 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -33,6 +33,7 @@ build_for_mac() { } build_for_android() { + rm -rf "../build" if [ -z "${ANDROID_NDK}" ]; then echo "ANDROID_NDK not found!" exit -1 @@ -61,37 +62,36 @@ build_for_android() { TOOLCHAIN_FILE="./tools/android-cmake/android.toolchain.cmake" ANDROID_ARM_MODE="arm" if [ $# -eq 1 ]; then - NET=$1 - cmake . \ - -B"build/release/${PLATFORM}" \ - -DANDROID_ABI="${ABI}" \ - -DCMAKE_BUILD_TYPE="${MODE}" \ - -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ - -DANDROID_PLATFORM="${ANDROID_PLATFORM_VERSION}" \ - -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ - -DANDROID_STL=c++_static \ - -DANDROID=true \ - -D"${NET}=true" \ - -D"${ARM_PLATFORM}"=true + NET=$1 + cmake .. \ + -B"../build/release/${PLATFORM}" \ + -DANDROID_ABI="${ABI}" \ + -DCMAKE_BUILD_TYPE="${MODE}" \ + -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ + -DANDROID_PLATFORM="${ANDROID_PLATFORM_VERSION}" \ + -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ + -DANDROID_STL=c++_static \ + -DANDROID=true \ + -D"${NET}"=true \ + -D"${ARM_PLATFORM}"=true else - - cmake .. \ - -B"../build/release/${PLATFORM}" \ - -DANDROID_ABI="${ABI}" \ - -DCMAKE_BUILD_TYPE="${MODE}" \ - -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ - -DANDROID_PLATFORM="${ANDROID_PLATFORM_VERSION}" \ - -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ - -DANDROID_STL=c++_static \ - -DANDROID=true \ - -D"${ARM_PLATFORM}"=true + cmake .. \ + -B"../build/release/${PLATFORM}" \ + -DANDROID_ABI="${ABI}" \ + -DCMAKE_BUILD_TYPE="${MODE}" \ + -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ + -DANDROID_PLATFORM="${ANDROID_PLATFORM_VERSION}" \ + -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ + -DANDROID_STL=c++_static \ + -DANDROID=true \ + -D"${ARM_PLATFORM}"=true fi cd "../build/release/${PLATFORM}" make -j 8 - } build_for_ios() { + rm -rf "../build" PLATFORM="ios" MODE="Release" BUILD_DIR=../build/release/"${PLATFORM}" @@ -99,16 +99,27 @@ build_for_ios() { C_FLAGS="-fobjc-abi-version=2 -fobjc-arc -isysroot ${CMAKE_OSX_SYSROOT}" CXX_FLAGS="-fobjc-abi-version=2 -fobjc-arc -std=gnu++11 -stdlib=libc++ -isysroot ${CMAKE_OSX_SYSROOT}" mkdir -p "${BUILD_DIR}" - - cmake .. \ - -B"${BUILD_DIR}" \ - -DCMAKE_BUILD_TYPE="${MODE}" \ - -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ - -DIOS_PLATFORM=OS \ - -DCMAKE_C_FLAGS="${C_FLAGS}" \ - -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ - -DIS_IOS="true" \ - + if [ $# -eq 1 ]; then + NET=$1 + cmake .. \ + -B"${BUILD_DIR}" \ + -DCMAKE_BUILD_TYPE="${MODE}" \ + -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ + -DIOS_PLATFORM=OS \ + -DCMAKE_C_FLAGS="${C_FLAGS}" \ + -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ + -D"${NET}"=true \ + -DIS_IOS="true" + else + cmake .. \ + -B"${BUILD_DIR}" \ + -DCMAKE_BUILD_TYPE="${MODE}" \ + -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ + -DIOS_PLATFORM=OS \ + -DCMAKE_C_FLAGS="${C_FLAGS}" \ + -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \ + -DIS_IOS="true" + fi cd "${BUILD_DIR}" make -j 8 } @@ -123,8 +134,7 @@ if [ $# -lt 1 ]; then echo "sample usage: ./build.sh mac" else if [ $# -eq 2 ]; then - - if [[$2 != "googlenet"]] -a [[$2 != "mobilenet"]] -a [[$2 != "yolo"]] -a [[$2 != "squeezenet"]] -a [[$2 != "resnet"]]; then + if [ $2 != "googlenet" -a $2 != "mobilenet" -a $2 != "yolo" -a $2 != "squeezenet" -a $2 != "resnet" ]; then if [ $1 = "mac" ]; then build_for_mac elif [ $1 = "linux" ]; then diff --git a/tools/scripts/push2android.sh b/tools/scripts/push2android.sh index 9b69e28b8afd675b36f96b7502bbcc749122d761..33737f2ed37a233dc17892591f429a24c1832a4b 100644 --- a/tools/scripts/push2android.sh +++ b/tools/scripts/push2android.sh @@ -7,7 +7,7 @@ EXE_FILE="../../test/build/*" EXE_DIR="data/local/tmp/bin" MODELS_DIR="data/local/tmp/models" IMAGES_DIR="data/local/tmp/images" -LIB_PATH="../build/release/arm-v7a/build/*" +LIB_PATH="../../build/release/arm-v7a/build/*" adb push ${EXE_FILE} ${EXE_DIR} adb push ${LIB_PATH} ${EXE_DIR} adb push ${IMAGE_PATH} ${IMAGES_DIR}