Skip to content

Commit 2bfb0ae

Browse files
authored
Uniform test root path (#1435)
* make test_root_path consistent for all the tests * prevent folder name conflicts, make uniform * pre-commit fixes * make sure the test output directories are unique
1 parent 717a6c2 commit 2bfb0ae

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

test/pytest/test_keras_v3_api.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import hls4ml
2828

29-
test_root_path = Path('/tmp/tests')
29+
test_root_path = Path(__file__).parent
3030

3131

3232
@pytest.mark.parametrize('backend', ['Vivado', 'Vitis', 'Quartus', 'oneAPI', 'Catapult'])
@@ -57,7 +57,7 @@ def test_dense(backend, io_type):
5757
keras_prediction = model.predict(X_input, verbose=0) # type: ignore
5858

5959
config = hls4ml.utils.config_from_keras_model(model)
60-
output_dir = str(test_root_path / f'hls4mlprj_keras_api_dense_{backend}_{io_type}')
60+
output_dir = str(test_root_path / f'hls4mlprj_keras_v3_api_dense_{backend}_{io_type}')
6161

6262
hls_model = hls4ml.converters.convert_from_keras_model(
6363
model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type
@@ -105,7 +105,7 @@ def test_activations(activation_function, backend, io_type):
105105
X_input = np.random.rand(1000, 1)
106106
keras_prediction = model.predict(X_input, verbose=0) # type: ignore
107107
config = hls4ml.utils.config_from_keras_model(model)
108-
output_dir = str(test_root_path / f'hls4mlprj_keras_api_activations_{activation_function.name}_{backend}_{io_type}')
108+
output_dir = str(test_root_path / f'hls4mlprj_keras_v3_api_activations_{activation_function.name}_{backend}_{io_type}')
109109
hls_model = hls4ml.converters.convert_from_keras_model(
110110
model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type
111111
)
@@ -151,7 +151,7 @@ def test_conv1d(padds, backend, io_type):
151151
keras_prediction = model.predict(X_input, verbose=0) # type: ignore
152152

153153
config = hls4ml.utils.config_from_keras_model(model)
154-
output_dir = str(test_root_path / f'hls4mlprj_keras_api_conv1d_{padds}_{backend}_{io_type}')
154+
output_dir = str(test_root_path / f'hls4mlprj_keras_v3_api_conv1d_{padds}_{backend}_{io_type}')
155155
hls_model = hls4ml.converters.convert_from_keras_model(
156156
model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type
157157
)
@@ -228,7 +228,7 @@ def test_conv2d(chans, padds, backend, io_type):
228228
keras_prediction = model.predict(X_input)
229229

230230
config = hls4ml.utils.config_from_keras_model(model)
231-
output_dir = str(test_root_path / f'hls4ml_project_keras_api_conv2d_{backend}_{chans}_{padds}_{io_type}')
231+
output_dir = str(test_root_path / f'hls4mlprj_keras_v3_api_conv2d_{backend}_{chans}_{padds}_{io_type}')
232232
hls_model = hls4ml.converters.convert_from_keras_model(
233233
model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type
234234
)
@@ -311,7 +311,7 @@ def test_depthwise2d(backend, io_type):
311311
config = hls4ml.utils.config_from_keras_model(
312312
model, granularity='name', default_precision='fixed<32,12>', backend=backend
313313
)
314-
output_dir = str(test_root_path / f'hls4mlprj_keras_api_depthwiseconv2d_{backend}_{io_type}')
314+
output_dir = str(test_root_path / f'hls4mlprj_keras_v3_api_depthwiseconv2d_{backend}_{io_type}')
315315
hls_model = hls4ml.converters.convert_from_keras_model(
316316
model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type
317317
)
@@ -336,7 +336,7 @@ def test_depthwise1d(backend, io_type):
336336
model.compile()
337337

338338
config = hls4ml.utils.config_from_keras_model(model, granularity='name', backend=backend)
339-
output_dir = str(test_root_path / f'hls4mlprj_keras_api_depthwiseconv1d_{backend}_{io_type}')
339+
output_dir = str(test_root_path / f'hls4mlprj_keras_v3_api_depthwiseconv1d_{backend}_{io_type}')
340340
hls_model = hls4ml.converters.convert_from_keras_model(
341341
model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type
342342
)
@@ -368,7 +368,8 @@ def test_pooling(pooling, padds, chans, backend):
368368

369369
hls_cfg = hls4ml.utils.config_from_keras_model(keras_model)
370370
output_dir = str(
371-
test_root_path / f'hls4mlprj_keras_api_pooling_{pooling.__name__}_channels_{chans}_padds_{padds}_backend_{backend}'
371+
test_root_path
372+
/ f'hls4mlprj_keras_v3_api_pooling_{pooling.__name__}_channels_{chans}_padds_{padds}_backend_{backend}'
372373
)
373374
hls_model = hls4ml.converters.convert_from_keras_model(
374375
keras_model, hls_config=hls_cfg, output_dir=output_dir, backend=backend
@@ -497,7 +498,7 @@ def test_reused_layer(backend, io_type):
497498
_ = model([inp1, inp1])
498499

499500
hls_config = {'Model': {'Precision': 'ap_fixed<32,8>', 'ReuseFactor': 1}}
500-
output_dir = str(test_root_path / f'hls4mlprj_keras_api_conv1d_{backend}_{io_type}')
501+
output_dir = str(test_root_path / f'hls4mlprj_keras_v3_api_reused_{backend}_{io_type}')
501502

502503
model_hls = hls4ml.converters.convert_from_keras_model(
503504
model, backend=backend, io_type=io_type, hls_config=hls_config, output_dir=output_dir

0 commit comments

Comments
 (0)