diff --git a/hls4ml/templates/vitis/nnet_utils/nnet_conv1d_resource.h b/hls4ml/templates/vitis/nnet_utils/nnet_conv1d_resource.h index dd488ace5b..e3e53d1869 100644 --- a/hls4ml/templates/vitis/nnet_utils/nnet_conv1d_resource.h +++ b/hls4ml/templates/vitis/nnet_utils/nnet_conv1d_resource.h @@ -94,7 +94,8 @@ void conv_1d_resource_cl(data_T data[CONFIG_T::in_width * CONFIG_T::n_chan], ResultLoop: for (unsigned i_res = 0; i_res < mult_n_out; i_res++) { #pragma HLS UNROLL - *(res++) = cast(acc[i_pxl][i_res]); + res[i_part * CONFIG_T::n_pixels * mult_n_out + i_pxl * mult_n_out + i_res] = + cast(acc[i_pxl][i_res]); } } } diff --git a/hls4ml/templates/vitis/nnet_utils/nnet_conv2d_resource.h b/hls4ml/templates/vitis/nnet_utils/nnet_conv2d_resource.h index e0d30da34b..e427bd708d 100644 --- a/hls4ml/templates/vitis/nnet_utils/nnet_conv2d_resource.h +++ b/hls4ml/templates/vitis/nnet_utils/nnet_conv2d_resource.h @@ -97,7 +97,8 @@ void conv_2d_resource_cl( ResultLoop: for (unsigned i_res = 0; i_res < mult_n_out; i_res++) { #pragma HLS UNROLL - *(res++) = cast(acc[i_pxl][i_res]); + res[i_part * CONFIG_T::n_pixels * mult_n_out + i_pxl * mult_n_out + i_res] = + cast(acc[i_pxl][i_res]); } } } diff --git a/test/pytest/test_keras_api.py b/test/pytest/test_keras_api.py index af2507e8f7..4bb9f03751 100644 --- a/test/pytest/test_keras_api.py +++ b/test/pytest/test_keras_api.py @@ -119,9 +119,19 @@ def test_activations(activation_function, backend, io_type): @pytest.mark.parametrize('padds', padds_options) -@pytest.mark.parametrize('backend', ['Vivado', 'Vitis', 'Quartus', 'oneAPI']) +@pytest.mark.parametrize( + 'backend,strategy', + [ + ('Vivado', 'Resource'), + ('Vivado', 'Latency'), + ('Vitis', 'Resource'), + ('Vitis', 'Latency'), + ('Quartus', 'Resource'), + ('oneAPI', 'Resource'), + ], +) @pytest.mark.parametrize('io_type', ['io_parallel', 'io_stream']) -def test_conv1d(padds, backend, io_type): +def test_conv1d(padds, backend, strategy, io_type): model = tf.keras.models.Sequential() input_shape = (10, 128, 4) model.add( @@ -144,7 +154,8 @@ def test_conv1d(padds, backend, io_type): keras_prediction = model.predict(X_input) config = hls4ml.utils.config_from_keras_model(model) - output_dir = str(test_root_path / f'hls4mlprj_keras_api_conv1d_{padds}_{backend}_{io_type}') + config['Model']['Strategy'] = strategy + output_dir = str(test_root_path / f'hls4mlprj_keras_api_conv1d_{padds}_{backend}_{strategy}_{io_type}') hls_model = hls4ml.converters.convert_from_keras_model( model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type ) @@ -192,9 +203,19 @@ def test_conv1d(padds, backend, io_type): @pytest.mark.parametrize('chans', chans_options) @pytest.mark.parametrize('padds', padds_options) -@pytest.mark.parametrize('backend', ['Vivado', 'Vitis', 'Quartus', 'oneAPI']) +@pytest.mark.parametrize( + 'backend,strategy', + [ + ('Vivado', 'Resource'), + ('Vivado', 'Latency'), + ('Vitis', 'Resource'), + ('Vitis', 'Latency'), + ('Quartus', 'Resource'), + ('oneAPI', 'Resource'), + ], +) @pytest.mark.parametrize('io_type', ['io_parallel', 'io_stream']) -def test_conv2d(chans, padds, backend, io_type): +def test_conv2d(chans, padds, backend, strategy, io_type): model = tf.keras.models.Sequential() input_shape = (28, 28, 3) model.add( @@ -215,7 +236,8 @@ def test_conv2d(chans, padds, backend, io_type): keras_prediction = model.predict(X_input) config = hls4ml.utils.config_from_keras_model(model) - output_dir = str(test_root_path / f'hls4mlprj_keras_api_conv2d_{backend}_{chans}_{padds}_{io_type}') + config['Model']['Strategy'] = strategy + output_dir = str(test_root_path / f'hls4mlprj_keras_api_conv2d_{backend}_{strategy}_{chans}_{padds}_{io_type}') hls_model = hls4ml.converters.convert_from_keras_model( model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type )