Skip to content
Snippets Groups Projects
Commit 216d6948 authored by laurent soulier's avatar laurent soulier
Browse files

[MERGE][master] updating from master

parents eb3ebace b4c8c60e
No related branches found
No related tags found
No related merge requests found
......@@ -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,7 @@ 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 -r requirements.txt
- python3 -m pip install .
artifacts:
expire_in: 1 week
......@@ -195,10 +190,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
......@@ -206,10 +197,7 @@ build:windows_python:
- python -m pip install virtualenv
- virtualenv venv
- 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 -r requirements.txt
- python -m pip install .
artifacts:
expire_in: 1 week
......
......@@ -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)
......
......@@ -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)];
}
......
......@@ -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())
......@@ -107,6 +108,7 @@ if __name__ == '__main__':
cmdclass={
'build_ext': CMakeBuild,
},
install_requires=['aidge_core'],
zip_safe=False,
)
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment