diff --git a/.gitlab/ci/build.gitlab-ci.yml b/.gitlab/ci/build.gitlab-ci.yml index 365b6ddf4d009476122188adf1770243022ee663..208a7e8704fc83e275816b6a81d700cbff949c23 100644 --- a/.gitlab/ci/build.gitlab-ci.yml +++ b/.gitlab/ci/build.gitlab-ci.yml @@ -122,10 +122,6 @@ build:ubuntu_python: - docker script: # Download dependencies - # aidge_core (CPP) - - 'curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:ubuntu_cpp"' - - unzip -o build_artifacts.zip -d . - - rm -rf build_cpp # aidge_core (Python) - 'curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:ubuntu_python"' - unzip -o build_artifacts.zip -d . @@ -133,8 +129,6 @@ build:ubuntu_python: - python3 -m pip install virtualenv - virtualenv venv - source venv/bin/activate - - export AIDGE_INSTALL=`pwd`/install - - export CMAKE_PREFIX_PATH=../install_cpp - python3 -m pip install . artifacts: expire_in: 1 week @@ -195,10 +189,6 @@ build:windows_python: - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") script: # Download dependencies - # aidge_core (CPP) - - 'curl "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:windows_cpp" -o build_artifacts.zip' - - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force - - Remove-Item .\build_cpp\ -Recurse # aidge_core (Python) - 'curl "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:windows_python" -o build_artifacts.zip' - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force @@ -208,8 +198,6 @@ build:windows_python: - venv\Scripts\Activate.ps1 # Numpy dependancy for unit test - python -m pip install numpy - - $env:AIDGE_INSTALL = "$pwd" + "install" - - $env:CMAKE_PREFIX_PATH = "../install_cpp" - python -m pip install . artifacts: expire_in: 1 week diff --git a/CMakeLists.txt b/CMakeLists.txt index 51ee1f6d5df771fcccd1b05a45861eb2f1d3bbbe..51a6ebe10d7b8d03fcb94898de55734dbabf9b0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,11 +12,6 @@ set(module_name _${project}) # target name project(${project}) -############################################## -# Import utils CMakeLists -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") -include(PybindModuleCreation) - ############################################## # Define options option(PYBIND "python binding" ON) diff --git a/include/aidge/backend/cpu/operator/PadImpl_forward_kernels.hpp b/include/aidge/backend/cpu/operator/PadImpl_forward_kernels.hpp index 1babc3ecf2ff2fa8db2fd5ffbd34d89b8d7d88b6..8b793257d2f3f126793316d463fe2542512da939 100644 --- a/include/aidge/backend/cpu/operator/PadImpl_forward_kernels.hpp +++ b/include/aidge/backend/cpu/operator/PadImpl_forward_kernels.hpp @@ -37,8 +37,8 @@ void PadImpl2D_cpu_forward_kernel(const Pad_Op<2>::Attrs &attrs, const std::arra const I *input = static_cast<const I *>(input_); O *output = static_cast<O *>(output_); - const std::size_t oySize = dims[2] + std::get<0>(attrs)[0][0] + std::get<0>(attrs)[0][1]; - const std::size_t oxSize = dims[3] + std::get<0>(attrs)[1][0] + std::get<0>(attrs)[1][1]; + const std::size_t oySize = dims[2] + std::get<0>(attrs)[0] + std::get<0>(attrs)[1]; + const std::size_t oxSize = dims[3] + std::get<0>(attrs)[2] + std::get<0>(attrs)[3]; for (std::size_t batch = 0; batch < dims[0]; ++batch) { for (std::size_t ch = 0; ch < dims[1]; ++ch) { @@ -52,22 +52,22 @@ void PadImpl2D_cpu_forward_kernel(const Pad_Op<2>::Attrs &attrs, const std::arra O outputValue = std::get<2>(attrs); if (std::get<1>(attrs) == PadBorderType::Constant) { - int ix = static_cast<int>(ox) - static_cast<int>(std::get<0>(attrs)[1][1]); - int iy = static_cast<int>(oy) - static_cast<int>(std::get<0>(attrs)[0][1]); + int ix = static_cast<int>(ox) - static_cast<int>(std::get<0>(attrs)[3]); + int iy = static_cast<int>(oy) - static_cast<int>(std::get<0>(attrs)[1]); if (ix >= 0 && ix < static_cast<int>(dims[3]) && iy >= 0 && iy < static_cast<int>(dims[2])) { outputValue = input[iIndex + static_cast<std::size_t>(ix)*dims[2] + static_cast<std::size_t>(iy)]; } } - else if (std::get<1>(attrs) == PadBorderType::Replicate) { - int ix = std::max(0, std::min(static_cast<int>(dims[3]) - 1, static_cast<int>(ox) - static_cast<int>(std::get<0>(attrs)[1][1]))); - int iy = std::max(0, std::min(static_cast<int>(dims[2]) - 1, static_cast<int>(oy) - static_cast<int>(std::get<0>(attrs)[0][1]))); + else if (std::get<1>(attrs) == PadBorderType::Edge) { + int ix = std::max(0, std::min(static_cast<int>(dims[3]) - 1, static_cast<int>(ox) - static_cast<int>(std::get<0>(attrs)[3]))); + int iy = std::max(0, std::min(static_cast<int>(dims[2]) - 1, static_cast<int>(oy) - static_cast<int>(std::get<0>(attrs)[1]))); outputValue = input[iIndex + static_cast<std::size_t>(ix)*dims[2] + static_cast<std::size_t>(iy)]; } else if (std::get<1>(attrs) == PadBorderType::Reflect) { - int ix = static_cast<int>(ox) - static_cast<int>(std::get<0>(attrs)[1][1]); - int iy = static_cast<int>(oy) - static_cast<int>(std::get<0>(attrs)[0][1]); + int ix = static_cast<int>(ox) - static_cast<int>(std::get<0>(attrs)[3]); + int iy = static_cast<int>(oy) - static_cast<int>(std::get<0>(attrs)[1]); if (ix < 0) ix = 0 - ix; @@ -81,8 +81,8 @@ void PadImpl2D_cpu_forward_kernel(const Pad_Op<2>::Attrs &attrs, const std::arra outputValue = input[iIndex + static_cast<std::size_t>(ix)*dims[2] + static_cast<std::size_t>(iy)]; } else if (std::get<1>(attrs) == PadBorderType::Wrap) { - int ix = (static_cast<int>(dims[3]) + static_cast<int>(ox) - static_cast<int>(std::get<0>(attrs)[1][1])) % static_cast<int>(dims[3]); - int iy = (static_cast<int>(dims[2]) + static_cast<int>(oy) - static_cast<int>(std::get<0>(attrs)[0][1])) % static_cast<int>(dims[2]); + int ix = (static_cast<int>(dims[3]) + static_cast<int>(ox) - static_cast<int>(std::get<0>(attrs)[3])) % static_cast<int>(dims[3]); + int iy = (static_cast<int>(dims[2]) + static_cast<int>(oy) - static_cast<int>(std::get<0>(attrs)[1])) % static_cast<int>(dims[2]); outputValue = input[iIndex + static_cast<std::size_t>(ix)*dims[2] + static_cast<std::size_t>(iy)]; } diff --git a/setup.py b/setup.py index b88329e54feab78e39bd79be0a129030098e216a..60807df560510ad4cfacfdd2b178aca957306439 100644 --- a/setup.py +++ b/setup.py @@ -66,12 +66,13 @@ class CMakeBuild(build_ext): # used to launch setup.py to setup PythonInterp param_py = "-DPYTHON_EXECUTABLE=" + sys.executable + compile_type = 'Debug' install_path = os.path.join(sys.prefix, "lib", "libAidge") if "AIDGE_INSTALL" not in os.environ else os.environ["AIDGE_INSTALL"] - self.spawn(['cmake', str(cwd), param_py, '-DTEST=OFF', f'-DCMAKE_INSTALL_PREFIX:PATH={install_path}']) + self.spawn(['cmake', str(cwd), param_py, '-DTEST=OFF', f'-DCMAKE_INSTALL_PREFIX:PATH={install_path}', f'-DCMAKE_BUILD_TYPE={compile_type}']) if not self.dry_run: - self.spawn(['cmake', '--build', '.', '--config', 'Debug', '-j', max_jobs]) - self.spawn(['cmake', '--install', '.', '--config', 'Debug']) + self.spawn(['cmake', '--build', '.', '--config', compile_type, '-j', max_jobs]) + self.spawn(['cmake', '--install', '.', '--config', compile_type]) os.chdir(str(cwd)) aidge_package = build_lib / (get_project_name()) diff --git a/unit_tests/operator/Test_PadImpl.cpp b/unit_tests/operator/Test_PadImpl.cpp index f40b62faa8207d770b895258c786580f82ae7f21..b603e165392f1a861dc1b40d50b70a53c9256870 100644 --- a/unit_tests/operator/Test_PadImpl.cpp +++ b/unit_tests/operator/Test_PadImpl.cpp @@ -24,7 +24,7 @@ TEST_CASE("[cpu/operator] Pad(forward)") { SECTION("Symmetric Pad") { const int pv = 0; // pad value - std::shared_ptr<Node> myPad = Pad({{1, 1}, {1, 1}}, "mypad", PadBorderType::Constant, static_cast<double>(pv)); + std::shared_ptr<Node> myPad = Pad<2>({1, 1, 1, 1}, "mypad", PadBorderType::Constant, static_cast<double>(pv)); myPad->getOperator()->setDatatype(DataType::Int32); myPad->getOperator()->setBackend("cpu"); std::shared_ptr<Tensor> myInput = std::make_shared<Tensor>(Array4D<int,2,3,5,5> { //NCHW @@ -134,7 +134,7 @@ TEST_CASE("[cpu/operator] Pad(forward)") { SECTION("Asymmetric Pad") { const int pv = 0; // pad value - std::shared_ptr<Node> myPad = Pad({{1, 0}, {0, 1}}, "mypad", PadBorderType::Constant, static_cast<double>(pv)); + std::shared_ptr<Node> myPad = Pad<2>({1, 0, 0, 1}, "mypad", PadBorderType::Constant, static_cast<double>(pv)); myPad->getOperator()->setDatatype(DataType::Int32); myPad->getOperator()->setBackend("cpu"); std::shared_ptr<Tensor> myInput = std::make_shared<Tensor>(Array4D<int,2,3,5,5> { //NCHW @@ -235,8 +235,8 @@ TEST_CASE("[cpu/operator] Pad(forward)") { REQUIRE(*(myPad->getOperator()->getOutput(0)) == *myOutput); } - SECTION("Pad Replicate") { - std::shared_ptr<Node> myPad = Pad({{1, 1}, {1, 1}}, "mypad", PadBorderType::Replicate); + SECTION("Pad Edge") { + std::shared_ptr<Node> myPad = Pad<2>({1, 1, 1, 1}, "mypad", PadBorderType::Edge); myPad->getOperator()->setDatatype(DataType::Int32); myPad->getOperator()->setBackend("cpu"); std::shared_ptr<Tensor> myInput = std::make_shared<Tensor>(Array4D<int,2,3,5,5> { //NCHW @@ -344,7 +344,7 @@ TEST_CASE("[cpu/operator] Pad(forward)") { } SECTION("Pad Reflect") { - std::shared_ptr<Node> myPad = Pad({{1, 1}, {1, 1}}, "mypad", PadBorderType::Reflect); + std::shared_ptr<Node> myPad = Pad<2>({1, 1, 1, 1}, "mypad", PadBorderType::Reflect); myPad->getOperator()->setDatatype(DataType::Int32); myPad->getOperator()->setBackend("cpu"); std::shared_ptr<Tensor> myInput = std::make_shared<Tensor>(Array4D<int,2,3,5,5> { //NCHW @@ -460,7 +460,7 @@ TEST_CASE("[cpu/operator] Pad(forward)") { } SECTION("Pad Wrap") { - std::shared_ptr<Node> myPad = Pad({{1, 1}, {1, 1}}, "mypad", PadBorderType::Wrap); + std::shared_ptr<Node> myPad = Pad<2>({1, 1, 1, 1}, "mypad", PadBorderType::Wrap); myPad->getOperator()->setDatatype(DataType::Int32); myPad->getOperator()->setBackend("cpu"); std::shared_ptr<Tensor> myInput = std::make_shared<Tensor>(Array4D<int,2,3,5,5> { //NCHW