Skip to content

Commit

Permalink
Upgrade version (#94)
Browse files Browse the repository at this point in the history
* Upgrade version

* upgrade version

* disable

* fix import

* disable more

* remove mac ci

* remove numpy.array_api

* remove

* one day maybe

* fix urls
  • Loading branch information
xadupre authored Feb 17, 2025
1 parent eb106e2 commit 689cc6f
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ jobs:
exit 1
fi
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: ./dist/html/**
2 changes: 1 addition & 1 deletion .github/workflows/wheels-any.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
- name: build wheel
run: python -m pip wheel .

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: ./onnx_array_api*.whl
1 change: 1 addition & 0 deletions CHANGELOGS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Change Logs
0.3.0
+++++

* :pr:`93`: fixes evaluator type in ``compare_onnx_execution``
* :pr:`92`: avoids recursion errors in profiling
* :pr:`87`: adds command line to replace contant by ConstantOfShape
* :pr:`79`: first draft to export to GraphBuilder
Expand Down
6 changes: 2 additions & 4 deletions _doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,9 @@
"torch.onnx": "https://pytorch.org/docs/stable/onnx.html",
#
"C_OrtValue": (
"http://www.xavierdupre.fr/app/onnxcustom/helpsphinx/"
"api/onnxruntime_python/ortvalue.html#c-class-ortvalue-or-c-ortvalue"
"https://onnxruntime.ai/docs/api/csharp/api/Microsoft.ML.OnnxRuntime.OrtValue.html"
),
"OrtValue": (
"http://www.xavierdupre.fr/app/onnxcustom/helpsphinx/"
"api/onnxruntime_python/ortvalue.html#onnxruntime.OrtValue"
"https://onnxruntime.ai/docs/api/python/api_summary.html#onnxruntime.OrtValue"
),
}
2 changes: 2 additions & 0 deletions _doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,7 @@ to know onnx for that. See :ref:`l-numpy-api-onnx`.
Older versions
++++++++++++++

* `0.3.0 <../v0.3.0/index.html>`_
* `0.2.0 <../v0.2.0/index.html>`_
* `0.1.3 <../v0.1.3/index.html>`_
* `0.1.2 <../v0.1.2/index.html>`_
6 changes: 6 additions & 0 deletions _unittests/onnx-numpy-skips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ array_api_tests/test_creation_functions.py::test_asarray_arrays
array_api_tests/test_creation_functions.py::test_empty
array_api_tests/test_creation_functions.py::test_empty_like
array_api_tests/test_creation_functions.py::test_eye
array_api_tests/test_creation_functions.py::test_full
array_api_tests/test_creation_functions.py::test_full_like
array_api_tests/test_creation_functions.py::test_ones
array_api_tests/test_creation_functions.py::test_ones_like
array_api_tests/test_creation_functions.py::test_zeros
array_api_tests/test_creation_functions.py::test_zeros_like
# fails to precision issue
array_api_tests/test_creation_functions.py::test_linspace
array_api_tests/test_creation_functions.py::test_meshgrid
8 changes: 1 addition & 7 deletions _unittests/ut_array_api/test_hypothesis_array_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
import warnings
from os import getenv
from functools import reduce
import packaging.version as pv
Expand Down Expand Up @@ -45,12 +44,7 @@ class TestHypothesisArraysApis(ExtTestCase):

@classmethod
def setUpClass(cls):
try:
import array_api_strict as xp
except ImportError:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
from numpy import array_api as xp
import array_api_strict as xp

api_version = getenv(
"ARRAY_API_TESTS_VERSION",
Expand Down
6 changes: 5 additions & 1 deletion _unittests/ut_graph_api/test_graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import unittest
import numpy as np
import onnx
from onnx_array_api.ext_test_case import ExtTestCase
from onnx_array_api.ext_test_case import ExtTestCase, skipif_ci_apple
from onnx_array_api.graph_api.graph_builder import GraphBuilder, OptimizationOptions
from onnx_array_api.reference import (
from_array_extended,
Expand Down Expand Up @@ -107,6 +107,7 @@ def test_simple_big(self):
got = ref.run(None, feeds)
self.assertEqualArray(expected, got[0])

@skipif_ci_apple("libomp is missing")
def test_constant_folding(self):
with contextlib.redirect_stdout(io.StringIO()):
g = GraphBuilder(verbose=10)
Expand All @@ -133,6 +134,7 @@ def test_constant_folding(self):
got = ref.run(None, feeds)
self.assertEqualArray(expected, got[0])

@skipif_ci_apple("libomp is missing")
def test_constant_folding2(self):
g = GraphBuilder(
optimization_options=OptimizationOptions(constant_folding=True)
Expand Down Expand Up @@ -270,6 +272,7 @@ def test_remove_unused_nodes_simple(self):
got = ref.run(None, feeds)
self.assertEqualArray(expected, got[0])

@skipif_ci_apple("libomp is missing")
def test_constant_array(self):
with contextlib.redirect_stdout(io.StringIO()):
g = GraphBuilder(verbose=10)
Expand All @@ -290,6 +293,7 @@ def test_constant_array(self):
got = ref.run(None, feeds)
self.assertEqualArray(expected, got[0])

@skipif_ci_apple("libomp is missing")
def test_constant_array_2(self):
with contextlib.redirect_stdout(io.StringIO()):
g = GraphBuilder(verbose=10)
Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut_npx/test_npx.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def local1(
return x

def local2(
x: TensorType[ElemType.floats, "T"]
x: TensorType[ElemType.floats, "T"],
) -> TensorType[ElemType.floats, "T"]:
return x

Expand Down
57 changes: 5 additions & 52 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ jobs:
cd array-api-tests
python -m pytest -x array_api_tests/test_creation_functions.py --skips-file=../_unittests/onnx-numpy-skips.txt --hypothesis-explain
displayName: "numpy test_creation_functions.py"
- script: |
export ARRAY_API_TESTS_MODULE=onnx_array_api.array_api.onnx_ort
cd array-api-tests
python -m pytest -x array_api_tests/test_creation_functions.py --skips-file=../_unittests/onnx-ort-skips.txt --hypothesis-explain
displayName: "ort test_creation_functions.py"
# - script: |
# export ARRAY_API_TESTS_MODULE=onnx_array_api.array_api.onnx_ort
# cd array-api-tests
# python -m pytest -x array_api_tests/test_creation_functions.py --skips-file=../_unittests/onnx-ort-skips.txt --hypothesis-explain
# displayName: "ort test_creation_functions.py"
#- script: |
# export ARRAY_API_TESTS_MODULE=onnx_array_api.array_api.onnx_numpy
# cd array-api-tests
Expand Down Expand Up @@ -238,50 +238,3 @@ jobs:
inputs:
artifactName: 'wheel-windows-$(python.version)'
targetPath: 'dist'

- job: 'TestMac'
pool:
vmImage: 'macOS-latest'
strategy:
matrix:
Python311-Mac:
python.version: '3.11'
maxParallel: 3

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
- script: gcc --version
displayName: 'gcc version'
#- script: brew upgrade
# displayName: 'brew upgrade'
#- script: brew update
# displayName: 'brew update'
- script: export
displayName: 'export'
- script: gcc --version
displayName: 'gcc version'
- script: python -m pip install --upgrade pip setuptools wheel
displayName: 'Install tools'
- script: pip install -r requirements.txt
displayName: 'Install Requirements'
- script: pip install -r requirements-dev.txt
displayName: 'Install Requirements dev'
- script: pip install onnxmltools --no-deps
displayName: 'Install onnxmltools'
- script: |
python -m pip freeze
displayName: 'pip freeze'
- script: |
python -m pytest
displayName: 'Runs Unit Tests'
- script: |
python -u setup.py bdist_wheel
displayName: 'Build Package'
- task: PublishPipelineArtifact@0
inputs:
artifactName: 'wheel-mac-$(python.version)'
targetPath: 'dist'

2 changes: 1 addition & 1 deletion onnx_array_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
APIs to create ONNX Graphs.
"""

__version__ = "0.2.0"
__version__ = "0.3.0"
__author__ = "Xavier Dupré"
14 changes: 4 additions & 10 deletions onnx_array_api/array_api/_onnx_common.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
from typing import Any, Optional
import warnings
import numpy as np
from onnx import TensorProto

try:
import array_api_strict

Array = type(array_api_strict.ones((1,)))
except ImportError:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
from numpy.array_api._array_object import Array
import array_api_strict

from ..npx.npx_types import (
DType,
Expand All @@ -36,6 +27,9 @@
)


Array = type(array_api_strict.ones((1,)))


# These functions with no specific code do not have to be
# implemented. They are automatically added in
# :mod:`onnx_array_api.array_api`. It needs
Expand Down
8 changes: 4 additions & 4 deletions onnx_array_api/npx/npx_functions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@

@npxapi_function
def _min_max(
x: TensorType[ElemType.numerics, "T"]
x: TensorType[ElemType.numerics, "T"],
) -> TupleType[TensorType[ElemType.numerics, "T"], TensorType[ElemType.numerics, "T"]]:
return tuple_var(var(x, op="ReduceMin"), var(x, op="ReduceMax"))


@npxapi_inline
def _min_max_inline(
x: TensorType[ElemType.numerics, "T"]
x: TensorType[ElemType.numerics, "T"],
) -> TupleType[TensorType[ElemType.numerics, "T"], TensorType[ElemType.numerics, "T"]]:
return tuple_var(var(x, op="ReduceMin"), var(x, op="ReduceMax"))


@npxapi_function
def absolute(
x: TensorType[ElemType.numerics, "T"]
x: TensorType[ElemType.numerics, "T"],
) -> TensorType[ElemType.numerics, "T"]:
"See :func:`numpy.absolute`."
return var(x, op="Abs")
Expand Down Expand Up @@ -90,7 +90,7 @@ def log1p(x: TensorType[ElemType.floats, "T"]) -> TensorType[ElemType.floats, "T

@npxapi_function
def negative(
x: TensorType[ElemType.numerics, "T"]
x: TensorType[ElemType.numerics, "T"],
) -> TensorType[ElemType.numerics, "T"]:
"See :func:`numpy.negative`."
return var(x, op="Neg")
Expand Down
2 changes: 1 addition & 1 deletion onnx_array_api/validation/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def randomize_proto(
onx: Union[ModelProto, GraphProto, FunctionProto, NodeProto, TensorProto]
onx: Union[ModelProto, GraphProto, FunctionProto, NodeProto, TensorProto],
) -> Union[ModelProto, GraphProto, FunctionProto, NodeProto, TensorProto]:
"""
Randomizes float initializers or constant nodes.
Expand Down

0 comments on commit 689cc6f

Please sign in to comment.