Skip to content

Commit

Permalink
atol to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
evelynmitchell committed Dec 30, 2023
1 parent b618c39 commit 4fc6fb9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/utils/test_absmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ def test_absmax_quantize_default_bits():
quant, dequant = absmax_quantize(x)
assert quant.dtype == torch.int8
assert dequant.dtype == torch.float32
assert torch.allclose(dequant, x, atol=1e-5)
assert torch.allclose(dequant, x, atol=1e-4)

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check warning

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.


def test_absmax_quantize_custom_bits():
x = torch.randn(128)
quant, dequant = absmax_quantize(x, bits=16)
assert quant.dtype == torch.int8
assert dequant.dtype == torch.float32
assert torch.allclose(dequant, x, atol=1e-5)
assert torch.allclose(dequant, x, atol=1e-4)

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check warning

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.


def test_absmax_quantize_zero_tensor():
Expand All @@ -29,11 +29,11 @@ def test_absmax_quantize_positive_tensor():
x = torch.ones(128)
quant, dequant = absmax_quantize(x)
assert torch.all(quant == 2**7 - 1)
assert torch.allclose(dequant, x, atol=1e-5)
assert torch.allclose(dequant, x, atol=1e-4)

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check warning

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.


def test_absmax_quantize_negative_tensor():
x = -torch.ones(128)
quant, dequant = absmax_quantize(x)
assert torch.all(quant == -(2**7 - 1))
assert torch.allclose(dequant, x, atol=1e-5)
assert torch.allclose(dequant, x, atol=1e-4)

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check warning

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Warning test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

0 comments on commit 4fc6fb9

Please sign in to comment.