Skip to content
Snippets Groups Projects
Commit f2ea4dc9 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Add GitLabCI to aidge_core module.

parents f6f1c60c 1dc695f6
No related branches found
No related tags found
No related merge requests found
###############################################################################
# Aidge Continious Integration and Continious Deployment #
# #
###############################################################################
stages:
# Analyse code
- static_analysis
# Build Aidge
- build
# Unit test stage
- test
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'
################################################################################
# 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
image: n2d2-ci/ubuntu20.04/cpu:latest
\ No newline at end of file
build:ubuntu_cpp:
stage: build
tags:
- docker
image: n2d2-ci/ubuntu20.04/cpu:latest
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 ..
- make -j4 all install
artifacts:
paths:
- build_cpp/
- install_cpp/
build:ubuntu_python:
stage: build
tags:
- docker
image: n2d2-ci/ubuntu20.04/cpu:latest
script:
- python3 -m pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- export AIDGE_INSTALL=`pwd`/install
- python3 -m pip install .
artifacts:
paths:
- venv/
\ No newline at end of file
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 aidge_core/ > codeclimate.json
- pylint --rcfile=.pylintrc --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter aidge_core/ > 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
image: n2d2-ci/ubuntu20.04/cpu:latest
script:
- cd build_cpp
- ctest --output-on-failure
test:ubuntu_python:
stage: test
needs: ["build:ubuntu_python"]
tags:
- docker
image: n2d2-ci/ubuntu20.04/cpu:latest
script:
- source venv/bin/activate
- cd aidge_core
- python3 -m pip list
# Run on discovery all tests located in core/unit_tests/python and discard the stdout
# only to show the errors/warnings and the results of the tests
- python3 -m unittest discover -s unit_tests/ -v -b 1> /dev/null
.pylintrc 0 → 100644
This diff is collapsed.
from aidge_core.aidge_core import * # import so generated by PyBind
\ No newline at end of file
"""
Copyright (c) 2023 CEA-List
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
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
"""
Copyright (c) 2023 CEA-List
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
SPDX-License-Identifier: EPL-2.0
"""
import unittest
import aidge_core
class test_operator_binding(unittest.TestCase):
"""Very basic test to make sure the python APi is not broken.
Can be remove in later stage of the developpement.
"""
def setUp(self):
self.generic_operator = aidge_core.GenericOperator("FakeConv", 1, 1, 1).get_operator()
def tearDown(self):
pass
def test_default_name(self):
op_type = "Conv"
gop = aidge_core.GenericOperator(op_type, 1, 1, 1, "FictiveName")
# check node name is not operator type
self.assertNotEqual(gop.name(), "Conv")
# check node name is not default
self.assertNotEqual(gop.name(), "")
def test_param_bool(self):
self.generic_operator.add_parameter("bool", True)
self.assertEqual(self.generic_operator.get_parameter("bool"), True)
def test_param_int(self):
self.generic_operator.add_parameter("int", 1)
self.assertEqual(self.generic_operator.get_parameter("int"), 1)
def test_param_float(self):
self.generic_operator.add_parameter("float", 2.0)
self.assertEqual(self.generic_operator.get_parameter("float"), 2.0)
def test_param_str(self):
self.generic_operator.add_parameter("str", "value")
self.assertEqual(self.generic_operator.get_parameter("str"), "value")
def test_param_l_int(self):
self.generic_operator.add_parameter("l_int", [1,2,3])
self.assertEqual(self.generic_operator.get_parameter("l_int"), [1,2,3])
def test_param_l_bool(self):
self.generic_operator.add_parameter("l_bool", [True, False])
self.assertEqual(self.generic_operator.get_parameter("l_bool"), [True, False])
def test_param_l_float(self):
self.generic_operator.add_parameter("l_float", [2.0, 1.0])
self.assertEqual(self.generic_operator.get_parameter("l_float"), [2.0, 1.0])
def test_param_l_str(self):
self.generic_operator.add_parameter("l_str", ["ok"])
self.assertEqual(self.generic_operator.get_parameter("l_str"), ["ok"])
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
"""
Copyright (c) 2023 CEA-List
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
SPDX-License-Identifier: EPL-2.0
"""
import unittest
import aidge_core
class test_parameters(unittest.TestCase):
"""Very basic test to make sure the python APi is not broken.
Can be remove in later stage of the developpement.
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_conv(self):
# TODO : test StrideDims & DilationDims when supported in ctor
in_channels = 4
out_channels = 8
k_dims = [2, 2]
conv_op = aidge_core.Conv2D(in_channels , out_channels, k_dims).get_operator()
self.assertEqual(conv_op.get("InChannels"), in_channels)
self.assertEqual(conv_op.get("OutChannels"), out_channels)
self.assertEqual(conv_op.get("KernelDims"), k_dims)
def test_fc(self):
out_channels = 8
nb_bias = True
fc_op = aidge_core.FC(out_channels, nb_bias).get_operator()
self.assertEqual(fc_op.get("OutChannels"), out_channels)
self.assertEqual(fc_op.get("NoBias"), nb_bias)
def test_matmul(self):
out_channels = 8
matmul_op = aidge_core.Matmul(out_channels).get_operator()
self.assertEqual(matmul_op.get("OutChannels"), out_channels)
def test_producer_1D(self):
dims = [5]
producer_op = aidge_core.Producer(dims).get_operator()
self.assertEqual(producer_op.dims(), dims)
def test_producer_2D(self):
dims = [10,5]
producer_op = aidge_core.Producer(dims).get_operator()
self.assertEqual(producer_op.dims(), dims)
def test_producer_3D(self):
dims = [1,10,5]
producer_op = aidge_core.Producer(dims).get_operator()
self.assertEqual(producer_op.dims(), dims)
def test_producer_4D(self):
dims = [12,1,10,5]
producer_op = aidge_core.Producer(dims).get_operator()
self.assertEqual(producer_op.dims(), dims)
def test_producer_5D(self):
dims = [2,12,1,10,5]
producer_op = aidge_core.Producer(dims).get_operator()
self.assertEqual(producer_op.dims(), dims)
def test_leaky_relu(self):
negative_slope = 0.25
leakyrelu_op = aidge_core.LeakyReLU(negative_slope).get_operator()
self.assertEqual(leakyrelu_op.get("NegativeSlope"), negative_slope)
if __name__ == '__main__':
unittest.main()
......@@ -21,7 +21,7 @@ namespace py = pybind11;
namespace Aidge {
void declare_FC(py::module &m) {
py::class_<FC_Op, std::shared_ptr<FC_Op>, Operator>(m, "FC_Op", py::multiple_inheritance());
py::class_<FC_Op, std::shared_ptr<FC_Op>, Operator, PyAbstractParametrizable>(m, "FC_Op", py::multiple_inheritance());
m.def("FC", &FC, py::arg("out_channels"), py::arg("nobias") = false, py::arg("name") = nullptr);
}
......
......@@ -21,7 +21,7 @@ namespace py = pybind11;
namespace Aidge {
void declare_Matmul(py::module &m) {
py::class_<Matmul_Op, std::shared_ptr<Matmul_Op>, Operator>(m, "Matmul_Op", py::multiple_inheritance());
py::class_<Matmul_Op, std::shared_ptr<Matmul_Op>, Operator, PyAbstractParametrizable>(m, "Matmul_Op", py::multiple_inheritance());
m.def("Matmul", &Matmul, py::arg("out_channels"), py::arg("name") = nullptr);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment