1: fix cmake cross-ios failed caused by df118a87 build static lib for APPLE define for XCODE third_party framework including require 2: megbrain_test/megdnn_test build when MGE_INFERENCE_ONLY=ON now u can build megbrain_test/megdnn_test by: EXTRA_CMAKE_ARGS="-DMGE_WITH_TEST=ON" ./scripts/cmake-build/xxx.sh example macos-cross-ios build megdnn_test for IOS by EXTRA_CMAKE_ARGS="-DMGE_WITH_TEST=ON" ./scripts/cmake-build/cross_build_ios_arm_inference.sh 3: reuse host flatc build when cross build mode GitOrigin-RevId: 132f4bf893567bdb1d54de506449950513a5841ftags/v1.0.0-rc1
| @@ -40,6 +40,11 @@ option(MGE_USE_SYSTEM_LIB "Build MegEngine with system libraries." OFF) | |||||
| option(MGB_WITH_FLATBUFFERS "Build MegBrain with FlatBuffers serialization support." ON) | option(MGB_WITH_FLATBUFFERS "Build MegBrain with FlatBuffers serialization support." ON) | ||||
| option(BUILD_SHARED_LIBS "Build shared libraries" ON) | option(BUILD_SHARED_LIBS "Build shared libraries" ON) | ||||
| if (APPLE) | |||||
| set (BUILD_SHARED_LIBS OFF) | |||||
| message("build static for xcode framework require") | |||||
| endif() | |||||
| if (MGE_USE_SYSTEM_LIB) | if (MGE_USE_SYSTEM_LIB) | ||||
| set (MGE_CUDA_USE_STATIC OFF) | set (MGE_CUDA_USE_STATIC OFF) | ||||
| endif() | endif() | ||||
| @@ -245,8 +250,6 @@ if(MGE_INFERENCE_ONLY) | |||||
| set(MGE_WITH_DISTRIBUTED OFF) | set(MGE_WITH_DISTRIBUTED OFF) | ||||
| message("-- Disable python module for inference only build.") | message("-- Disable python module for inference only build.") | ||||
| set(MGE_WITH_PYTHON_MODULE OFF) | set(MGE_WITH_PYTHON_MODULE OFF) | ||||
| message("-- Disable tests for inference only build.") | |||||
| set(MGE_WITH_TEST OFF) | |||||
| endif() | endif() | ||||
| if(MGE_WITH_DISTRIBUTED) | if(MGE_WITH_DISTRIBUTED) | ||||
| @@ -469,7 +472,7 @@ endif() | |||||
| set(MGB_ENABLE_TENSOR_RT ${MGE_WITH_TRT}) | set(MGB_ENABLE_TENSOR_RT ${MGE_WITH_TRT}) | ||||
| # Inference only | # Inference only | ||||
| if(MGE_INFERENCE_ONLY) | |||||
| if(MGE_INFERENCE_ONLY AND NOT MGE_WITH_TEST) | |||||
| set(MGB_ENABLE_GRAD 0) | set(MGB_ENABLE_GRAD 0) | ||||
| set(MGB_BUILD_SLIM_SERVING 1) | set(MGB_BUILD_SLIM_SERVING 1) | ||||
| else() | else() | ||||
| @@ -28,6 +28,7 @@ endif() | |||||
| add_executable(megdnn_test ${SOURCES}) | add_executable(megdnn_test ${SOURCES}) | ||||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing") | |||||
| target_link_libraries(megdnn_test gtest) | target_link_libraries(megdnn_test gtest) | ||||
| target_link_libraries(megdnn_test megdnn ${MGE_BLAS_LIBS}) | target_link_libraries(megdnn_test megdnn ${MGE_BLAS_LIBS}) | ||||
| @@ -36,7 +37,9 @@ target_include_directories(megdnn_test | |||||
| ${PROJECT_SOURCE_DIR}/third_party/midout/src | ${PROJECT_SOURCE_DIR}/third_party/midout/src | ||||
| ) | ) | ||||
| if(UNIX) | |||||
| if(APPLE OR ANDROID) | |||||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") | |||||
| else() | |||||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") | ||||
| endif() | endif() | ||||
| @@ -44,6 +47,8 @@ if(MGE_ENABLE_COVERAGE) | |||||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") | ||||
| endif() | endif() | ||||
| if(UNIX) | |||||
| if(APPLE OR ANDROID) | |||||
| target_link_libraries(megdnn_test dl) | |||||
| else() | |||||
| target_link_libraries(megdnn_test dl rt) | target_link_libraries(megdnn_test dl rt) | ||||
| endif() | endif() | ||||
| @@ -79,6 +79,7 @@ std::vector<conv_bias::TestArg> get_nchw44_conv_bias_args( | |||||
| using NLMode = param::ConvBias::NonlineMode; | using NLMode = param::ConvBias::NonlineMode; | ||||
| std::vector<TestArg> args; | std::vector<TestArg> args; | ||||
| MEGDNN_MARK_USED_VAR(no_pad); | |||||
| auto pack = [&](size_t n, size_t oc, size_t ic, size_t h, size_t w, | auto pack = [&](size_t n, size_t oc, size_t ic, size_t h, size_t w, | ||||
| size_t kernel, size_t stride, size_t group, NLMode nlmode, | size_t kernel, size_t stride, size_t group, NLMode nlmode, | ||||
| @@ -175,6 +175,7 @@ TEST_F(ARM_COMMON, QINT8x8x32_GEMV_MK4) { | |||||
| checker.set_rng(0, rng.get()).set_rng(1, rng.get()); | checker.set_rng(0, rng.get()).set_rng(1, rng.get()); | ||||
| auto run = [&](size_t M, size_t K, size_t N) { | auto run = [&](size_t M, size_t K, size_t N) { | ||||
| MEGDNN_MARK_USED_VAR(N); | |||||
| Param param; | Param param; | ||||
| param.format = param::MatrixMul::Format::MK4; | param.format = param::MatrixMul::Format::MK4; | ||||
| param.transposeA = false; | param.transposeA = false; | ||||
| @@ -138,7 +138,7 @@ function cmake_build() { | |||||
| make install/strip | make install/strip | ||||
| } | } | ||||
| build_flatc $SRC_DIR | |||||
| build_flatc $SRC_DIR $REMOVE_OLD_BUILD | |||||
| api_level=16 | api_level=16 | ||||
| abi="armeabi-v7a with NEON" | abi="armeabi-v7a with NEON" | ||||
| @@ -136,7 +136,7 @@ function cmake_build() { | |||||
| make install | make install | ||||
| } | } | ||||
| build_flatc $SRC_DIR | |||||
| build_flatc $SRC_DIR $REMOVE_OLD_BUILD | |||||
| # refs for ../../toolchains/ios.toolchain.cmake | # refs for ../../toolchains/ios.toolchain.cmake | ||||
| # to config this, if u want to build other, | # to config this, if u want to build other, | ||||
| @@ -128,7 +128,7 @@ function cmake_build() { | |||||
| make install/strip | make install/strip | ||||
| } | } | ||||
| build_flatc $SRC_DIR | |||||
| build_flatc $SRC_DIR $REMOVE_OLD_BUILD | |||||
| toolchain=null | toolchain=null | ||||
| if [ "$ARCH" = "arm64-v8a" ]; then | if [ "$ARCH" = "arm64-v8a" ]; then | ||||
| @@ -12,18 +12,30 @@ fi | |||||
| function build_flatc() { | function build_flatc() { | ||||
| BUILD_DIR=$1/build_dir/host_flatc/build | BUILD_DIR=$1/build_dir/host_flatc/build | ||||
| INSTALL_DIR=$BUILD_DIR/../install | INSTALL_DIR=$BUILD_DIR/../install | ||||
| if [ -e $BUILD_DIR ];then | |||||
| echo "clean old dir: $BUILD_DIR" | |||||
| rm -rf $BUILD_DIR | |||||
| REMOVE_OLD_BUILD=$2 | |||||
| if [ $REMOVE_OLD_BUILD = "true" ]; then | |||||
| if [ -e $BUILD_DIR ];then | |||||
| echo "clean old dir: $BUILD_DIR" | |||||
| rm -rf $BUILD_DIR | |||||
| fi | |||||
| if [ -e $INSTALL_DIR ];then | |||||
| echo "clean old dir: $INSTALL_DIR" | |||||
| rm -rf $INSTALL_DIR | |||||
| fi | |||||
| else | |||||
| echo "strip remove old build" | |||||
| fi | |||||
| if [ ! -e $BUILD_DIR ];then | |||||
| echo "create build: $BUILD_DIR" | |||||
| mkdir -p $BUILD_DIR | |||||
| fi | fi | ||||
| if [ -e $INSTALL_DIR ];then | |||||
| echo "clean old dir: $INSTALL_DIR" | |||||
| rm -rf $INSTALL_DIR | |||||
| if [ ! -e $INSTALL_DIR ];then | |||||
| echo "create install $INSTALL_DIR" | |||||
| mkdir -p $INSTALL_DIR | |||||
| fi | fi | ||||
| echo "create build dir" | |||||
| mkdir -p $BUILD_DIR | |||||
| mkdir -p $INSTALL_DIR | |||||
| cd $BUILD_DIR | cd $BUILD_DIR | ||||
| cmake -G "$MAKEFILE_TYPE Makefiles" \ | cmake -G "$MAKEFILE_TYPE Makefiles" \ | ||||
| -DCMAKE_BUILD_TYPE=Release \ | -DCMAKE_BUILD_TYPE=Release \ | ||||
| @@ -2,7 +2,7 @@ include_directories(src) | |||||
| file (GLOB_RECURSE SOURCES src/*.cpp main.cpp) | file (GLOB_RECURSE SOURCES src/*.cpp main.cpp) | ||||
| add_executable (load_and_run ${SOURCES}) | add_executable (load_and_run ${SOURCES}) | ||||
| if (WIN32) | |||||
| if (WIN32) | |||||
| # Windows does not support implicitly importing data members from DLL. | # Windows does not support implicitly importing data members from DLL. | ||||
| target_link_libraries(load_and_run megbrain megdnn) | target_link_libraries(load_and_run megbrain megdnn) | ||||
| else() | else() | ||||
| @@ -28,7 +28,9 @@ if(CXX_SUPPORT_WCLASS_MEMACCESS) | |||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| if(UNIX) | |||||
| if(APPLE OR ANDROID) | |||||
| target_link_libraries(megbrain_test dl) | |||||
| else() | |||||
| target_link_libraries(megbrain_test dl rt) | target_link_libraries(megbrain_test dl rt) | ||||
| endif() | endif() | ||||