hls4ml.backends.vitis.passes package

Submodules

hls4ml.backends.vitis.passes.feature_check module

class hls4ml.backends.vitis.passes.feature_check.ValidateBidirectionalIoType

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.ValidateBidirectionalMergeMode

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.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.

class hls4ml.backends.vitis.passes.feature_check.ValidateStdCppTypes

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

First step of the FIFO depth optimization: set every FIFO to a large depth so that the co-simulation can profile it. The flow then writes the project, runs the co-simulation (FifoDepthOptimizationProfile) and reads the measured depths back (FifoDepthOptimizationPost).

transform(model)

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.fifo_depth_optimization.FifoDepthOptimizationPost

Bases: ModelOptimizerPass

Last step: read the depths measured by the co-simulation and set them on the model. At the end the FIFOs have the largest depths reached during co-simulation without causing any deadlocks between the layers; in some cases this gives bigger FIFOs than the ones initially set by hls4ml.

get_hls_project_path(model)
transform(model)

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.fifo_depth_optimization.FifoDepthOptimizationProfile

Bases: ModelOptimizerPass

Second step: synthesize and co-simulate the project written with the large FIFOs to profile their depths. Note that the top function needs to execute at least twice, so user-provided input must have at least two samples.

transform(model)

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.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, hls_prj_path)

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.

  • hls_prj_path (str) – The HLS solution directory that holds the .autopilot files.

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)

Module contents