-
Notifications
You must be signed in to change notification settings - Fork 554
VivadoAccelerator complete build test #1451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
marco66colombo
wants to merge
8
commits into
fastmachinelearning:main
from
marco66colombo:vivadoaccelerator-full-synth
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cd45b22
test VivadoAccelerator synth
marco66colombo e915de1
add VivadoAccelerator test baseline
marco66colombo 72d3414
add: export vivado command in CI
marco66colombo 1bf3236
assign vivadoaccelerator test to a signle job
marco66colombo 9e35fff
add board and part in test_keras_api_vivadoacc
marco66colombo dee7f60
fix: update vivado board and part
marco66colombo 791d062
update baselines
marco66colombo 0048498
move VivadoAccelerator baselines files
marco66colombo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...Accelerator/2020.1/test_keras_api_vivadoacc_test_dense_io_parallel-VivadoAccelerator.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "CSynthesisReport": { | ||
| "TargetClockPeriod": "5.00", | ||
| "EstimatedClockPeriod": "4.349", | ||
| "BestLatency": "11", | ||
| "WorstLatency": "11", | ||
| "IntervalMin": "12", | ||
| "IntervalMax": "12", | ||
| "BRAM_18K": "1", | ||
| "DSP": "2", | ||
| "FF": "622", | ||
| "LUT": "1947", | ||
| "URAM": "0", | ||
| "AvailableBRAM_18K": "1824", | ||
| "AvailableDSP": "2520", | ||
| "AvailableFF": "548160", | ||
| "AvailableLUT": "274080", | ||
| "AvailableURAM": "0" | ||
| }, | ||
| "VivadoSynthReport": { | ||
| "LUT": "47", | ||
| "FF": "35", | ||
| "BRAM_18K": "0.5", | ||
| "DSP48E": "2" | ||
| }, | ||
| "TimingReport": { | ||
| "WNS": 3.988, | ||
| "TNS": 0.0, | ||
| "WHS": 0.01, | ||
| "THS": 0.0, | ||
| "WPWS": 3.5, | ||
| "TPWS": 0.0 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| from pathlib import Path | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
| import tensorflow as tf | ||
| from synthesis_helpers import run_synthesis_test | ||
| from tensorflow.keras.layers import ( | ||
| Activation, | ||
| Dense, | ||
| ) | ||
|
|
||
| import hls4ml | ||
|
|
||
| test_root_path = Path(__file__).parent | ||
| VIVADOACC_BOARD = 'zcu102' | ||
| VIVADOACC_PART = 'xczu9eg-ffvb1156-2-e' | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('backend', ['VivadoAccelerator']) | ||
| @pytest.mark.parametrize('io_type', ['io_parallel']) | ||
| def test_dense(test_case_id, backend, io_type, synthesis_config): | ||
| model = tf.keras.models.Sequential() | ||
| model.add( | ||
| Dense( | ||
| 2, | ||
| input_shape=(1,), | ||
| name='Dense', | ||
| use_bias=True, | ||
| kernel_initializer=tf.keras.initializers.RandomUniform(minval=1, maxval=10), | ||
| bias_initializer='zeros', | ||
| kernel_regularizer=None, | ||
| bias_regularizer=None, | ||
| activity_regularizer=None, | ||
| kernel_constraint=None, | ||
| bias_constraint=None, | ||
| ) | ||
| ) | ||
| model.add(Activation(activation='elu', name='Activation')) | ||
| model.compile(optimizer='adam', loss='mse') | ||
|
|
||
| X_input = np.random.rand(100, 1) | ||
|
|
||
| keras_prediction = model.predict(X_input) | ||
|
|
||
| config = hls4ml.utils.config_from_keras_model(model) | ||
| output_dir = str(test_root_path / test_case_id) | ||
| baseline_file_name = f'{test_case_id}.json' | ||
|
|
||
| hls_model = hls4ml.converters.convert_from_keras_model( | ||
| model, | ||
| hls_config=config, | ||
| output_dir=output_dir, | ||
| backend=backend, | ||
| io_type=io_type, | ||
| board=VIVADOACC_BOARD, | ||
| part=VIVADOACC_PART, | ||
| ) | ||
|
|
||
| hls_model.compile() | ||
|
|
||
| hls_prediction = hls_model.predict(X_input) | ||
|
|
||
| np.testing.assert_allclose(hls_prediction, keras_prediction, rtol=1e-2, atol=0.01) | ||
|
|
||
| assert len(model.layers) + 1 == len(hls_model.get_layers()) | ||
| assert list(hls_model.get_layers())[0].attributes['class_name'] == 'InputLayer' | ||
| assert list(hls_model.get_layers())[1].attributes['class_name'] == model.layers[0]._name | ||
| assert list(hls_model.get_layers())[2].attributes['class_name'] == 'ELU' | ||
| assert list(hls_model.get_layers())[0].attributes['input_shape'] == list(model.layers[0].input_shape[1:]) | ||
| assert list(hls_model.get_layers())[1].attributes['n_in'] == model.layers[0].input_shape[1:][0] | ||
| assert list(hls_model.get_layers())[1].attributes['n_out'] == model.layers[0].output_shape[1:][0] | ||
| assert list(hls_model.get_layers())[2].attributes['activation'] == str(model.layers[1].activation).split()[1] | ||
| assert list(hls_model.get_layers())[1].attributes['activation'] == str(model.layers[0].activation).split()[1] | ||
|
|
||
| run_synthesis_test( | ||
| config=synthesis_config, | ||
| hls_model=hls_model, | ||
| baseline_file_name=baseline_file_name, | ||
| backend=backend, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd set it to
True