Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Check Release
on:
workflow_dispatch:
schedule:
# every first day of the week
- cron: '0 0 * * *'
# push:

jobs:

release-linux-mac:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
python-version: ['3.12', '3.11', '3.10']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install onnx-diagnostic
run: pip install onnx-diagnostic
- name: Version
run: |
python -c "import onnx_diagnostic;print(onnx_diagnostic.__version__)"
- name: Installation path
run: python -c "import onnx_diagnostic;print(onnx_diagnostic.__file__)"
- name: git checkout
run: |
git init
git remote add -f origin https://github.com/sdpython/onnx-diagnostic.git
git config core.sparsecheckout true
echo _unittests/ >> .git/info/sparse-checkout
echo _doc/examples/ >> .git/info/sparse-checkout
echo pyproject.toml >> .git/info/sparse-checkout
echo requirements-dev.txt >> .git/info/sparse-checkout
git pull origin main
VERSION=$(python -c "import onnx_diagnostic;print(onnx_diagnostic.__version__)")
git checkout tags/${VERSION} -b thistag
- name: ls
run: ls .
- name: Install requirements
run: pip install -r requirements-dev.txt
- name: Run pytest
run: pytest _unittests

release-windows:
strategy:
matrix:
os: [windows-latest]
python-version: ['3.12', '3.11', '3.10']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install onnx-diagnostic
run: pip install onnx-diagnostic
- name: Version
run: |
python -c "import onnx_diagnostic;print(onnx_diagnostic.__version__)"
- name: Installation path
run: python -c "import onnx_diagnostic;print(onnx_diagnostic.__file__)"
- name: git checkout
run: |
git init
git remote add -f origin https://github.com/sdpython/onnx-diagnostic.git
git config core.sparsecheckout true
echo _unittests/ >> .git\info\sparse-checkout
echo _doc/examples/ >> .git\info\sparse-checkout
echo pyproject.toml >> .git\info\sparse-checkout
echo requirements-dev.txt >> .git/info/sparse-checkout
git pull origin main
git checkout tags/0.2.2 -b thistag
- name: ls
run: ls .
- name: Install requirements
run: pip install -r requirements-dev.txt
- name: Run pytest
run: pytest _unittests
3 changes: 2 additions & 1 deletion _doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ onnx-diagnostic: investigate onnx models
.. image:: https://codecov.io/gh/sdpython/onnx-diagnostic/branch/main/graph/badge.svg?token=Wb9ZGDta8J
:target: https://codecov.io/gh/sdpython/onnx-diagnostic

**onnx-diagnostic** is mostly to experiment ideas.
**onnx-diagnostic** helps investgating onnx models, exporting models into onnx.
It implements tools used to understand issues.

Source are `sdpython/onnx-diagnostic
<https://github.com/sdpython/onnx-diagnostic>`_.
Expand Down
66 changes: 66 additions & 0 deletions _unittests/ut_reference/test_ort_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ml_dtypes
from onnx import ModelProto, TensorProto
from onnx.checker import check_model
import onnx
import onnx.helper as oh
import onnx.numpy_helper as onh
import torch
Expand Down Expand Up @@ -248,6 +249,71 @@ def test_init_torch_bfloat16(self):
self.assertIsInstance(got[0], (torch.Tensor, np.ndarray))
self.assertEqualArray(expected[0], got[0])

@hide_stdout()
def test_if(self):

def _mkv_(name):
value_info_proto = onnx.ValueInfoProto()
value_info_proto.name = name
return value_info_proto

model = oh.make_model(
oh.make_graph(
[
oh.make_node("ReduceSum", ["X"], ["Xred"]),
oh.make_node("Add", ["X", "two"], ["X0"]),
oh.make_node("Add", ["X0", "zero"], ["X00"]),
oh.make_node("CastLike", ["one", "Xred"], ["one_c"]),
oh.make_node("Greater", ["Xred", "one_c"], ["cond"]),
oh.make_node(
"If",
["cond"],
["Z_c"],
then_branch=oh.make_graph(
[
oh.make_node("Constant", [], ["two"], value_floats=[2.1]),
oh.make_node("Add", ["X00", "two"], ["Y"]),
],
"then",
[],
[_mkv_("Y")],
),
else_branch=oh.make_graph(
[
oh.make_node("Constant", [], ["two"], value_floats=[2.2]),
oh.make_node("Sub", ["X0", "two"], ["Y"]),
],
"else",
[],
[_mkv_("Y")],
),
),
oh.make_node("CastLike", ["Z_c", "X"], ["Z"]),
],
"test",
[
oh.make_tensor_value_info("X", TensorProto.FLOAT, ["N"]),
oh.make_tensor_value_info("one", TensorProto.FLOAT, ["N"]),
],
[oh.make_tensor_value_info("Z", TensorProto.UNDEFINED, ["N"])],
[
onh.from_array(np.array([0], dtype=np.float32), name="zero"),
onh.from_array(np.array([2], dtype=np.float32), name="two"),
],
),
opset_imports=[oh.make_operatorsetid("", 18)],
ir_version=10,
)
feeds = {
"X": np.array([1, 2, 3], dtype=np.float32),
"one": np.array([1], dtype=np.float32),
}
ref = ExtendedReferenceEvaluator(model, verbose=10)
expected = ref.run(None, feeds)[0]
sess = OnnxruntimeEvaluator(model, verbose=10)
got = sess.run(None, feeds)[0]
self.assertEqualArray(expected[0], got[0])


if __name__ == "__main__":
unittest.main(verbosity=2)
Loading