Skip to content

Commit

Permalink
reduce cover factor to ensure overflow in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
calad0i committed Apr 26, 2024
1 parent 2ba9ded commit bb4f5ec
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
7 changes: 5 additions & 2 deletions test/test_syn_hlayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def custom_fn(x):
@pytest.mark.parametrize("N", [1000])
@pytest.mark.parametrize("rnd_strategy", ['auto', 'standard_round', 'floor'])
@pytest.mark.parametrize("io_type", ['io_parallel', 'io_stream'])
@pytest.mark.parametrize("cover_factor", [0.5, 1.0])
@pytest.mark.parametrize("cover_factor", [0.25, 1.0])
@pytest.mark.parametrize("aggressive", [True, False])
@pytest.mark.parametrize("backend", ['vivado', 'vitis'])
@pytest.mark.parametrize("seed", [42])
Expand All @@ -103,7 +103,10 @@ def test_syn_hlayers(layer, N: int, rnd_strategy: str, io_type: str, cover_facto
data = get_data(N, 1, 1, seed)

test_grad = N > 100
cond = None if 'softmax' not in layer else softmax_cond
cond = None
if 'softmax' in layer:
cond = softmax_cond
cover_factor = max(cover_factor, 0.5) # Softmax table size is sensitive to range

skip_sl_test = 'custom' in layer
run_model_test(model,
Expand Down
2 changes: 1 addition & 1 deletion test/test_syn_large.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_data(N: int, sigma: float, max_scale: float, seed):
@pytest.mark.parametrize("N", [50000, 10])
@pytest.mark.parametrize("rnd_strategy", ['auto'])
@pytest.mark.parametrize("io_type", ['io_parallel', 'io_stream'])
@pytest.mark.parametrize("cover_factor", [0.49, 1.0])
@pytest.mark.parametrize("cover_factor", [0.25, 1.0])
@pytest.mark.parametrize("aggressive", [True, False])
@pytest.mark.parametrize("backend", ['vivado', 'vitis'])
@pytest.mark.parametrize("seed", [42])
Expand Down
10 changes: 3 additions & 7 deletions test/test_syn_players.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def create_model(layer: str, rnd_strategy: str, io_type: str):
raise Exception(f'Please add test for {layer}')

out = eval(layer)(_inp)
if 'maxpool' in layer.lower():
out = HQuantize()(out)
model = keras.Model(inp, out)

for layer in model.layers:
Expand All @@ -62,12 +64,6 @@ def get_data(N: int, sigma: float, max_scale: float, seed):
return (a1 * a2).astype(np.float32)


def parallel_avg_pool_cond(a, b):
close: np.ndarray = np.abs(a - b) < 1e-2

assert np.all(close), f"Keras-Proxy mismatch for approx avg pool: {np.sum(np.any(~close, axis=tuple(range(1,close.ndim))))} out of {a.shape[0]} samples are very different. Sample: {a[~close].ravel()[:5]} vs {b[~close].ravel()[:5]}"


@pytest.mark.parametrize('layer',
[
"PConcatenate()",
Expand All @@ -89,7 +85,7 @@ def parallel_avg_pool_cond(a, b):
@pytest.mark.parametrize("N", [1000])
@pytest.mark.parametrize("rnd_strategy", ['auto', 'standard_round', 'floor'])
@pytest.mark.parametrize("io_type", ['io_parallel', 'io_stream'])
@pytest.mark.parametrize("cover_factor", [0.5, 1.0])
@pytest.mark.parametrize("cover_factor", [0.25, 1.0])
@pytest.mark.parametrize("aggressive", [True, False])
@pytest.mark.parametrize("backend", ['vivado', 'vitis'])
@pytest.mark.parametrize("seed", [42])
Expand Down
2 changes: 1 addition & 1 deletion test/test_syn_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_data(N: int, sigma: float, max_scale: float, seed):
@pytest.mark.parametrize("N", [50000, 10])
@pytest.mark.parametrize("rnd_strategy", ['auto', 'standard_round', 'floor'])
@pytest.mark.parametrize("io_type", ['io_parallel', 'io_stream'])
@pytest.mark.parametrize("cover_factor", [0.49, 1.0])
@pytest.mark.parametrize("cover_factor", [0.25, 1.0])
@pytest.mark.parametrize("aggressive", [True, False])
@pytest.mark.parametrize("backend", ['vivado', 'vitis'])
@pytest.mark.parametrize("seed", [114514, 42, 1919810])
Expand Down

0 comments on commit bb4f5ec

Please sign in to comment.