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
  • silvanosky/aidge_core
  • maab05/aidge_core
  • mick94/aidge_core
  • lucaslopez/aidge_core_ll
  • wboussella/aidge_core
  • farnez/aidge_core
  • mnewson/aidge_core
17 results
Show changes
Commits on Source (1792)
Showing
with 646 additions and 1000 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
build*/
install*/
cppcheck-result.xml
include/aidge/core_version.h
# VSCode
.vscode
# Python
## Python
# build/packaging artifacts
*.so
__pycache__
*.pyc
*.egg-info
dist*/
*.egg-info
wheelhouse/*
aidge_core/_version.py
# test artifact
aidge_core/dummy_export/*
*xmlrunner-results.xml
# Mermaid
*.mmd
......@@ -19,4 +30,4 @@ dist*/
xml*/
# ONNX
*.onnx
\ No newline at end of file
*.onnx
###############################################################################
# Aidge Continious Integration and Continious Deployment #
# Aidge Continuous Integration and Deployment #
# #
###############################################################################
stages:
# Analyse code
- static_analysis
# Build Aidge
- build
# Unit test stage
- test
# Code coverage
- coverage
- release
- deploy
include:
- local: '/.gitlab/ci/_global.gitlab-ci.yml'
- local: '/.gitlab/ci/static_analysis.gitlab-ci.yml'
- local: '/.gitlab/ci/build.gitlab-ci.yml'
- local: '/.gitlab/ci/test.gitlab-ci.yml'
- local: '/.gitlab/ci/coverage.gitlab-ci.yml'
- project: 'eclipse/aidge/gitlab_shared_files'
ref: 'main'
file:
# choose which jobs to run by including the corresponding files.
- '.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
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-allow-list= aidge_core, torch, tensorflow
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code. (This is an alternative name to extension-pkg-allow-list
# for backward compatibility.)
extension-pkg-whitelist=
# Return non-zero exit code if any of these messages/categories are detected,
# even if score is above --fail-under value. Syntax same as enable. Messages
# specified are enabled, while categories only check already-enabled messages.
fail-on=
# Specify a score threshold to be exceeded before program exits with error.
fail-under=0.0
# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS
# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths.
ignore-paths=
# Files or directories matching the regex patterns are skipped. The regex
# matches against base names, not paths.
ignore-patterns=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
jobs=1
# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
# complex, nested conditions.
limit-inference-results=100
# List of plugins (as comma separated values of python module names) to load,
# usually to register additional checkers.
load-plugins=
# Pickle collected data for later comparisons.
persistent=yes
# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
confidence=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once). You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=print-statement,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
comprehension-escape,
c-extension-no-member,
too-many-locals,
missing-class-docstring,
missing-function-docstring,
too-many-ancestor,
too-many-arguments,
protected-access,
too-many-branches,
too-many-ancestors,
wrong-import-order,
wrong-import-position,
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=c-extension-no-member
[REPORTS]
# Python expression which should return a score less than or equal to 10. You
# have access to the variables 'error', 'warning', 'refactor', and 'convention'
# which contain the number of messages in each category, as well as 'statement'
# which is the total number of statements analyzed. This score is used by the
# global evaluation report (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details.
#msg-template=
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
output-format=text
# Tells whether to display a full report or only the messages.
reports=no
# Activate the evaluation score.
score=yes
[REFACTORING]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
# Complete name of functions that never returns. When checking for
# inconsistent-return-statements if a never returning function is called then
# it will be considered as an explicit return statement and no message will be
# printed.
never-returning-functions=sys.exit,argparse.parse_error
[BASIC]
# Naming style matching correct argument names.
argument-naming-style=snake_case
# Regular expression matching correct argument names. Overrides argument-
# naming-style.
#argument-rgx=
# Naming style matching correct attribute names.
attr-naming-style=snake_case
# Regular expression matching correct attribute names. Overrides attr-naming-
# style.
#attr-rgx=
# Bad variable names which should always be refused, separated by a comma.
bad-names=foo,
bar,
baz,
toto,
tutu,
tata
# Bad variable names regexes, separated by a comma. If names match any regex,
# they will always be refused
bad-names-rgxs=
# Naming style matching correct class attribute names.
class-attribute-naming-style=any
# Regular expression matching correct class attribute names. Overrides class-
# attribute-naming-style.
#class-attribute-rgx=
# Naming style matching correct class constant names.
class-const-naming-style=UPPER_CASE
# Regular expression matching correct class constant names. Overrides class-
# const-naming-style.
#class-const-rgx=
# Naming style matching correct class names.
class-naming-style=PascalCase
# Regular expression matching correct class names. Overrides class-naming-
# style.
#class-rgx=
# Naming style matching correct constant names.
const-naming-style=UPPER_CASE
# Regular expression matching correct constant names. Overrides const-naming-
# style.
#const-rgx=
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
# Naming style matching correct function names.
function-naming-style=snake_case
# Regular expression matching correct function names. Overrides function-
# naming-style.
#function-rgx=
# Good variable names which should always be accepted, separated by a comma.
good-names=i,
j,
k,
ex,
Run,
_,
# Good variable names regexes, separated by a comma. If names match any regex,
# they will always be accepted
good-names-rgxs=
# Include a hint for the correct naming format with invalid-name.
include-naming-hint=no
# Naming style matching correct inline iteration names.
inlinevar-naming-style=any
# Regular expression matching correct inline iteration names. Overrides
# inlinevar-naming-style.
#inlinevar-rgx=
# Naming style matching correct method names.
method-naming-style=snake_case
# Regular expression matching correct method names. Overrides method-naming-
# style.
#method-rgx=
# Naming style matching correct module names.
module-naming-style=snake_case
# Regular expression matching correct module names. Overrides module-naming-
# style.
#module-rgx=
# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
# These decorators are taken in consideration only for invalid-name.
property-classes=abc.abstractproperty
# Naming style matching correct variable names.
variable-naming-style=snake_case
# Regular expression matching correct variable names. Overrides variable-
# naming-style.
#variable-rgx=
[FORMAT]
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=200
# Maximum number of lines in a module.
max-module-lines=1000
# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no
[LOGGING]
# The type of string formatting that logging methods do. `old` means using %
# formatting, `new` is for `{}` formatting.
logging-format-style=old
# Logging modules to check that the string format arguments are in logging
# function parameter format.
logging-modules=logging
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
XXX,
TODO
# Regular expression of note tags to take in consideration.
#notes-rgx=
[SIMILARITIES]
# Comments are removed from the similarity computation
ignore-comments=yes
# Docstrings are removed from the similarity computation
ignore-docstrings=yes
# Imports are removed from the similarity computation
ignore-imports=no
# Signatures are removed from the similarity computation
ignore-signatures=no
# Minimum lines number of a similarity.
min-similarity-lines=4
[SPELLING]
# Limits count of emitted suggestions for spelling mistakes.
max-spelling-suggestions=4
# Spelling dictionary name. Available dictionaries: none. To make it work,
# install the 'python-enchant' package.
spelling-dict=
# List of comma separated words that should be considered directives if they
# appear and the beginning of a comment and should not be checked.
spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains the private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to the private dictionary (see the
# --spelling-private-dict-file option) instead of raising a message.
spelling-store-unknown-words=no
[STRING]
# This flag controls whether inconsistent-quotes generates a warning when the
# character used as a quote delimiter is used inconsistently within a module.
check-quote-consistency=no
# This flag controls whether the implicit-str-concat should generate a warning
# on implicit string concatenation in sequences defined over several lines.
check-str-concat-over-line-jumps=no
[TYPECHECK]
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# Tells whether to warn about missing members when the owner of the attribute
# is inferred to be None.
ignore-none=yes
# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,
thread._local,
_thread._local,
aidge.global_variables,
aidge.cells.abstract_cell.Trainable,
torch,
tensorflow,
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules= aidge_core
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes
# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1
# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1
# List of decorators that change the signature of a decorated function.
signature-mutators=
[VARIABLES]
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid defining new builtins when possible.
additional-builtins=
# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes
# List of names allowed to shadow builtins
allowed-redefined-builtins=
# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,
_cb
# A regular expression matching the name of dummy variables (i.e. expected to
# not be used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
# Argument names that match this expression will be ignored. Default to name
# with leading underscore.
ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no
# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
[CLASSES]
# Warn about protected attribute access inside special methods
check-protected-access-in-special-methods=no
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,
__new__,
setUp,
__post_init__
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,
_fields,
_replace,
_source,
_make
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=cls
[DESIGN]
# List of qualified class names to ignore when countint class parents (see
# R0901)
ignored-parents=
# Maximum number of arguments for function / method.
max-args=5
# Maximum number of attributes for a class (see R0902).
max-attributes=7
# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5
# Maximum number of branch for function / method body.
max-branches=12
# Maximum number of locals for function / method body.
max-locals=15
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of return / yield for function / method body.
max-returns=6
# Maximum number of statements in function / method body.
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
[IMPORTS]
# List of modules that can be imported at any level, not just the top level
# one.
allow-any-import-level=
# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=no
# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no
# Deprecated modules which should not be used, separated by a comma.
deprecated-modules=
# Output a graph (.gv or any supported image format) of external dependencies
# to the given file (report RP0402 must not be disabled).
ext-import-graph=
# Output a graph (.gv or any supported image format) of all (i.e. internal and
# external) dependencies to the given file (report RP0402 must not be
# disabled).
import-graph=
# Output a graph (.gv or any supported image format) of internal dependencies
# to the given file (report RP0402 must not be disabled).
int-import-graph=
# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
# Couples of modules and preferred modules, separated by a comma.
preferred-modules=
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception
\ No newline at end of file
# 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)
* rework export mechanism
* change `Operator::computeOutputDims()` with `Operator::forwardDims()`
* automatic docstring decorators for python
* add implementation of Operators only performing data/format manipulation
* add many assertions
* bind Database and Scaling_Op
# Version 0.2.0 (April 11, 2024)
# Version 0.1.1 (January 29, 2024)
[Add] Support of a negative value for Reshape Operator shape attribute.
......
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)
file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project)
project(aidge_core
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 "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}
set(module_name _${project}) # target name
project(${project})
set(module_name _${CMAKE_PROJECT_NAME}) # target name
set(pybind_module_name ${CMAKE_PROJECT_NAME}) # name of submodule for python bindings
##############################################
# Define options
option(PYBIND "python binding" ON)
option(PYBIND "python binding" OFF)
option(WERROR "Warning as error" OFF)
option(TEST "Enable tests" ON)
option(COVERAGE "Enable coverage" OFF)
option(ENABLE_ASAN "Enable ASan (AddressSanitizer) for runtime analysis of memory use (over/underflow, memory leak, ...)" OFF)
##############################################
# Import utils CMakeLists
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(PybindModuleCreation)
if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE)
Include(CodeCoverage)
......@@ -30,9 +54,28 @@ endif()
##############################################
# Find system dependencies
set(FMT_MIN_VERSION 10.2.1)
find_package(fmt ${FMT_MIN_VERSION} QUIET)
if(NOT fmt_FOUND)
message(STATUS "fmt not found in system, retrieving from git")
Include(FetchContent)
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
......@@ -51,19 +94,47 @@ target_include_directories(${module_name}
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# PYTHON BINDING
if (PYBIND)
generate_python_binding(${project} ${module_name})
# Handles Python + pybind11 headers dependencies
if( ${ENABLE_ASAN} )
message("Building ${module_name} with ASAN.")
set(SANITIZE_FLAGS -fsanitize=address -fno-omit-frame-pointer)
target_link_libraries(${module_name}
PUBLIC
pybind11::pybind11
-fsanitize=address
)
target_compile_options(${module_name}
PRIVATE
Python::Python
)
${SANITIZE_FLAGS}
)
endif()
# 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)
# 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")
include(PybindModuleCreation)
generate_python_binding(${pybind_module_name} ${module_name})
##
# As of now, when PYBIND is set, the core archive itself depends upon pybind/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()
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)
if (DOSANITIZE STREQUAL "ON")
......@@ -106,11 +177,22 @@ endif()
##############################################
# 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)
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}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
......@@ -119,10 +201,16 @@ install(TARGETS ${module_name} EXPORT ${project}-targets
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
install(EXPORT ${project}-targets
FILE "${project}-targets.cmake"
install(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE "${CMAKE_PROJECT_NAME}-targets.cmake"
DESTINATION ${INSTALL_CONFIGDIR}
# COMPONENT ${module_name}
)
......@@ -131,32 +219,37 @@ install(EXPORT ${project}-targets
include(CMakePackageConfigHelpers)
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}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file("${project}-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake"
configure_package_config_file("${CMAKE_PROJECT_NAME}-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
#Install the config, configversion and custom find modules
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${project}-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config-version.cmake"
DESTINATION ${INSTALL_CONFIGDIR}
)
##############################################
## Exporting from the build tree
export(EXPORT ${project}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${project}-targets.cmake")
message(STATUS "Exporting created targets to use them in another build")
export(EXPORT ${CMAKE_PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-targets.cmake")
##############################################
## Add test
if(TEST)
enable_testing()
add_subdirectory(unit_tests)
if (AIDGE_REQUIRES_PYTHON AND NOT AIDGE_PYTHON_HAS_EMBED)
message(WARNING "Skipping compilation of tests: missing Python embedded interpreter")
else()
enable_testing()
add_subdirectory(unit_tests)
endif()
endif()
include README.md LICENSE
recursive-include aidge_core *.py
recursive-exclude aidge_core/unit_tests *.py
recursive-include aidge_core/aidge_export_aidge *
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 @@
You can find here the C++ code of the Core library of Aidge.
[TOC]
## 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
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
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
Create two directories ``build`` and ``ìnstall``.
......@@ -40,22 +85,22 @@ make all install
| Option | Value type | Description |
|:----------:|:----------:|:-----------:|
| *-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`` |
| *-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
### CPP
Inside of the build file run:
```bash
ctest --output-on-failure
```
### Python
......
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(fmt @FMT_VERSION@)
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-targets.cmake)
......@@ -8,4 +8,8 @@ http://www.eclipse.org/legal/epl-2.0.
SPDX-License-Identifier: EPL-2.0
"""
from aidge_core.aidge_core import * # import so generated by PyBind
from aidge_core.export import ExportNode
import aidge_core.export_utils
import aidge_core.utils
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 *
from pathlib import Path
# Constants
FILE = Path(__file__).resolve()
ROOT_EXPORT = FILE.parents[0]
from .operator_export import *
from .export import serialize_to_cpp
import aidge_core
import shutil
import os
from pathlib import Path
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 serialize_to_cpp(export_folder: str,
graph_view: aidge_core.GraphView,
enable_python_binding: bool = True,
):
export_folder_path = Path(export_folder)
export_name = export_folder_path.name
### Creating export folder ###
# Create export directory
os.makedirs(export_folder, exist_ok=True)
### Cpy static files ###
shutil.copytree(ROOT_EXPORT / "static/include",
export_folder_path / "include", dirs_exist_ok=True)
shutil.copytree(ROOT_EXPORT / "static/cmake",
export_folder_path / "cmake", dirs_exist_ok=True)
shutil.copyfile(ROOT_EXPORT / "static/CMakeLists.txt",
export_folder_path / "CMakeLists.txt")
shutil.copyfile(ROOT_EXPORT / "static/version.txt",
export_folder_path / "version.txt")
shutil.copyfile(ROOT_EXPORT / "static/README.md",
export_folder_path / "README.md")
shutil.copyfile(ROOT_EXPORT / "static/main.cpp",
export_folder_path / "main.cpp")
shutil.copyfile(ROOT_EXPORT / "static/export-config.cmake.in",
export_folder_path / f"{export_name}-config.cmake.in")
# Create project_name file
with open(export_folder_path / "project_name.txt", "w") as f:
f.write(export_name)
# Add files related to python binding if
if enable_python_binding:
os.makedirs(export_folder_path / "python_binding", exist_ok=True)
generate_file(
export_folder_path / "python_binding/pybind.cpp",
ROOT_EXPORT / "templates/pybind.jinja",
name=export_name,
)
# TODO: Add a main.py 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_actions = [] # List of string to construct graph
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
open_nodes = list(graph_view.get_input_nodes())
# List of Aidge nodes already explored
closed_nodes = []
while open_nodes:
node = open_nodes.pop(0)
if node in closed_nodes:
continue # Node already converted, moving on ...
parents_not_converted = False
# Check all parents have been converted
for parent in node.get_parents():
if parent is not None and \
parent not in closed_nodes:
# If parents have not been converted, push back current node
if not parents_not_converted:
open_nodes.insert(0, node)
parents_not_converted = True
# Add to the stack the not converted parent as next node to convert
open_nodes.insert(0, parent)
if parents_not_converted:
continue
# Next nodes to treat are children of current node
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)
# set_operator.add(node.type())
# TODO: list_configs and list_actions don't need to be passed by argument
# Export the configuration
list_configs += op.export(export_folder_path)
# Add forward kernel
list_actions += op.forward()
closed_nodes.append(node)
list_operators = list(dict.fromkeys(list_operators)) # make unique
# Generate full dnn.cpp
aidge_core.export_utils.generate_file(
export_folder_path / "src/dnn.cpp",
ROOT_EXPORT / "templates/dnn.jinja",
headers=list_configs,
operators=list_operators,
actions=list_actions,
)