Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cleanup transformation sorting inputs of commutative operations #85

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
6250172
[Range] use monotonic range calc for reshapes
maltanar Aug 30, 2023
64d95ac
QuantLSTM ONNX representation
shashwat1198 Oct 22, 2023
e2e0737
Clean QuantLSTM
shashwat1198 Oct 22, 2023
95279e4
[Transform] introduce ExtractQuantScaleZeroPt and simple test
maltanar Oct 24, 2023
9e0a49a
[Test] add more testcases for ExtractQuantScaleZeroPt
maltanar Oct 24, 2023
51b6717
Update 0_how_to_work_with_onnx.ipynb
Harsh9650 Nov 6, 2023
94321b7
Add option to find_upstream to keep nodes visited even if not found
iksnagreb Nov 14, 2023
7719a3e
Add cleanup transformation sorting inputs of commutative operations
iksnagreb Nov 14, 2023
c0f5b46
Address some linting issues
iksnagreb Nov 14, 2023
ebd9193
Introduce 3D layout annotations defaulting to NWC
iksnagreb Nov 20, 2023
6f8efa2
update in the matmul mac calculation
Nov 21, 2023
cdc2747
[Hotfix] round scaled-up internal result for QuantAvgPool2d
maltanar Nov 21, 2023
62223f3
Merge pull request #89 from iksnagreb/feature/3d_data_layouts
maltanar Nov 21, 2023
6298df5
Merge branch 'main' into feature/tensor_stats
maltanar Jan 12, 2024
e8de415
Merge main into feature/tensor_stats + deprecate propagate_range
maltanar Jan 12, 2024
538a935
Transformation pass to introduce quantnodes
Jan 14, 2024
c752dfb
[Range] support multi-output ops, add Split
maltanar Jan 30, 2024
251030b
[Extract] support extracting ConvTranspose bias
maltanar Jan 30, 2024
f5f17f3
[Range] support dense ConvTranspose for analysis
maltanar Jan 30, 2024
f209c9d
[Range] support Python notation for input ranges ([ch0_min, ch1_min,.…
maltanar Jan 30, 2024
96906cb
[Cleanup] allow overriding full input tensor size
maltanar Jan 30, 2024
11850c1
[Extract] use derived output dtype for conv bias extraction
maltanar Jan 31, 2024
184bfd7
[Range] also work with np.float16
maltanar Jan 31, 2024
2d6322b
[Cleanup] support both str and tuple format for input shape override
maltanar Jan 31, 2024
1de24c5
use newer tf2onnx
maltanar Feb 5, 2024
fd3b319
[Test] add validated/ to ONNX model zoo URLs
maltanar Feb 5, 2024
813128f
Merge pull request #96 from fastmachinelearning/fix/tf2onnx-1.16.1
maltanar Feb 5, 2024
3a33770
Merge branch 'main' into feature/tensor_stats
maltanar Feb 5, 2024
3fd9386
Merge pull request #97 from fastmachinelearning/feature/tensor_stats
maltanar Feb 5, 2024
7d5c3a5
Merge branch 'import_edits' of https://github.com/Harsh9650/qonnx int…
maltanar Feb 5, 2024
3b0f11e
fix typo in notebooks README
maltanar Feb 5, 2024
baff921
[Notebook] more fixes to 0_how_to_work_with_onnx.ipynb
maltanar Feb 5, 2024
e3cba58
Merge pull request #81 from Harsh9650/import_edits
maltanar Feb 5, 2024
038f21e
Merge branch 'main' into transformation_introducing_quantnode
maltanar Feb 5, 2024
2feab84
[Test] override_batchsize -> override_inpsize for cleanup
maltanar Feb 5, 2024
3e132fe
[GraphQnt] some cleanup and renaming
maltanar Feb 5, 2024
99841c1
[DataType] add preliminary support for FLOAT16
maltanar Feb 6, 2024
42df7a0
Revised version for QuantizeGraph
Feb 8, 2024
39442cb
Merge pull request #90 from fastmachinelearning/matmul_mac_update
maltanar Feb 13, 2024
7608e7c
inference cost breakdown
Feb 15, 2024
d120742
Update inference_cost.py
Harsh9650 Feb 15, 2024
04619a3
revised version of quantize_graph
Feb 15, 2024
be9a9f8
Update inference_cost.py
Harsh9650 Feb 21, 2024
4743ae2
Merge pull request #80 from fastmachinelearning/feature/extract_quant…
maltanar Feb 23, 2024
1815bb4
Merge branch 'feature/find_upstream_keep_visited' of https://github.c…
maltanar Feb 23, 2024
fad667f
fix linting problems
maltanar Feb 23, 2024
b3186cb
Merge branch 'main' into iksnagreb-feature/find_upstream_keep_visited
maltanar Feb 23, 2024
fe4aa37
Merge pull request #83 from iksnagreb/feature/find_upstream_keep_visited
maltanar Feb 23, 2024
8bba76b
Merge branch 'feature/sort_commutative_inputs' of https://github.com/…
maltanar Feb 23, 2024
5e2d0b8
[Wrapper] explicitly return None for name/index finder functions
maltanar Feb 23, 2024
fd61cfe
Merge pull request #94 from fastmachinelearning/transformation_introd…
maltanar Feb 23, 2024
565d978
Feat (transformation): adding ResizeConvolutionToDeconvolution transf…
i-colbert Feb 20, 2024
cfc8dda
Feat (transformation): restructure onnx data for upsampling tests
i-colbert Feb 20, 2024
057c263
Feat (tests): adding resize to deconv unit tests
i-colbert Feb 20, 2024
e199a46
Fix (transformation): fixing warnings to exit on unsupported condition
i-colbert Feb 20, 2024
19c73fe
Pre-commit fixes
i-colbert Feb 20, 2024
59a7ca0
package installations added
shashwat1198 Mar 1, 2024
30b838b
Fix (tests): removing generated onnx graph
i-colbert Mar 7, 2024
8d66e89
Fix (util): centralizing auto pad utility
i-colbert Mar 7, 2024
bf1840d
Fix: adding check and warning for dimension mismatch
i-colbert Mar 7, 2024
fd834aa
Fix: handling case where bias is generated from another node
i-colbert Mar 7, 2024
29e6843
Pre-commit fixes
i-colbert Mar 7, 2024
13906da
Fix: handling scalar vs. array scaling factor
i-colbert Mar 10, 2024
b7eebaa
Fix: adding quant test cases and fixing bugs
i-colbert Mar 11, 2024
c5bd87f
Merge pull request #102 from i-colbert/icolbert/nn-resize-to-deconv
maltanar Mar 12, 2024
7ebbeac
Add unit test for SortCommutativeInputsInitializerLast transformation
iksnagreb Apr 25, 2024
38df9fb
Address some linting issues
iksnagreb Apr 25, 2024
57d0d9d
Remove some commented debug code
timkpaine May 11, 2024
1dfda07
fix linting
maltanar May 21, 2024
2cc6d52
[InfCost] per-node norm mac/param counts, always floats for json
maltanar May 21, 2024
4dd2000
update README
maltanar May 21, 2024
0ca12ce
Merge branch 'main' into inference_cost_breakdown
maltanar May 21, 2024
a4e7e35
[Test] fix changes return style for inference cost
maltanar May 21, 2024
db969e6
Merge pull request #101 from fastmachinelearning/inference_cost_break…
maltanar May 21, 2024
f9db218
fix notebook 0
makoeppel Jun 17, 2024
1b2774c
refactor LowerConvsToMatMul class, increase rtol in test_conv_lowerin…
makoeppel Jun 17, 2024
17bd6d0
avoiding mp.Pool in case of using only 1 worker for easier pdb debugging
lstasytis Jul 19, 2024
5414416
strings attribute support added to CustomOp
Jul 30, 2024
ba5c41f
strings attr test added to test_attr.py
Aug 1, 2024
b0a6088
[README] updates to dev docs: pip upgrade, linting
maltanar Aug 9, 2024
326a525
Merge pull request #130 from fastmachinelearning/feature/readme_dev_u…
maltanar Aug 9, 2024
3835a37
ran pre-commit
lstasytis Aug 9, 2024
654bf15
pre-commit applied
Aug 12, 2024
c4c16f7
Merge pull request #128 from mdanilow/feature/strings_attr
maltanar Aug 12, 2024
2281a77
Merge pull request #127 from lstasytis/fix/avoid-mp-pool-with-one-worker
maltanar Aug 13, 2024
a8ca195
Merge pull request #119 from makoeppel/fix_qonnx_import_in_notebook_0
maltanar Aug 13, 2024
698c4bf
Merge pull request #79 from shashwat1198/main
maltanar Aug 13, 2024
415634b
Merge branch 'improve/test_conv_lowering_convmnist' of https://github…
maltanar Aug 16, 2024
75f8f8c
run pre-commit on all files
maltanar Aug 16, 2024
84ad7ae
Merge pull request #120 from makoeppel/improve/test_conv_lowering_con…
maltanar Aug 16, 2024
8f66615
[LowerConv] skip convs with non-initialized weights
maltanar Aug 16, 2024
a92093c
[Test] add (failing) quant weight conv testcase for lowering
maltanar Aug 16, 2024
5e5bb55
[LowerConv] support lowering Conv with Quant node on weights
maltanar Aug 16, 2024
c54f142
[Test] extend quant weight conv testcase, now passing
maltanar Aug 16, 2024
8d1ee1d
[LowerConv] support reshaping quant conv weight scales
maltanar Aug 16, 2024
55c2f6f
[Test] add MNv1 for quant conv lowering test
maltanar Aug 16, 2024
a3451c5
[Test] use np.isclose instead of equals for test condition
maltanar Aug 18, 2024
100bfde
[Util] break out test input generation function & allow seed setting
maltanar Aug 22, 2024
032681c
[Lower] fix quant scale conversion, adjust seed
maltanar Aug 22, 2024
bdf9405
Merge pull request #132 from fastmachinelearning/feature/convlower_qnt
maltanar Aug 22, 2024
c9ad9e5
Merge pull request #116 from timkpaine/tkp/clean
jmduarte Aug 23, 2024
3c870d6
[Util] add accumulator-aware quantized (A2Q) CIFAR-10 models
maltanar Sep 9, 2024
ee7464f
[Test] correctly handle multi-channel input ranges in change_batchsize
maltanar Sep 9, 2024
8694a6d
[Util] handle per-channel ranges in get_random_input
maltanar Sep 9, 2024
1f8938a
Merge pull request #142 from fastmachinelearning/feature/test_a2q_nets
maltanar Sep 9, 2024
cc1b1f0
Merge branch 'feature/sort_commutative_inputs' of https://github.com/…
maltanar Sep 12, 2024
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
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Inference cost for CNV_2W2A.onnx
}
```

You can use the `--cost-breakdown` option to generate a more detailed report that covers per-node (by name) and per-op-type information.
You can read more about the BOPS metric in [this paper](https://www.frontiersin.org/articles/10.3389/frai.2021.676564/full), Section 4.2 Bit Operations.

### Convert between different quantization representations
Expand All @@ -114,16 +115,19 @@ Please see the documentation of the `QuantToQCDQ` transformation to learn more a

## Development

Install in editable mode in a venv:
Install in editable mode in a Python virtual environment:

```
git clone https://github.com/fastmachinelearning/qonnx
cd qonnx
virtualenv -p python3.8 venv
source venv/bin/activate
pip install --upgrade pip
pip install -e .[qkeras,testing]
```

### Running tests

Run entire test suite, parallelized across CPU cores:
```
pytest -n auto --verbose
Expand All @@ -134,6 +138,22 @@ Run a particular test and fall into pdb if it fails:
pytest --pdb -k "test_extend_partition.py::test_extend_partition[extend_id1-2]"
```

### Linting

If you plan to make pull requests to the qonnx repo, linting will be required.
We use a pre-commit hook to auto-format Python code and check for issues. See https://pre-commit.com/ for installation. Once you have `pre-commit`,
you can install the hooks into your local clone of the qonnx repo:

```
cd qonnx
source venv/bin/activate
pip install pre-commit
pre-commit install
```

Every time you commit some code, the pre-commit hooks will first run, performing various checks and fixes. In some cases pre-commit won’t be able to
fix the issues and you may have to fix it manually, then run git commit once again. The checks are configured in .pre-commit-config.yaml under the repo root.

## Why QONNX?

The QONNX representation has several advantages compared to other alternatives, as summarized in the table below.
Expand Down
3 changes: 3 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Install in editable mode in a venv:
pip install -e .[testing, docs, notebooks]


Test suite
++++++++++

Run entire test suite, parallelized across CPU cores:

::
Expand Down
4 changes: 2 additions & 2 deletions docs/license.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _license:

=======
========
License
=======
========

.. include:: ../LICENSE
29 changes: 15 additions & 14 deletions notebooks/0_how_to_work_with_onnx.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"outputs": [],
"source": [
"import onnx\n",
"from qonnx.basic.util import qonnx_make_model\n",
"from qonnx.util.basic import qonnx_make_model\n",
"\n",
"Add1_node = onnx.helper.make_node(\n",
" 'Add',\n",
Expand Down Expand Up @@ -68,26 +68,26 @@
" name='Add2',\n",
")\n",
"\n",
"Add3_node = onnx.helper.make_node(\n",
" 'Add',\n",
" inputs=['abs1', 'abs1'],\n",
" outputs=['sum3'],\n",
" name='Add3',\n",
")\n",
"\n",
"Abs_node = onnx.helper.make_node(\n",
" 'Abs',\n",
" inputs=['sum2'],\n",
" outputs=['abs1'],\n",
" name='Abs'\n",
")\n",
"\n",
"Add3_node = onnx.helper.make_node(\n",
" 'Add',\n",
" inputs=['abs1', 'abs1'],\n",
" outputs=['sum3'],\n",
" name='Add3',\n",
")\n",
"\n",
"Round_node = onnx.helper.make_node(\n",
" 'Round',\n",
" inputs=['sum3'],\n",
" outputs=['out1'],\n",
" name='Round',\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -253,7 +253,7 @@
"metadata": {},
"outputs": [],
"source": [
"in1_values =np.asarray(np.random.uniform(low=-5, high=5, size=(4,4)), dtype=np.float32)\n",
"in1_values = np.asarray(np.random.uniform(low=-5, high=5, size=(4,4)), dtype=np.float32)\n",
"in2_values = np.asarray(np.random.uniform(low=-5, high=5, size=(4,4)), dtype=np.float32)\n",
"in3_values = np.asarray(np.random.uniform(low=-5, high=5, size=(4,4)), dtype=np.float32)"
]
Expand Down Expand Up @@ -350,6 +350,7 @@
"metadata": {},
"outputs": [],
"source": [
"import qonnx\n",
"from qonnx.core.modelwrapper import ModelWrapper\n",
"finn_model = ModelWrapper(onnx_model)"
]
Expand Down Expand Up @@ -608,7 +609,7 @@
"metadata": {},
"outputs": [],
"source": [
"onnx_model1 = onnx.qonnx_make_model(graph, producer_name=\"simple-model1\")\n",
"onnx_model1 = qonnx.util.basic.qonnx_make_model(graph, producer_name=\"simple-model1\")\n",
"onnx.save(onnx_model1, '/tmp/simple_model1.onnx')"
]
},
Expand Down Expand Up @@ -656,7 +657,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -670,7 +671,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.8.18"
},
"vscode": {
"interpreter": {
Expand All @@ -679,5 +680,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Loading
Loading