Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • eclipse/aidge/aidge_core
  • hrouis/aidge_core
  • mszczep/aidge_core
  • oantoni/aidge_core
  • cguillon/aidge_core
  • jeromeh/aidge_core
  • axelfarr/aidge_core
  • cmoineau/aidge_core
  • noamzerah/aidge_core
  • lrakotoarivony/aidge_core
  • idealbuq/aidge_core
  • silvanosky/aidge_core
  • maab05/aidge_core
  • mick94/aidge_core
  • lucaslopez/aidge_core_ll
  • wboussella/aidge_core
  • farnez/aidge_core
  • mnewson/aidge_core
18 results
Show changes
Commits on Source (994)
Showing
with 526 additions and 1042 deletions
---
Checks: "google-*, readability-identifier-naming"
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
CheckOptions:
# Case style
# Following https://webkit.org/code-style-guidelines/ :
# CamelCase for class,struct, namespace
# camelBack for variables, functions
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.AbstractClassCase'
value: 'CamelCase'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.ClassCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassConstantCase'
value: 'camelBack'
- key: 'readability-identifier-naming.ClassConstantPrefix'
value: 's_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassMemberCase'
value: 'camelBack'
- key: 'readability-identifier-naming.ClassMemberPrefix'
value: 's_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantPointerParameterCase'
value: 'camelBack'
# camelBack for variables, functions
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassMemberCase'
value: 'camelBack'
- key: 'readability-identifier-naming.ClassMemberPrefix'
value: 's_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ClassMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstantPointerParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstexprFunctionCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstexprMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ConstexprVariableCase'
value: 'camelBack'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.EnumCase'
value: 'CamelCase'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.EnumConstantCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.FunctionCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalConstantPointerCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalFunctionCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalPointerCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.GlobalVariableCase'
value: 'camelBack'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.InlineNamespaceCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.LocalConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.LocalConstantPointerCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.LocalPointerCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.LocalVariableCase'
value: 'camelBack'
- key: 'readability-identifier-naming.MacroDefinitionCase'
value: 'UPPER_CASE'
# camelBack for variables, functions
- key: 'readability-identifier-naming.MemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.MethodCase'
value: 'CamelCase'
# CamelCase for class,struct, namespace
- key: 'readability-identifier-naming.NamespaceCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ParameterPackCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PointerParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PrivateMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PrivateMemberPrefix'
value: 'm_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PrivateMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ProtectedMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ProtectedMemberPrefix'
value: 'm_'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ProtectedMethodCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PublicMemberCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.PublicMethodCase'
value: 'camelBack'
- key: 'readability-identifier-naming.ScopedEnumConstantCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.StaticConstantCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.StaticVariableCase'
value: 'camelBack'
- key: 'readability-identifier-naming.StructCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TemplateParameterCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TemplateTemplateParameterCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TypeTemplateParameterIgnoredRegexp'
value: 'expr-type'
# CamelCase for Type aliases
- key: 'readability-identifier-naming.TypeAliasCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TypedefCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.TypeTemplateParameterCase'
value: 'CamelCase'
- key: 'readability-identifier-naming.UnionCase'
value: 'CamelCase'
# camelBack for variables, functions
- key: 'readability-identifier-naming.ValueTemplateParameterCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.VariableCase'
value: 'camelBack'
# camelBack for variables, functions
- key: 'readability-identifier-naming.VirtualMethodCase'
value: 'camelCase'
...
[codespell]
builtin = clear,rare,en-GB_to_en-US,names,informal,code
check-filenames =
check-hidden =
skip = */.git,*/build*,*/prefix,*/aidge_core,*/aidge_core.egg-info,*/cmake,*/future-std.clang-format
quiet-level = 2
# childs : used a lot and understandable
# dOut,inH,ro : used for testing
# deque : cpp data struct
# inout : commented code variable
# nd : commented code
# neighbours : exception to the gb to us english rule
# neighbouring : exception to the gb to us english rule
# endcode : documentation keyword
ignore-words-list = childs, dOut, inH, ro, deque, inout, stdio, nd, neighbours, neighbouring, endcode
# general
.cache
# C++ Build # C++ Build
build*/ build*/
install*/ install*/
cppcheck-result.xml
include/aidge/core_version.h
# VSCode # VSCode
.vscode .vscode
# Python ## Python
# build/packaging artifacts
*.so *.so
__pycache__ __pycache__
*.pyc *.pyc
*.egg-info
dist*/ dist*/
*.egg-info
wheelhouse/*
aidge_core/_version.py
# test artifact
aidge_core/dummy_export/*
*xmlrunner-results.xml
# Mermaid # Mermaid
*.mmd *.mmd
...@@ -19,4 +30,4 @@ dist*/ ...@@ -19,4 +30,4 @@ dist*/
xml*/ xml*/
# ONNX # ONNX
*.onnx *.onnx
\ No newline at end of file
############################################################################### ###############################################################################
# Aidge Continious Integration and Continious Deployment # # Aidge Continuous Integration and Deployment #
# # # #
############################################################################### ###############################################################################
stages: stages:
# Analyse code
- static_analysis - static_analysis
# Build Aidge
- build - build
# Unit test stage
- test - test
# Code coverage
- coverage - coverage
- release
- deploy
include: include:
- local: '/.gitlab/ci/_global.gitlab-ci.yml' - project: 'eclipse/aidge/gitlab_shared_files'
- local: '/.gitlab/ci/static_analysis.gitlab-ci.yml' ref: 'main'
- local: '/.gitlab/ci/build.gitlab-ci.yml' file:
- local: '/.gitlab/ci/test.gitlab-ci.yml' # choose which jobs to run by including the corresponding files.
- local: '/.gitlab/ci/coverage.gitlab-ci.yml' - '.gitlab/ci/ubuntu_cpp.gitlab-ci.yml'
- '.gitlab/ci/ubuntu_python.gitlab-ci.yml'
- '.gitlab/ci/release/cibuildwheel_ubuntu.gitlab-ci.yml'
- '.gitlab/ci/windows_cpp.gitlab-ci.yml'
- '.gitlab/ci/windows_python.gitlab-ci.yml'
- '.gitlab/ci/release/cibuildwheel_windows.gitlab-ci.yml'
# Required bc of test_export that cannot run in parallel in test and in coverage
coverage:ubuntu_python:
needs:
- build:ubuntu_python
- test:ubuntu_python
################################################################################
# Centralized definitions of common job parameter values. #
# Parameters with many optional configurations may be in separate files. #
# #
################################################################################
variables:
GIT_SUBMODULE_STRATEGY: recursive
OMP_NUM_THREADS: 4
GIT_SSL_NO_VERIFY: 1
DEBIAN_FRONTEND: noninteractive
# See https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
default:
image: nvidia/cuda:12.2.0-devel-ubuntu22.04
before_script:
- apt update
- apt install -y cmake cppcheck python-is-python3 pip git gcovr
build:ubuntu_cpp:
stage: build
needs: []
tags:
- docker
script:
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON ..
- make -j4 all install
artifacts:
expire_in: 1 week
paths:
- build_cpp/
- install_cpp/
build:ubuntu_cpp_g++10:
stage: build
needs: []
tags:
- docker
script:
- apt install -y g++-10
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- export CXX=/usr/bin/g++-10
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON ..
- make -j4 all install
build:ubuntu_cpp_g++12:
stage: build
needs: []
tags:
- docker
script:
- apt install -y g++-12
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- export CXX=/usr/bin/g++-12
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON ..
- make -j4 all install
build:ubuntu_cpp_clang12:
stage: build
needs: []
tags:
- docker
script:
- apt install -y clang-12
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- export CXX=/usr/bin/clang++-12
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON ..
- make -j4 all install
build:ubuntu_cpp_clang15:
stage: build
needs: []
tags:
- docker
script:
- apt install -y clang-15
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- export CXX=/usr/bin/clang++-15
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON ..
- make -j4 all install
build:ubuntu_python:
stage: build
needs: []
tags:
- docker
script:
- python3 -m pip install virtualenv
- virtualenv venv
- source venv/bin/activate
# Numpy dependancy for unit test
- python3 -m pip install -r requirements.txt
- python3 -m pip install .
artifacts:
expire_in: 1 week
paths:
- venv/
build:windows_cpp:
stage: build
needs: []
tags:
- windows
image: buildtools
before_script:
# Install Chocolatey
- Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install dependencies
- choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y
- choco install git -Y
- choco install python -Y
# Update PATH
- $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
script:
- mkdir -p build_cpp
- mkdir -p install_cpp
- cd build_cpp
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug ..
- cmake --build . -j2
- cmake --install . --config Debug
artifacts:
expire_in: 1 week
paths:
- build_cpp/
- install_cpp/
build:windows_python:
stage: build
needs: []
tags:
- windows
image: buildtools
before_script:
# Install Chocolatey
- Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install dependencies
- choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y
- choco install git -Y
- choco install python -Y
# Update PATH
- $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
script:
- python -m pip install virtualenv
- virtualenv venv
- venv\Scripts\Activate.ps1
# Numpy dependancy for unit test
- python -m pip install -r requirements.txt
- python -m pip install .
artifacts:
expire_in: 1 week
paths:
- venv/
$ErrorActionPreference = "Stop"
# Retrieve and clean the dependencies string from the environment variable
$AIDGE_DEPENDENCIES = $env:AIDGE_DEPENDENCIES -split ' '
Write-Host "Aidge dependencies : $AIDGE_DEPENDENCIES"
if ( $($AIDGE_DEPENDENCIES.Length) -eq 0) {
Write-Host "- No dependencies provided for current repository"
New-Item -ItemType Directory -Force -Path ".\build" | Out-Null
Remove-Item -Path ".\build\*" -Recurse -Force
} else {
Write-Host "Retrieving given dependencies to build current package : $AIDGE_DEPENDENCIES"
foreach ($dep in $($AIDGE_DEPENDENCIES -split " ")) {
Write-Host "Retrieving : $dep"
$curr_loc=$(Get-Location)
Set-Location ../$dep
Get-Location
Get-ChildItem .
New-Item -Path ".\build" -ItemType Directory -Force | Out-Null
Get-ChildItem -Path ".\build" -File | Remove-Item -Force
python -m pip install . -v
Set-Location $curr_loc
}
}
#!/bin/bash
set -e
if [[ "$1" == "" ]]; then
echo "build aidge deps in cibuildwheel container before building wheel."
echo "search path defines where the dependencies will be searched."
echo "Hint : In wheel containers, files are mounted on /host by default."
echo "\nusage : ./cibuildwheel_build_deps_before_build_wheel.sh $search_path"
fi
set -x
if [[ $AIDGE_DEPENDENCIES == "" ]]; then # case for aidge_ core
mkdir -p build # creating build if its not already there to hold the build of cpp files
rm -rf build/* # build from scratch
else
for repo in $AIDGE_DEPENDENCIES ; do # case for other projects
search_path=$1
REPO_PATH=$(find $search_path ! -writable -prune -o -type d \
-name "$repo" \
-not -path "*/install/*" \
-not -path "*/.git/*" \
-not -path "*/miniconda/*" \
-not -path "*/conda/*" \
-not -path "*/.local/*" \
-not -path "*/lib/*" \
-not -path "*/$repo/$repo/*" \
-not -path "*/proc/*" \
-print -quit)
if [[ -z "$REPO_PATH" ]]; then
echo "ERROR : dependency $repo not found in search_path \"$search_path\". ABORTING."
exit -1
fi
cd $REPO_PATH
mkdir -p build # creating build if its not already there to hold the build of cpp files
rm -rf build/* # build from scratch
pip install . -v
cd -
done
fi
set +x
set +e
coverage:ubuntu_cpp:
stage: coverage
needs: ["build:ubuntu_cpp"]
tags:
- docker
script:
- cd build_cpp
- ctest --output-on-failure
- gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml --root ${CI_PROJECT_DIR} --filter '\.\./include/' --filter '\.\./src/'
coverage: /^\s*lines:\s*\d+.\d+\%/
artifacts:
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
expire_in: 2 days
reports:
coverage_report:
coverage_format: cobertura
path: build_cpp/coverage.xml
coverage:ubuntu_python:
stage: coverage
needs: ["build:ubuntu_python"]
tags:
- docker
script:
- source venv/bin/activate
- python3 -m pip install numpy coverage
- cd ${CI_PROJECT_NAME}
# Retrieve the installation path of the module, since it is installed with pip.
- export MODULE_LOCATION=`python -c "import ${CI_PROJECT_NAME} as _; print(_.__path__[0])"`
- python3 -m coverage run --source=$MODULE_LOCATION -m unittest discover -s unit_tests/ -v -b
- python3 -m coverage report
- python3 -m coverage xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: ${CI_PROJECT_NAME}/coverage.xml
static_analysis:cpp:
stage: static_analysis
tags:
- static_analysis
allow_failure: true
script:
- mkdir -p $CI_COMMIT_REF_NAME
- cppcheck -j 4 --enable=all --inconclusive --force --xml --xml-version=2 . 2> cppcheck-result.xml
- python -m pip install Pygments
- cppcheck-htmlreport --file=cppcheck-result.xml --report-dir=$CI_COMMIT_REF_NAME --source-dir=.
- python3 -m pip install -U cppcheck_codequality
- cppcheck-codequality --input-file=cppcheck-result.xml --output-file=cppcheck.json
- mkdir -p public/cpp
- mv $CI_COMMIT_REF_NAME public/cpp/
artifacts:
paths:
- public
reports:
codequality: cppcheck.json
static_analysis:python:
stage: static_analysis
tags:
- static_analysis
allow_failure: true
script:
- pip install pylint
- pip install pylint-gitlab
- pylint --rcfile=.pylintrc --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter ${CI_PROJECT_NAME}/ > codeclimate.json
- pylint --rcfile=.pylintrc --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter ${CI_PROJECT_NAME}/ > pylint.html
- mkdir -p public/python/$CI_COMMIT_REF_NAME
- mv pylint.html public/python/$CI_COMMIT_REF_NAME/
artifacts:
paths:
- public
reports:
codequality: codeclimate.json
\ No newline at end of file
test:ubuntu_cpp:
stage: test
needs: ["build:ubuntu_cpp"]
tags:
- docker
script:
- cd build_cpp
- ctest --output-junit ctest-results.xml --output-on-failure
artifacts:
reports:
junit: build_cpp/ctest-results.xml
test:ubuntu_python:
stage: test
needs: ["build:ubuntu_python"]
tags:
- docker
script:
- source venv/bin/activate
- cd ${CI_PROJECT_NAME}
- python3 -m pip install unittest-xml-reporting
- python3 -m pip list
# Run on discovery all tests located in core/unit_tests/python
- python3 -m xmlrunner discover -s unit_tests/ -v -b --output-file xmlrunner-results.xml
artifacts:
reports:
junit: ${CI_PROJECT_NAME}/xmlrunner-results.xml
test:windows_cpp:
stage: test
needs: ["build:windows_cpp"]
tags:
- windows
image: buildtools
before_script:
# Install Chocolatey
- Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install dependencies
- choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y
- choco install python -Y
# Update PATH
- $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
script:
- cd build_cpp
- ctest --output-junit ctest-results.xml --output-on-failure
artifacts:
reports:
junit: build_cpp/ctest-results.xml
This diff is collapsed.
# Version 0.5.1 (February 13, 2025)
# Version 0.5.0 (January 31, 2025)
# Version 0.4.0 (December 2024)
# Version 0.2.1 (May 14, 2024) # Version 0.2.1 (May 14, 2024)
* rework export mechanism * rework export mechanism
* change `Operator::computeOutputDims()` with `Operator::forwardDims()` * change `Operator::computeOutputDims()` with `Operator::forwardDims()`
* automatic docstring decorators for python * automatic docstring decorators for python
* add implementation of Operators only performing data/format manipulation * add implementation of Operators only performing data/format manipulation
......
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.18)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version)
# Parse version.txt to retrieve Major, Minor and Path
string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" _ MATCHES ${version})
set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1})
set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2})
set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3})
# Retrieve latest git commit
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
file(READ "${CMAKE_SOURCE_DIR}/version.txt" version) project(aidge_core
file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project) VERSION ${version}
DESCRIPTION "Core algorithms for operators and graph of the AIDGE framework"
LANGUAGES CXX)
message(STATUS "Project name: ${project}") message(STATUS "Project name: ${CMAKE_PROJECT_NAME}")
message(STATUS "Project version: ${version}") message(STATUS "Project version: ${version}")
message(STATUS "Latest git commit: ${GIT_COMMIT_HASH}")
# helper for LSP users
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Note : project name is {project} and python module name is also {project} # Note : project name is {project} and python module name is also {project}
set(module_name _${project}) # target name set(module_name _${CMAKE_PROJECT_NAME}) # target name
set(pybind_module_name ${CMAKE_PROJECT_NAME}) # name of submodule for python bindings
project(${project})
set(CXX_STANDARD 14)
############################################## ##############################################
# Define options # Define options
option(PYBIND "python binding" ON) option(PYBIND "python binding" OFF)
option(WERROR "Warning as error" OFF) option(WERROR "Warning as error" OFF)
option(TEST "Enable tests" ON) option(TEST "Enable tests" ON)
option(COVERAGE "Enable coverage" OFF) option(COVERAGE "Enable coverage" OFF)
...@@ -24,7 +47,6 @@ option(ENABLE_ASAN "Enable ASan (AddressSanitizer) for runtime analysis of memor ...@@ -24,7 +47,6 @@ option(ENABLE_ASAN "Enable ASan (AddressSanitizer) for runtime analysis of memor
############################################## ##############################################
# Import utils CMakeLists # Import utils CMakeLists
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(PybindModuleCreation)
if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE) if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE)
Include(CodeCoverage) Include(CodeCoverage)
...@@ -32,20 +54,28 @@ endif() ...@@ -32,20 +54,28 @@ endif()
############################################## ##############################################
# Find system dependencies # Find system dependencies
Include(FetchContent) set(FMT_MIN_VERSION 10.2.1)
FetchContent_Declare( find_package(fmt ${FMT_MIN_VERSION} QUIET)
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 10.2.1 # or a later release
)
set(FMT_SYSTEM_HEADERS ON) if(NOT fmt_FOUND)
FetchContent_MakeAvailable(fmt) message(STATUS "fmt not found in system, retrieving from git")
set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON) Include(FetchContent)
find_package(Threads REQUIRED) FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG master #latest
)
set(FMT_SYSTEM_HEADERS ON)
FetchContent_MakeAvailable(fmt)
set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON)
else()
message(STATUS "Found system fmt version ${fmt_VERSION}")
endif()
find_package(Threads REQUIRED)
############################################## ##############################################
# Create target and set properties # Create target and set properties
...@@ -78,19 +108,33 @@ if( ${ENABLE_ASAN} ) ...@@ -78,19 +108,33 @@ if( ${ENABLE_ASAN} )
endif() endif()
# PYTHON BINDING # PYTHON BINDING
set(AIDGE_REQUIRES_PYTHON FALSE) # Will be set if aidge_core lib depends upon python interpreter
set(AIDGE_PYTHON_HAS_EMBED FALSE) # Will be set if python interpreter is found on the system
if (PYBIND) if (PYBIND)
generate_python_binding(${project} ${module_name}) # Python binding lib is by default installed in <prefix>/python_packages/<package>/
# When installed from python, setup.py should set it to the python package dir
set(PYBIND_INSTALL_PREFIX python_packages/${pybind_module_name} CACHE PATH "Python package install prefix")
# Handles Python + pybind11 headers dependencies include(PybindModuleCreation)
target_link_libraries(${module_name} generate_python_binding(${pybind_module_name} ${module_name})
PUBLIC
pybind11::pybind11 ##
PRIVATE # As of now, when PYBIND is set, the core archive itself depends upon pybind/python,
Python::Python # we define -DPYBIND and the dependencies on pybind/python runtime where necessary.
)
# Add -DPYBIND to compilation and interface
target_compile_definitions(${module_name} PUBLIC PYBIND)
# Add dependencies on pybind/python. See details in add_pybind_dependency()
include(PybindDependency)
add_pybind_dependency(${module_name})
##
target_link_libraries(${pybind_module_name} PUBLIC fmt::fmt)
endif() endif()
target_link_libraries(${module_name} PUBLIC Threads::Threads fmt::fmt) target_link_libraries(${module_name} PUBLIC fmt::fmt)
target_link_libraries(${module_name} PUBLIC Threads::Threads)
target_compile_features(${module_name} PRIVATE cxx_std_14) target_compile_features(${module_name} PRIVATE cxx_std_14)
if (DOSANITIZE STREQUAL "ON") if (DOSANITIZE STREQUAL "ON")
...@@ -133,11 +177,22 @@ endif() ...@@ -133,11 +177,22 @@ endif()
############################################## ##############################################
# Installation instructions # Installation instructions
if(NOT $ENV{AIDGE_INSTALL} STREQUAL "")
set(CMAKE_INSTALL_PREFIX $ENV{AIDGE_INSTALL})
message(WARNING "CMAKE_INSTALL_PREFIX set to env variable AIDGE_INSTALL by default (${CMAKE_INSTALL_PREFIX})")
endif()
message(STATUS "Creating ${CMAKE_CURRENT_SOURCE_DIR}/include/aidge/core_version.h")
# Generate version.h file from config file version.h.in
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/include/aidge/version.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/include/aidge/core_version.h"
)
include(GNUInstallDirs) include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${project}) set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
install(TARGETS ${module_name} EXPORT ${project}-targets install(TARGETS ${module_name} EXPORT ${CMAKE_PROJECT_NAME}-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
...@@ -146,10 +201,16 @@ install(TARGETS ${module_name} EXPORT ${project}-targets ...@@ -146,10 +201,16 @@ install(TARGETS ${module_name} EXPORT ${project}-targets
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (PYBIND)
install(TARGETS ${pybind_module_name}
DESTINATION ${PYBIND_INSTALL_PREFIX}
)
endif()
#Export the targets to a script #Export the targets to a script
install(EXPORT ${project}-targets install(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE "${project}-targets.cmake" FILE "${CMAKE_PROJECT_NAME}-targets.cmake"
DESTINATION ${INSTALL_CONFIGDIR} DESTINATION ${INSTALL_CONFIGDIR}
# COMPONENT ${module_name} # COMPONENT ${module_name}
) )
...@@ -158,32 +219,37 @@ install(EXPORT ${project}-targets ...@@ -158,32 +219,37 @@ install(EXPORT ${project}-targets
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file( write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config-version.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake"
VERSION ${version} VERSION ${version}
COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
) )
configure_package_config_file("${project}-config.cmake.in" configure_package_config_file("${CMAKE_PROJECT_NAME}-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION ${INSTALL_CONFIGDIR} INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
) )
#Install the config, configversion and custom find modules #Install the config, configversion and custom find modules
install(FILES install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config-version.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake"
DESTINATION ${INSTALL_CONFIGDIR} DESTINATION ${INSTALL_CONFIGDIR}
) )
############################################## ##############################################
## Exporting from the build tree ## Exporting from the build tree
export(EXPORT ${project}-targets message(STATUS "Exporting created targets to use them in another build")
FILE "${CMAKE_CURRENT_BINARY_DIR}/${project}-targets.cmake") export(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-targets.cmake")
############################################## ##############################################
## Add test ## Add test
if(TEST) if(TEST)
enable_testing() if (AIDGE_REQUIRES_PYTHON AND NOT AIDGE_PYTHON_HAS_EMBED)
add_subdirectory(unit_tests) message(WARNING "Skipping compilation of tests: missing Python embedded interpreter")
else()
enable_testing()
add_subdirectory(unit_tests)
endif()
endif() endif()
include MANIFEST.in include README.md LICENSE
include LICENSE recursive-include aidge_core *.py
include README.md recursive-exclude aidge_core/unit_tests *.py
recursive-include aidge_core *
include setup.py recursive-include aidge_core/aidge_export_aidge *
include version.txt recursive-include aidge_core/export_utils/templates *
recursive-include include *.hpp
recursive-include src *.cpp
recursive-include python_binding *.cpp
include CMakeLists.txt
...@@ -4,21 +4,66 @@ ...@@ -4,21 +4,66 @@
You can find here the C++ code of the Core library of Aidge. You can find here the C++ code of the Core library of Aidge.
[TOC]
## Pip installation ## Pip installation
To install aidge_core using pip, run the following command in your python environment :
``` bash
pip install . -v
```
> **TIPS :** Use environment variables to change compilation options:
> - `AIDGE_INSTALL` : to set the installation folder. Defaults to `<python_prefix>/lib/libAidge`
> - `AIDGE_PYTHON_BUILD_TYPE` : to set the compilation mode to **Debug** or **Release** or "" (for default flags). Defaults to **Release**.
> - `AIDGE_BUILD_GEN` : to set the build backend (for development mode) or "" for the cmake default. Default to "".
> - `AIDGE_BUILD_TEST` : to build the C++ unit tests. Set to "ON" or "OFF". Default to "OFF".
## Pip installation for development
To install aidge_core using pip, run the following command in your python environnement : To setup aidge_core using pip in development (or editable mode), use the `--no-build-isolation -e` options to pip.
For instance run the following command in your python environment for a typical setup :
``` bash ``` bash
pip install . -v export AIDGE_BUILD_TEST=ON # enable C++ unit tests
export AIDGE_PYTHON_BUILD_TYPE= # default flags (no debug info but fastest build time)
export AIDGE_PYTHON_BUILD_TYPE=Debug # or if one really need to debug the C++ code
pip install -U pip setuptools setuptools_scm[toml] cmake # Pre-install build requirements (refer to the pyproject.toml [build-system] section)
pip install -v --no-build-isolation -e .
``` ```
**Note:** you can specify a custom install folder by setting an environment variable: In this configuration python files can be modified directly without re-installation.
The C++ build dir will be created in `build/` and recompilation and install of python bindings can be done directly with:
```bash
make -C build install -j $(nproc)
# or with cmake
cmake --build build -j $(nproc) && cmake --install build
```
One can also use an alternate cmake build backend such as ninja which can be installed easily though pip, for instance :
``` bash ``` bash
export AIDGE_INSTALL='<path_to_aidge>/install' pip install -U ninja
export AIDGE_BUILD_GEN=Ninja
pip install -v --no-build-isolation -e .
``` ```
In this case ninja is used instead of make as build backend, and recompilation when needed is done with:
```bash
ninja -C build install # note that by default ninja use available parallelism, no need for -j option
# or with cmake
cmake --build build && cmake --install build
```
Note that python development (or editable mode) is not always robust to changes in the python package setup,
or when changing the build backend with `AIDGE_BUILD_GEN`.
In order to re-install when the build breaks, re-execute the commands:
```bash
rm -rf *-egg-info build/
pip install -v --no-build-isolation -e .
```
## Standard C++ Compilation ## Standard C++ Compilation
Create two directories ``build`` and ``ìnstall``. Create two directories ``build`` and ``ìnstall``.
...@@ -40,22 +85,22 @@ make all install ...@@ -40,22 +85,22 @@ make all install
| Option | Value type | Description | | Option | Value type | Description |
|:----------:|:----------:|:-----------:| |:----------:|:----------:|:-----------:|
| *-DCMAKE_INSTALL_PREFIX:PATH* | ``str`` | Path to the install folder | | *-DCMAKE_INSTALL_PREFIX:PATH* | ``str`` | Path to the install folder |
| *-DCMAKE_BUILD_TYPE* | ``str`` | If ``Debug``, compile in debug mode, ``Release`` compile with highest optimisations, default= ``Release`` | | *-DCMAKE_BUILD_TYPE* | ``str`` | If ``Debug``, compile in debug mode, ``Release`` compile with highest optimizations or "" (empty) , default= ``Release`` |
| *-DWERROR* | ``bool`` | If ``ON`` show warning as error during compilation phase, default=``OFF`` | | *-DWERROR* | ``bool`` | If ``ON`` show warning as error during compilation phase, default=``OFF`` |
| *-DPYBIND* | ``bool`` | If ``ON`` activate python binding, default=``ON`` | | *-DTEST* | ``bool`` | If ``ON`` build C++ unit tests, default=``ON`` |
| *-DPYBIND* | ``bool`` | If ``ON`` activate python binding, default=``OFF`` |
| *-DPYBIND_INSTALL_PREFIX:PATH*| ``str`` | Path to the python module install folder when ``-DPYBIND=ON``, defaults to ``$CMAKE_INSTALL_PREFIX/python_packages/<module>`` |
If you have compiled with PyBind you can find at the root of the ``build`` file the python lib ``aidge_core.cpython*.so`` If one compiles with ``-DPYBIND=ON``, ``-DPYBIND_INSTALL_PREFIX:PATH`` can be used to install the python module directly in the
python sources tree (for instance ``$PWD/aidge_core``). ``setup.py`` takes care of this and installs the module at the right place.
## Run tests ## Run tests
### CPP ### CPP
Inside of the build file run: Inside of the build file run:
```bash ```bash
ctest --output-on-failure ctest --output-on-failure
``` ```
### Python ### Python
......
@PACKAGE_INIT@ @PACKAGE_INIT@
include(CMakeFindDependencyMacro) include(CMakeFindDependencyMacro)
find_dependency(fmt) find_dependency(fmt @FMT_VERSION@)
find_dependency(Threads) find_dependency(Threads)
set(AIDGE_REQUIRES_PYTHON @AIDGE_REQUIRES_PYTHON@)
set(AIDGE_PYTHON_HAS_EMBED @AIDGE_PYTHON_HAS_EMBED@)
if (AIDGE_REQUIRES_PYTHON AND AIDGE_PYTHON_HAS_EMBED)
find_dependency(Python COMPONENTS Interpreter Development)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/aidge_core-config-version.cmake) include(${CMAKE_CURRENT_LIST_DIR}/aidge_core-config-version.cmake)
......
...@@ -8,6 +8,8 @@ http://www.eclipse.org/legal/epl-2.0. ...@@ -8,6 +8,8 @@ http://www.eclipse.org/legal/epl-2.0.
SPDX-License-Identifier: EPL-2.0 SPDX-License-Identifier: EPL-2.0
""" """
from aidge_core.aidge_core import * # import so generated by PyBind from aidge_core.aidge_core import * # import so generated by PyBind
from aidge_core.export_utils import ExportNode, generate_file, generate_str import aidge_core.export_utils
import aidge_core.utils import aidge_core.utils
from aidge_core.aidge_export_aidge import * from aidge_core.aidge_export_aidge import serialize_to_cpp
from aidge_core.show_graphview import gview_to_json
from aidge_core.mem_info import *
...@@ -5,4 +5,4 @@ FILE = Path(__file__).resolve() ...@@ -5,4 +5,4 @@ FILE = Path(__file__).resolve()
ROOT_EXPORT = FILE.parents[0] ROOT_EXPORT = FILE.parents[0]
from .operator_export import * from .operator_export import *
from .export import export from .export import serialize_to_cpp
...@@ -2,15 +2,14 @@ import aidge_core ...@@ -2,15 +2,14 @@ import aidge_core
import shutil import shutil
import os import os
from pathlib import Path from pathlib import Path
from .utils import supported_operators, OPERATORS_REGISTRY
from . import ROOT_EXPORT
from aidge_core import ExportNode, generate_file
import aidge_core.export_utils
from . import ROOT_EXPORT
from aidge_core.aidge_export_aidge.registry import ExportSerialize
from aidge_core.export_utils import generate_file
def export(export_folder: str, def serialize_to_cpp(export_folder: str,
graph_view: aidge_core.GraphView, graph_view: aidge_core.GraphView,
enable_python_binding: bool = True, enable_python_binding: bool = True,
): ):
...@@ -54,12 +53,11 @@ def export(export_folder: str, ...@@ -54,12 +53,11 @@ def export(export_folder: str,
### Generating an export for each nodes and dnn file ### ### Generating an export for each nodes and dnn file ###
list_configs = [] # List of headers to include in dnn.cpp to access attribute and parameters list_configs = [] # List of headers to include in dnn.cpp to access attribute and parameters
list_actions = [] # List of string to construct graph list_actions = [] # List of string to construct graph
set_operator = set() list_operators = [] # List of operator types used (to be made unique latter)
# Queue of Aidge nodes to explore, guarantee a topological exploration of the graph # Queue of Aidge nodes to explore, guarantee a topological exploration of the graph
open_nodes = list(graph_view.get_input_nodes()) open_nodes = list(graph_view.get_input_nodes())
# List of Aidge nodes already explored # List of Aidge nodes already explored
closed_nodes = [] closed_nodes = []
while open_nodes: while open_nodes:
node = open_nodes.pop(0) node = open_nodes.pop(0)
if node in closed_nodes: if node in closed_nodes:
...@@ -80,25 +78,37 @@ def export(export_folder: str, ...@@ -80,25 +78,37 @@ def export(export_folder: str,
continue continue
# Next nodes to treat are children of current node # Next nodes to treat are children of current node
open_nodes += list(node.get_children()) open_nodes += list(node.get_children())
node.get_operator().set_backend(ExportSerialize._name)
op_impl = node.get_operator().get_impl()
if op_impl is None:
raise RuntimeError(f"Operator {node.name()}[{node.type()}] doesn't have an implementation.")
if not isinstance(op_impl, ExportSerialize):
raise RuntimeError(f"Operator {node.name()}[{node.type()}] doesn't have an exportable backend ({op_impl}).")
required_specs = op_impl.get_required_spec()
specs = op_impl.get_best_match(required_specs)
export_node = op_impl.get_export_node(specs)
if export_node is None:
raise RuntimeError(f"Could not find export node for {node.name()}[{node.type()}].")
op = export_node(
node, None)
if node.type() in supported_operators(): # set_operator.add(node.type())
set_operator.add(node.type())
op = OPERATORS_REGISTRY[node.type()](node)
# TODO: list_configs and list_actions don't need to be passed by argument # TODO: list_configs and list_actions don't need to be passed by argument
# Export the configuration # Export the configuration
list_configs = op.export(export_folder_path, list_configs) list_configs += op.export(export_folder_path)
# Add forward kernel # Add forward kernel
list_actions = op.forward(list_actions) list_actions += op.forward()
else:
raise RuntimeError(f"Operator: {node.type()} is not supported")
closed_nodes.append(node) closed_nodes.append(node)
list_operators = list(dict.fromkeys(list_operators)) # make unique
# Generate full dnn.cpp # Generate full dnn.cpp
aidge_core.generate_file( aidge_core.export_utils.generate_file(
export_folder_path / "src/dnn.cpp", export_folder_path / "src/dnn.cpp",
ROOT_EXPORT / "templates/dnn.jinja", ROOT_EXPORT / "templates/dnn.jinja",
headers=list_configs, headers=list_configs,
operators=set_operator, operators=list_operators,
actions=list_actions, actions=list_actions,
) )