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

Fix/Feat (trunc avg pool): Update truncation and average pool behaviour #1042

Open
wants to merge 38 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0d7637b
Fix (quant_tensor): Produce valid IntQuantTensor after AvgPool functi…
nickfraser Oct 4, 2024
200cb4e
Fix (core/trunc): Fix output scaling after truncation
nickfraser Oct 4, 2024
69f0463
Fix (nn/TruncAvgPool): Remove any quant tensor manual manipulation.
nickfraser Oct 4, 2024
0f4df89
fix/trunc_avg_pool: Clamp output.
nickfraser Jan 22, 2025
f184727
style: fix
nickfraser Jan 22, 2025
5aee892
fix (trunc_avg_pool): Set default arguments for backward compatibility
nickfraser Jan 22, 2025
6fb7ced
test (trunc_int_quant): Added initial sanity-check test
nickfraser Jan 22, 2025
bc2aaa9
fix (export/torch/qcdq): Fixed output scale, and `signed` setting
nickfraser Jan 22, 2025
a61a63a
Fix (core/proxy/trunc): Moved setting of signed to the proxy
nickfraser Jan 22, 2025
e10583b
fix (qonnx/trunc): Fixed Trunc Quant QONNX export
nickfraser Jan 23, 2025
dc7b9b1
fix (trunc): Factored out scaling calculation to standalone class.
nickfraser Jan 24, 2025
5e9e106
fix typo: Updated comment in TruncAvgPool export
nickfraser Jan 24, 2025
7971700
feat (trunc/scaling): Factored out the scaling implementation.
nickfraser Jan 24, 2025
5f8d95b
test (trunc): Added signed overflow test
nickfraser Jan 24, 2025
26ad5c5
test (trunc): Added more unti tests.
nickfraser Jan 24, 2025
b1db190
fix (test/trunc): Bugfixes and tests.
nickfraser Jan 24, 2025
e2878e9
Fix: precommit
nickfraser Jan 27, 2025
2f8152f
Fix (solver/trunc): Added a ShiftRoundSaturate quantizer and update t…
nickfraser Jan 27, 2025
a1fddac
Fix (export/trunc): Updated export to generate Quant node.
nickfraser Jan 27, 2025
e48b88b
Fix (test/qonnx/trunc): Allow off-by-1 errors in test
nickfraser Jan 27, 2025
7d505e1
tests (brv_finn/avgpool): Add "lossless" tests
nickfraser Jan 28, 2025
4efa4d0
Fix (brevitas/scaling): TruncPowerOfTwoIntScaling -> PowerOfTwoIntSca…
nickfraser Jan 28, 2025
9c99d7d
Fix (scaling): Made signed an optional argument at init time.
nickfraser Jan 28, 2025
8395176
test (trunc_quant): Switched to pytest_cases.parametrize
nickfraser Jan 28, 2025
a80d7da
Fix (trunc): Fixed output zero-point calculation
nickfraser Jan 28, 2025
8e41fad
Fix (export/qonnx/trunc): Added check that zero-point is zero.
nickfraser Jan 28, 2025
6416388
Fix (export/qcdq/trunc): Pick up output scale from proxy
nickfraser Jan 28, 2025
a78408f
Fix (export/trunc): Retrieve bit_width from cache
nickfraser Jan 28, 2025
ca71825
precommit
nickfraser Jan 28, 2025
97a451d
docs (imagenet/qat): Updated accuracy with new TruncAvgPool implement…
nickfraser Jan 28, 2025
eb25fd5
test (finn/mobilenet): Allow tolerance of up-to 7 in output.
nickfraser Jan 28, 2025
c305d49
Fix (test/export/trunc): Revert export to produce a Trunc node.
nickfraser Feb 11, 2025
c6967de
fix (export/qonnx): Set QONNX OpSet.
nickfraser Mar 11, 2025
5b0ef65
Fix (export/qonnx): Set QONNX version during export
nickfraser Mar 11, 2025
14150a0
Fix style
nickfraser Mar 11, 2025
b71f2e5
Feat (export/qonnx/trunc) Added output_scale, output_zero_point as in…
nickfraser Mar 24, 2025
7a44b73
Fix (export/qonnx/trunc): Remove export of redundant output zero-point
nickfraser Mar 27, 2025
5bf5789
test (qonnx/trunc): Skip tests when qonnx<0.5.0
nickfraser Mar 27, 2025
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
Prev Previous commit
Next Next commit
test (trunc_int_quant): Added initial sanity-check test
nickfraser committed Mar 11, 2025
commit 6fb7ced6a6f9090307a011b1361475492d1fea97
22 changes: 22 additions & 0 deletions tests/brevitas/core/test_trunc_int_quant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause

from hypothesis import given
import mock
import torch

from brevitas.core.function_wrapper import RoundSte
from brevitas.core.function_wrapper import TensorClamp
from brevitas.core.quant import TruncIntQuant
from tests.brevitas.core.bit_width_fixture import * # noqa
from tests.brevitas.core.int_quant_fixture import * # noqa


class TestTruncIntQuantUnit:

def test_trunc_int_quant_defaults(self, bit_width_const):
trunc_int_quant = TruncIntQuant(
bit_width_impl=bit_width_const, float_to_int_impl=RoundSte())
assert isinstance(trunc_int_quant.tensor_clamp_impl, TensorClamp)
assert trunc_int_quant.narrow_range == False
assert trunc_int_quant.signed == True