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

Merge branch 'ViTOP' into 'master'

Fix a commit version to get the ONNX test file instead of using main which can...

See merge request !29
parents 73478639 e8c53758
No related branches found
No related tags found
1 merge request!29Fix a commit version to get the ONNX test file instead of using main which can...
Pipeline #39868 passed
include:
- remote: 'https://gitlab.eclipse.org/eclipse/aidge/gitlab_shared_files/-/raw/main/.gitlab/ci/shared_script.gitlab-ci.yml'
build:ubuntu_python: build:ubuntu_python:
stage: build stage: build
needs: [] needs: []
...@@ -5,12 +8,11 @@ build:ubuntu_python: ...@@ -5,12 +8,11 @@ build:ubuntu_python:
- docker - docker
script: script:
# Download dependencies # Download dependencies
# aidge_core (Python) - DEPENDENCY_JOB="build:ubuntu_python"
- 'curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:ubuntu_python"' # aidge_core
- unzip -o build_artifacts.zip -d . - DEPENDENCY_NAME="aidge_core"
# aidge_backend_cpu (Python) - echo ${CI_PROJECT_NAMESPACE_ID}
- 'curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/5140/jobs/artifacts/master/download?job=build:ubuntu_python"' - !reference [.download_dependency, script]
- unzip -o build_artifacts.zip -d .
- python3 -m pip install virtualenv - python3 -m pip install virtualenv
- virtualenv venv - virtualenv venv
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# A comma-separated list of package or module names from where C extensions may # 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 # be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code. # 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 # 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 # be loaded. Extensions are loading into the active Python interpreter and may
...@@ -396,7 +396,7 @@ ignored-classes=optparse.Values, ...@@ -396,7 +396,7 @@ ignored-classes=optparse.Values,
# (useful for modules/projects where namespaces are manipulated during runtime # (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It # and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching. # 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 # Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance. # of finding the hint is based on edit distance.
......
...@@ -24,8 +24,7 @@ def import_dropout(onnx_node:onnx.NodeProto, input_nodes:List[aidge_core.Node], ...@@ -24,8 +24,7 @@ def import_dropout(onnx_node:onnx.NodeProto, input_nodes:List[aidge_core.Node],
""" """
node_name = onnx_node.output[0] 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 Identity with Dropout operator when it is added
# @todo: replace this with Dropout operator when it is added my_node = aidge_core.Identity(name=node_name)
my_node = aidge_core.GenericOperator("Dropout", 1, 0, 1, name=node_name)
print(f"- {node_name} ({onnx_node.op_type})") print(f"- {node_name} ({onnx_node.op_type})")
return my_node return my_node
...@@ -38,7 +38,13 @@ def import_gather(onnx_node:onnx.NodeProto, input_nodes:List[aidge_core.Node], o ...@@ -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.") print(f"Warning: unsupported attribute(s): {attrs.keys()} for operator gather.")
return None return None
indices_input = input_nodes.pop().get_operator().get_output(0)
gather_node = aidge_core.Gather(axis, name=node_name)
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})") print(f"- {node_name} ({onnx_node.op_type})")
return gather_node return gather_node
"""
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
...@@ -28,10 +28,10 @@ def import_slice(onnx_node:onnx.NodeProto, input_nodes:List[aidge_core.Node], op ...@@ -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.") print(f"Warning: Attribute {attr.name} is not supported for operator slice.")
return None 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) 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) slice_node = aidge_core.Slice( starts, ends, axes, name=node_name)
......
...@@ -2,7 +2,6 @@ import unittest ...@@ -2,7 +2,6 @@ import unittest
import aidge_onnx import aidge_onnx
import aidge_core import aidge_core
import aidge_backend_cpu
import numpy as np import numpy as np
import onnx import onnx
......
import unittest import unittest
import aidge_onnx 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 import requests
def download_onnx_model(url, destination): def download_onnx_model(url, destination):
...@@ -32,7 +24,7 @@ class test_load_save(unittest.TestCase): ...@@ -32,7 +24,7 @@ class test_load_save(unittest.TestCase):
pass pass
def test_converter(self): 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" og_filename = "mobilenetV2.onnx"
aidge_filename = "aidge_mobilenetV2.onnx" aidge_filename = "aidge_mobilenetV2.onnx"
download_onnx_model(url, og_filename) download_onnx_model(url, og_filename)
......
import unittest import unittest
import aidge_onnx import aidge_onnx
import aidge_core
import aidge_backend_cpu
import numpy as np import numpy as np
import onnx import onnx
from onnx import helper from onnx import helper
......
...@@ -45,5 +45,5 @@ if __name__ == '__main__': ...@@ -45,5 +45,5 @@ if __name__ == '__main__':
long_description="\n".join(DOCLINES[2:]), long_description="\n".join(DOCLINES[2:]),
classifiers=[c for c in CLASSIFIERS.split('\n') if c], 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)], packages=[ROOT_PACKAGE] + [f"{ROOT_PACKAGE}.{item}" for item in find_packages(where=ROOT_PACKAGE)],
install_requires=['aidge_core', 'aidge_backend_cpu'], install_requires=['aidge_core'],
) )
\ No newline at end of file
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