diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3bb0fa915c..216befb86e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ concurrency: cancel-in-progress: true jobs: - build_cpu: + build_cpu_model_convert: runs-on: ubuntu-18.04 strategy: matrix: @@ -53,12 +53,41 @@ jobs: pip install -U numpy - name: Build and install run: rm -rf .eggs && pip install -e . - - name: Run unittests and generate coverage report + - name: Run python unittests and generate coverage report run: | coverage run --branch --source mmdeploy -m pytest -rsE tests coverage xml coverage report -m + build_cpu_sdk: + runs-on: ubuntu-18.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: 'recursive' + - name: update + run: sudo apt update + - name: gcc-multilib + run: | + sudo apt install gcc-multilib g++-multilib wget libprotobuf-dev protobuf-compiler + sudo apt update + sudo apt install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libxrender-dev libc++1-9 libc++abi1-9 + sudo add-apt-repository ppa:ignaciovizzo/opencv3-nonfree + sudo apt install libopencv-dev lcov wget + pkg-config --libs opencv + - name: Build and run SDK unit test without backend + run: | + mkdir -p build && pushd build + cmake .. -DCMAKE_CXX_COMPILER=g++-7 -DMMDEPLOY_CODEBASES=all -DMMDEPLOY_BUILD_SDK=ON -DMMDEPLOY_BUILD_SDK_PYTHON_API=OFF -DMMDEPLOY_TARGET_DEVICES=cpu -DMMDEPLOY_COVERAGE=ON -DMMDEPLOY_BUILD_TEST=ON + make -j2 + mkdir -p mmdeploy_test_resources/transform + cp ../tests/data/tiger.jpeg mmdeploy_test_resources/transform/ + ./bin/mmdeploy_tests + lcov --capture --directory . --output-file coverage.info + ls -lah coverage.info + cp coverage.info ../ + build_cuda102: runs-on: ubuntu-18.04 container: @@ -153,8 +182,8 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 with: - file: ./coverage.xml + file: ./coverage.xml,./coverage.info flags: unittests - env_vars: OS,PYTHON + env_vars: OS,PYTHON,CPLUS name: codecov-umbrella fail_ci_if_error: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dd7d05165..76e6ebe686 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,8 @@ option(MMDEPLOY_BUILD_SDK_JAVA_API "build SDK JAVA API" OFF) option(MMDEPLOY_BUILD_EXAMPLES "build examples" OFF) option(MMDEPLOY_SPDLOG_EXTERNAL "use external spdlog" OFF) option(MMDEPLOY_ZIP_MODEL "support SDK model in zip format" OFF) +option(MMDEPLOY_COVERAGE "build SDK for coverage" OFF) + set(MMDEPLOY_TARGET_DEVICES "cpu" CACHE STRING "target devices to support") set(MMDEPLOY_TARGET_BACKENDS "" CACHE STRING "target inference engines to support") set(MMDEPLOY_CODEBASES "all" CACHE STRING "select OpenMMLab codebases") @@ -49,6 +51,11 @@ endif () set(MMDEPLOY_TASKS "" CACHE INTERNAL "") +if (MMDEPLOY_COVERAGE) + add_compile_options(-coverage -fprofile-arcs -ftest-coverage) + add_link_options(-coverage -lgcov) +endif () + # when CUDA devices are enabled, the environment variable ASAN_OPTIONS=protect_shadow_gap=0 # must be set at runtime if (MMDEPLOY_ASAN_ENABLE) diff --git a/csrc/mmdeploy/preprocess/transform/collect.cpp b/csrc/mmdeploy/preprocess/transform/collect.cpp index 119415cd70..2a63a9b570 100644 --- a/csrc/mmdeploy/preprocess/transform/collect.cpp +++ b/csrc/mmdeploy/preprocess/transform/collect.cpp @@ -45,8 +45,7 @@ Result CollectImpl::Process(const Value &input) { } for (auto &key : arg_.keys) { if (!input.contains(key)) { - MMDEPLOY_ERROR("missed key '{}' in input", key); - // return Status(eInvalidArgument); + MMDEPLOY_INFO("missed key '{}' in input", key); return Status(eInvalidArgument); } else { output[key] = input[key]; diff --git a/tests/test_csrc/core/test_execution.cpp b/tests/test_csrc/core/test_execution.cpp index a8bdd39179..5704883cb2 100644 --- a/tests/test_csrc/core/test_execution.cpp +++ b/tests/test_csrc/core/test_execution.cpp @@ -30,7 +30,7 @@ TEST_CASE("test basic execution", "[execution]") { static_assert(std::is_same_v); auto c = Then(b, [](Value v) -> Value { return {{"c", v["a"].get() + v["b"].get()}}; }); auto d = SyncWait(c); - MMDEPLOY_ERROR("{}", d); + MMDEPLOY_INFO("{}", d); } template @@ -45,7 +45,7 @@ TEST_CASE("test split", "[execution]") { auto y = GetKey(s, "y"); auto x_v = SyncWait(x); auto y_v = SyncWait(y); - MMDEPLOY_ERROR("x = {}, y = {}", x_v, y_v); + MMDEPLOY_INFO("x = {}, y = {}", x_v, y_v); } TEST_CASE("test when_all", "[execution]") { @@ -56,7 +56,7 @@ TEST_CASE("test when_all", "[execution]") { auto e = Just(500); auto t = WhenAll(a, b, c, d, e); auto v = SyncWait(t); - MMDEPLOY_ERROR("v = {}", v); + MMDEPLOY_INFO("v = {}", v); } void Func() { @@ -65,7 +65,7 @@ void Func() { LetValue(a, [](int& x, int& y) { return Then(Just(x + y), [](int v) { return v * v; }); }); auto v = SyncWait(b); static_assert(std::is_same_v>); - MMDEPLOY_ERROR("v = {}", v); + MMDEPLOY_INFO("v = {}", v); } TEST_CASE("test let_value", "[execution]") { Func(); } @@ -78,7 +78,7 @@ TEST_CASE("test fork-join", "[execution]") { auto xy = WhenAll(x, y); auto v = SyncWait(xy); static_assert(std::is_same_v>); - MMDEPLOY_ERROR("v = {}", v); + MMDEPLOY_INFO("v = {}", v); } TEST_CASE("test ensure_started", "[execution]") { @@ -97,7 +97,7 @@ TEST_CASE("test ensure_started", "[execution]") { std::this_thread::sleep_for(std::chrono::milliseconds(500)); MMDEPLOY_INFO("ensure_started sync_wait"); auto v = SyncWait(c); - MMDEPLOY_ERROR("ensure_started: {}", v); + MMDEPLOY_INFO("ensure_started: {}", v); } TEST_CASE("test start_detached", "[execution]") { @@ -119,7 +119,7 @@ TEST_CASE("test on", "[execution]") { auto b = On(pool.GetScheduler(), a); auto c = SyncWait(b); static_assert(std::is_same_v>); - MMDEPLOY_ERROR("c = {}", c); + MMDEPLOY_INFO("c = {}", c); } mmdeploy_value_t f(mmdeploy_value_t v, void*) { @@ -246,7 +246,7 @@ TEST_CASE("test executor C API", "[execution]") { REQUIRE(b); auto c = mmdeploy_executor_sync_wait(b); REQUIRE(c); - MMDEPLOY_CRITICAL("{}", *(Value*)c); + MMDEPLOY_INFO("{}", *(Value*)c); mmdeploy_value_destroy(c); } diff --git a/tests/test_csrc/preprocess/test_resize.cpp b/tests/test_csrc/preprocess/test_resize.cpp index 0935e3d56f..da0500912d 100644 --- a/tests/test_csrc/preprocess/test_resize.cpp +++ b/tests/test_csrc/preprocess/test_resize.cpp @@ -116,7 +116,9 @@ void TestResizeWithScaleFactor(const Value& cfg, const std::string& device_name, auto transform = CreateTransform(cfg, device, stream); REQUIRE(transform != nullptr); - auto [dst_height, dst_width] = make_tuple(mat.rows * scale_factor, mat.cols * scale_factor); + // keep round policy with resize.cpp + const int dst_height = static_cast(mat.rows * scale_factor + 0.5); + const int dst_width = static_cast(mat.cols * scale_factor + 0.5); auto interpolation = cfg["interpolation"].get(); auto ref_mat = mmdeploy::cpu::Resize(mat, dst_height, dst_width, interpolation);