Skip to content

Commit

Permalink
Fix (tests): adapt tests to new logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe5 committed Nov 13, 2023
1 parent 3e6920a commit 7b1f46f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions tests/brevitas/core/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ def test_zero_percentile(self):

def test_interval_percentile(self):
values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
values = torch.tensor(values)
values = torch.tensor(values, dtype=torch.float32)
interval_percentile = PercentileInterval(low_percentile_q=0.01, high_percentile_q=99.9)
out = interval_percentile(values)

range = self.compute_percentile(values, low_q=0.01, high_q=99.9)
expected_out = torch.abs(range[1] - range[0])
# Clamp is to make sure the lower bound is not positive to align with zero-point statistics
low_result = torch.clamp(range[0], max=torch.tensor(0.0))
expected_out = torch.abs(range[1] - low_result)
assert torch.allclose(out, expected_out)
2 changes: 1 addition & 1 deletion tests/brevitas/fx/test_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,4 @@ def test_quant_module(module):
out = mod(x)
graph_model = value_trace(mod, value_args={'x': x_trace})
graph_out = graph_model(x)
assert graph_out.value.isclose(out.value).all().item()
assert graph_out.isclose(out).all().item()

0 comments on commit 7b1f46f

Please sign in to comment.