hls4ml.backends.vitis.passes package
Submodules
hls4ml.backends.vitis.passes.feature_check module
- class hls4ml.backends.vitis.passes.feature_check.ValidateConvImplementation
Bases:
OptimizerPass
- match(node)
Predicate to match on a given node.
- Parameters:
node (Layer) – Node in the model graph to try matching the optimizer on.
- transform(model, node)
Transformation to apply if matching was successful.
Transform should return a boolean value indicating if the model graph was altered (by adding/removing nodes).
- Parameters:
model (ModelGraph) – Model to optimize
node (Layer) – The matched node in the model graph.
- class hls4ml.backends.vitis.passes.feature_check.ValidateResourceStrategy
Bases:
OptimizerPass
- match(node)
Predicate to match on a given node.
- Parameters:
node (Layer) – Node in the model graph to try matching the optimizer on.
- transform(model, node)
Transformation to apply if matching was successful.
Transform should return a boolean value indicating if the model graph was altered (by adding/removing nodes).
- Parameters:
model (ModelGraph) – Model to optimize
node (Layer) – The matched node in the model graph.
- class hls4ml.backends.vitis.passes.feature_check.ValidateResourceUnrolledStrategy
Bases:
OptimizerPass
- match(node)
Predicate to match on a given node.
- Parameters:
node (Layer) – Node in the model graph to try matching the optimizer on.
- transform(model, node)
Transformation to apply if matching was successful.
Transform should return a boolean value indicating if the model graph was altered (by adding/removing nodes).
- Parameters:
model (ModelGraph) – Model to optimize
node (Layer) – The matched node in the model graph.
hls4ml.backends.vitis.passes.fifo_depth_optimization module
- class hls4ml.backends.vitis.passes.fifo_depth_optimization.FifoDepthOptimization
Bases:
ConfigurableOptimizerPass
,ModelOptimizerPass
- transform(model)
Perform FIFO depth optimization between the FIFOs of all layers to reduce resource utilization as the initial FIFOs set by hls4ml might be larger than required. At the end of the optimization the FIFOs will have the largest depths achieved during co-simulation without causing any deadlocks between the layers (producer-consumer), thus no additional delays between the layers. In some cases, this optimization might lead to bigger FIFOs than initially set by the hls4ml tool in order to prevent deadlocks.
- Parameters:
model (ModelGraph) – The model to which FIFO depth optimization is applied.
- Raises:
ValueError – If the FIFO depth for profiling provided by the user is not a non-negative integer.
RuntimeError – If the IO type is not set to “io_stream”.
- Returns:
The execution state of the Optimizer Pass
- Return type:
bool
- hls4ml.backends.vitis.passes.fifo_depth_optimization.execute_cosim_to_profile_fifos(model)
Execute a co-simulation with a test-bench that calls the top function to properly profile the max FIFO depths. Note that the top function needs to execute least twice, so user-provided input must have at least two samples.
- Parameters:
model (ModelGraph) – The model to which FIFO depth optimization is applied.
- hls4ml.backends.vitis.passes.fifo_depth_optimization.generate_depths_file(model, initial_fifo_depths, optimized_fifo_depths)
Generate a json file with the names of the FIFOs, the initial depths set by hls4ml and their optimized depths, for post-processing. The json file is not used by the rest of the pipeline, it is only produced for the user.
- Parameters:
model (ModelGraph) – The model to which FIFO depth optimization is applied.
initial_fifo_depths (Dict[str, int]) – A dictionary that contains the FIFO names as keys and the initial
values. (depths as)
optimized_fifo_depths (Dict[str, int]) – A dictionary that contains the FIFO names as keys and the optimized
values.
- hls4ml.backends.vitis.passes.fifo_depth_optimization.get_vitis_optimized_fifo_depths(model)
Parse the files generated by the co-simulation to retrieve the optimized depths for the FIFOs. Attention, only the FIFOs between the layers are profiled!
- Parameters:
model (ModelGraph) – The model to which FIFO depth optimization is applied.
- Returns:
A dictionary that contains the FIFO names as keys and the optimized depths as values.
- Return type:
Dict[str, int]
- hls4ml.backends.vitis.passes.fifo_depth_optimization.initialize_large_fifos(model, profiling_fifo_depth)
Set all FIFO depths equal to a large value so that they can be profiled.
- Parameters:
model (ModelGraph) – The model to which FIFO depth optimization is applied.
profiling_fifo_depth (int) – A large non-negative integer, must be larger than the max expected depth of the FIFOs.
- Returns:
A dictionary containing FIFO names as keys and their initial depths as values is returned for comparison with the optimized depths.
- Return type:
Dict[str, int]
- hls4ml.backends.vitis.passes.fifo_depth_optimization.set_optimized_fifo_depths(model, optimized_fifo_depths)
Set the new optimized FIFO depths.
- Parameters:
model (ModelGraph) – The model to which FIFO depth optimization is applied.
optimized_fifo_depths (Dict[str, int]) – A dictionary that contains the FIFO names as keys and the optimized
values. (depths as)