From 05a162377378918565a159f7cd4ef0877092a415 Mon Sep 17 00:00:00 2001 From: "zhaode.wzd" Date: Thu, 21 Sep 2023 21:29:53 +0800 Subject: [PATCH] [Compile:Bugfix] Bugfix of action and compile. --- .github/workflows/pymnn_macos.yml | 4 ++-- package_scripts/win/build_lib_release.ps1 | 4 +++- pymnn/test/unit_test.py | 6 ++++-- source/backend/cuda/core/CUDABackend.cpp | 1 + source/backend/opengl/GLBackend.hpp | 2 ++ source/core/Backend.cpp | 3 +++ source/core/Backend.hpp | 5 +---- source/core/BufferAllocator.cpp | 3 +++ source/core/BufferAllocator.hpp | 2 +- 9 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pymnn_macos.yml b/.github/workflows/pymnn_macos.yml index 3d5ed2eea..b8834438d 100644 --- a/.github/workflows/pymnn_macos.yml +++ b/.github/workflows/pymnn_macos.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: '3.8.10' - name: prepare run: | pip3 install numpy opencv-python torch @@ -34,7 +34,7 @@ jobs: run: | cd pymnn/pip_package python3 build_deps.py - sudo python3 setup.py install --version 1.0 + python3 setup.py install --version 1.0 - name: test run: | cd pymnn/test diff --git a/package_scripts/win/build_lib_release.ps1 b/package_scripts/win/build_lib_release.ps1 index 9e655cb09..71ca3289c 100644 --- a/package_scripts/win/build_lib_release.ps1 +++ b/package_scripts/win/build_lib_release.ps1 @@ -26,13 +26,15 @@ mkdir -p $PACKAGE_LIB_PATH #clear and create package directory powershell ./schema/generate.ps1 -pushd $PACKAGE_LIB_PATH + if ($cibuild) { + pushd $PACKAGE_LIB_PATH mkdir -p Release\Dynamic\MT } else { Remove-Item -Path $PACKAGE_PATH/include -Recurse -ErrorAction Ignore cp -r include $PACKAGE_PATH cp -r tools/cv/include/cv $PACKAGE_PATH/include + pushd $PACKAGE_LIB_PATH mkdir -p Release\Dynamic\MT, Release\Dynamic\MD, Release\Static\MD, Release\Static\MT } popd diff --git a/pymnn/test/unit_test.py b/pymnn/test/unit_test.py index cbaab2608..25ca4b0f6 100644 --- a/pymnn/test/unit_test.py +++ b/pymnn/test/unit_test.py @@ -194,7 +194,7 @@ def test_greater_equal(self): def test_less(self): self.assertEqualVar(expr.less(self.x, self.x), np.less(self.x_, self.x_)) def test_floordiv(self): - self.assertEqualVar(expr.floordiv(self.x, self.x), np.floor_divide(self.x_, self.x_)) + self.assertEqualVar(expr.floordiv(2.0, 1.2), np.floor_divide(2.0, 1.2)) def test_less(self): self.assertEqualVar(expr.less(self.x, self.x), np.less(self.x_, self.x_)) def test_squared_difference(self): @@ -784,7 +784,9 @@ def test_Structural(self): rect = cv.minAreaRect(contour) rect_ = cv2.minAreaRect(contour_) if version_info.major >= 3: - self.assertEqual(rect, rect_) + rect_list = [rect[0][0], rect[0][1], rect[1][0], rect[1][0], rect[2]] + rect__list = [rect_[0][0], rect_[0][1], rect_[1][0], rect_[1][0], rect_[2]] + self.assertEqualArray(np.array(rect_list), np.array(rect__list)) points = cv.boxPoints(rect) points_ = cv2.boxPoints(rect_) if version_info.major >= 3: diff --git a/source/backend/cuda/core/CUDABackend.cpp b/source/backend/cuda/core/CUDABackend.cpp index a69154125..7ed2e5690 100644 --- a/source/backend/cuda/core/CUDABackend.cpp +++ b/source/backend/cuda/core/CUDABackend.cpp @@ -302,6 +302,7 @@ void CUDABackend::onResizeBegin() { } ErrorCode CUDABackend::onResizeEnd() { + return NO_ERROR; } void CUDABackend::onExecuteBegin() const { diff --git a/source/backend/opengl/GLBackend.hpp b/source/backend/opengl/GLBackend.hpp index 7c8ad0880..95783d7cd 100644 --- a/source/backend/opengl/GLBackend.hpp +++ b/source/backend/opengl/GLBackend.hpp @@ -99,6 +99,8 @@ class GLBackend : public Backend { virtual void onExecuteEnd() const override; + ErrorCode onResizeEnd() { return NO_ERROR; } + /// get execution virtual Execution* onCreate(const std::vector& inputs, const std::vector& outputs, const MNN::Op* op) override; diff --git a/source/core/Backend.cpp b/source/core/Backend.cpp index 9c0770dab..6f939feb0 100644 --- a/source/core/Backend.cpp +++ b/source/core/Backend.cpp @@ -83,6 +83,9 @@ bool Backend::onAcquireBuffer(const Tensor* tensor, StorageType storageType) { TensorUtils::getDescribe(tensor)->mem.reset(mem); return true; } +ErrorCode Backend::onResizeEnd() { + return NO_ERROR; +} bool Backend::onReleaseBuffer(const Tensor* tensor, StorageType storageType) { TensorUtils::getDescribe(tensor)->mem.reset(nullptr); return true; diff --git a/source/core/Backend.hpp b/source/core/Backend.hpp index 06ed11b8b..840713e89 100644 --- a/source/core/Backend.hpp +++ b/source/core/Backend.hpp @@ -115,10 +115,7 @@ class Backend : public NonCopyable { /** * @brief callback after resize ops. */ - virtual ErrorCode onResizeEnd() { - // nothing to do - return NO_ERROR; - } + virtual ErrorCode onResizeEnd(); /** * @brief callback before executing ops. diff --git a/source/core/BufferAllocator.cpp b/source/core/BufferAllocator.cpp index e82d3033b..371faf959 100644 --- a/source/core/BufferAllocator.cpp +++ b/source/core/BufferAllocator.cpp @@ -72,6 +72,9 @@ class RecurseAllocator : public BufferAllocator::Allocator { BufferAllocator* mParent; }; +ErrorCode BufferAllocator::compute() { + return NO_ERROR; +} std::shared_ptr BufferAllocator::Allocator::createDefault() { std::shared_ptr _res; _res.reset(new DefaultAllocator); diff --git a/source/core/BufferAllocator.hpp b/source/core/BufferAllocator.hpp index 07ab0ea19..010d0107e 100644 --- a/source/core/BufferAllocator.hpp +++ b/source/core/BufferAllocator.hpp @@ -98,7 +98,7 @@ class MNN_PUBLIC BufferAllocator : public NonCopyable { virtual void beginGroup() {} virtual void endGroup() {} virtual void reset() {} - virtual ErrorCode compute() { return NO_ERROR; } + virtual ErrorCode compute(); };