diff --git a/.gitlab/ci/build.gitlab-ci.yml b/.gitlab/ci/build.gitlab-ci.yml index d0e32e3d11a7e0aad06828b3232a7aa6e063d75d..45119bfc5f24dfeedb36fd4b7239ab480c553af1 100644 --- a/.gitlab/ci/build.gitlab-ci.yml +++ b/.gitlab/ci/build.gitlab-ci.yml @@ -1,3 +1,6 @@ +include: + - remote: 'https://gitlab.eclipse.org/eclipse/aidge/gitlab_shared_files/-/raw/main/.gitlab/ci/shared_script.gitlab-ci.yml' + build:ubuntu_python: stage: build needs: [] @@ -5,12 +8,11 @@ build:ubuntu_python: - docker script: # Download dependencies - # aidge_core (Python) - - 'curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:ubuntu_python"' - - unzip -o build_artifacts.zip -d . - # aidge_backend_cpu (Python) - - 'curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/5140/jobs/artifacts/master/download?job=build:ubuntu_python"' - - unzip -o build_artifacts.zip -d . + - DEPENDENCY_JOB="build:ubuntu_python" + # aidge_core + - DEPENDENCY_NAME="aidge_core" + - echo ${CI_PROJECT_NAMESPACE_ID} + - !reference [.download_dependency, script] - python3 -m pip install virtualenv - virtualenv venv diff --git a/.pylintrc b/.pylintrc index 7134519f6da2d64d4b6cd99d6f1be671e3293f28..e7213ef2e19e667bd8b8c1254cc32ced1fdecc6b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,7 +3,7 @@ # 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, aidge_backend_cpu, torch, tensorflow +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 @@ -396,7 +396,7 @@ ignored-classes=optparse.Values, # (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, aidge_backend_cpu +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. diff --git a/aidge_onnx/node_import/onnx_converters/dropout.py b/aidge_onnx/node_import/onnx_converters/dropout.py index 027e463f0342357aa0492bca69a1814e18bf2df8..fb065df624d98208afaf787684924c4b1596e5f8 100644 --- a/aidge_onnx/node_import/onnx_converters/dropout.py +++ b/aidge_onnx/node_import/onnx_converters/dropout.py @@ -24,8 +24,7 @@ def import_dropout(onnx_node:onnx.NodeProto, input_nodes:List[aidge_core.Node], """ node_name = onnx_node.output[0] - # this is a simple workaround to force dropout to have 1 output (ignore the optional mask output) - # @todo: replace this with Dropout operator when it is added - my_node = aidge_core.GenericOperator("Dropout", 1, 0, 1, name=node_name) + # @todo: replace Identity with Dropout operator when it is added + my_node = aidge_core.Identity(name=node_name) print(f"- {node_name} ({onnx_node.op_type})") return my_node diff --git a/aidge_onnx/node_import/onnx_converters/gather.py b/aidge_onnx/node_import/onnx_converters/gather.py index acf824b55a8b2810c2cc47761a33d28e7a246c9f..2eab9ce6ffcefb8f0bcf783ebad503ecace5cf1e 100644 --- a/aidge_onnx/node_import/onnx_converters/gather.py +++ b/aidge_onnx/node_import/onnx_converters/gather.py @@ -38,7 +38,13 @@ def import_gather(onnx_node:onnx.NodeProto, input_nodes:List[aidge_core.Node], o print(f"Warning: unsupported attribute(s): {attrs.keys()} for operator gather.") return None - - gather_node = aidge_core.Gather(axis, name=node_name) + indices_input = input_nodes.pop().get_operator().get_output(0) + + gathered_shape = [] + # In case a single index is given, the dimension should be removed so an empty shape is passed + if indices_input.size() > 1: + gathered_shape = indices_input.dims() + + gather_node = aidge_core.Gather(indices_input, gathered_shape, axis, name=node_name) print(f"- {node_name} ({onnx_node.op_type})") return gather_node diff --git a/aidge_onnx/node_import/onnx_converters/matmul.py b/aidge_onnx/node_import/onnx_converters/matmul.py new file mode 100644 index 0000000000000000000000000000000000000000..b7dd97787dd44b773c932e85aa2a611169e7fe29 --- /dev/null +++ b/aidge_onnx/node_import/onnx_converters/matmul.py @@ -0,0 +1,35 @@ +""" +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 typing import List +import numpy as np + +import aidge_core +import onnx + +from aidge_onnx.node_import import auto_register_import + +@auto_register_import("matmul") +def import_matmul(onnx_node:onnx.NodeProto, input_nodes:List[aidge_core.Node], opset=None) -> aidge_core.Node: + """ + :param onnx_node: ONNX node to convert + :type onnx_node: onnx.NodeProto + :param input_nodes: List of Aidge nodes which constitute the input of the current node + :type input_nodes: List[aidge_core.Node] + """ + node_name = onnx_node.output[0] + attrs = {attr.name : attr for attr in onnx_node.attribute} + + if len(attrs) > 0: + print(f"Warning: unsupported attribute(s): {attrs.keys()} for operator matmul.") + return None + + matmul_node = aidge_core.MatMul(name=node_name) + print(f"- {node_name} ({onnx_node.op_type})") + return matmul_node diff --git a/aidge_onnx/node_import/onnx_converters/slice.py b/aidge_onnx/node_import/onnx_converters/slice.py index 19d83d86bc1a0d2926f376658986e6316b329fc2..1b0eea0514fb602e3bbac3bb73ef242905c11b28 100644 --- a/aidge_onnx/node_import/onnx_converters/slice.py +++ b/aidge_onnx/node_import/onnx_converters/slice.py @@ -28,10 +28,10 @@ def import_slice(onnx_node:onnx.NodeProto, input_nodes:List[aidge_core.Node], op print(f"Warning: Attribute {attr.name} is not supported for operator slice.") return None - - starts = input_nodes.pop().get_operator().get_output(0) - ends = input_nodes.pop().get_operator().get_output(0) axes = input_nodes.pop().get_operator().get_output(0) + ends = input_nodes.pop().get_operator().get_output(0) + ends = [i - 1 for i in ends] + starts = input_nodes.pop().get_operator().get_output(0) slice_node = aidge_core.Slice( starts, ends, axes, name=node_name) diff --git a/aidge_onnx/unit_tests/test_generic.py b/aidge_onnx/unit_tests/test_generic.py index 898a191b53778c91b2be7b22a660205f174d161a..ec85180a1693fe3f201c72e112c643ea1ee1c240 100644 --- a/aidge_onnx/unit_tests/test_generic.py +++ b/aidge_onnx/unit_tests/test_generic.py @@ -2,7 +2,6 @@ import unittest import aidge_onnx import aidge_core -import aidge_backend_cpu import numpy as np import onnx diff --git a/aidge_onnx/unit_tests/test_import_export.py b/aidge_onnx/unit_tests/test_import_export.py index a4d01c556cffe8854028ca6eed6aa38c51c6d5a1..c76b2e501184a318cc914eac1f6bdd2dfb83afe6 100644 --- a/aidge_onnx/unit_tests/test_import_export.py +++ b/aidge_onnx/unit_tests/test_import_export.py @@ -1,14 +1,6 @@ import unittest import aidge_onnx -import aidge_core -import aidge_backend_cpu - -import numpy as np -import onnx -from onnx import helper -from onnx import numpy_helper -from onnx import TensorProto import requests def download_onnx_model(url, destination): @@ -32,7 +24,7 @@ class test_load_save(unittest.TestCase): pass def test_converter(self): - url = "https://github.com/onnx/models/raw/main/Computer_Vision/mobilenet_v2_Opset18_torch_hub/mobilenet_v2_Opset18.onnx?download=" + url = "https://github.com/onnx/models/raw/69d69010b7ed6ba9438c392943d2715026792d40/Computer_Vision/mobilenetv2_050_Opset18_timm/mobilenetv2_050_Opset18.onnx?download=" og_filename = "mobilenetV2.onnx" aidge_filename = "aidge_mobilenetV2.onnx" download_onnx_model(url, og_filename) diff --git a/aidge_onnx/unit_tests/test_node_conv.py b/aidge_onnx/unit_tests/test_node_conv.py index 9edb7f4d57f322ea9e831b7da91f1fc45104a44c..4f9b997111763f058391fa02c53a88d152bb92e2 100644 --- a/aidge_onnx/unit_tests/test_node_conv.py +++ b/aidge_onnx/unit_tests/test_node_conv.py @@ -1,9 +1,6 @@ import unittest import aidge_onnx -import aidge_core -import aidge_backend_cpu - import numpy as np import onnx from onnx import helper diff --git a/setup.py b/setup.py index 51995c67614f31553b48035f1b2cd671ef16ab6a..612bae20a8708c3c909a308484617bd8c34dedd1 100644 --- a/setup.py +++ b/setup.py @@ -45,5 +45,5 @@ if __name__ == '__main__': long_description="\n".join(DOCLINES[2:]), classifiers=[c for c in CLASSIFIERS.split('\n') if c], packages=[ROOT_PACKAGE] + [f"{ROOT_PACKAGE}.{item}" for item in find_packages(where=ROOT_PACKAGE)], - install_requires=['aidge_core', 'aidge_backend_cpu'], - ) \ No newline at end of file + install_requires=['aidge_core'], + )