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.ValidateFusedIoType
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,ModelOptimizerPassFirst 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:
ModelOptimizerPassLast 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:
ModelOptimizerPassSecond 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
.autopilotfiles.
- 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)
hls4ml.backends.vitis.passes.fuse_dense module
- class hls4ml.backends.vitis.passes.fuse_dense.FoldActivationIntoFused
Bases:
OptimizerPassMove an activation into the fused Dense layer before it and remove the activation layer.
Only done for Dense layers the planner put in a chain; any other layer keeps its activation layer, since its kernel cannot compute the activation. The parameters of the activation are copied to the Dense layer.
- 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.fuse_dense.LayoutFusedDotWeights
Bases:
OptimizerPassTranspose the weights of dot layers into the order their kernel reads them.
hls4ml stores the weight for input i and output j at i * n_out + j, which is what the axpy and plain kernels read: all outputs for one input at a time. The dot kernel reads one output at a time, at j * n_in + i.
- 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.fuse_dense.PlanDenseFusion
Bases:
ModelOptimizerPassGroup consecutive Dense layers into regions and select the kernel each one uses.
It sets three attributes on each layer of a chain:
fused_form- which of the three kernels computes the layer: dot, axpy or plainfused_multipliers- how many multipliers the kernel uses at the same timefused_stream_out- whether the output is written one value at a time, as a stream
A layer with ReuseFactorAsInterval also gets the wait cycles that bring it up to the requested interval, and a layer given fewer multipliers than its reuse factor allows records why, for ValidateDenseFusion to report.
There are three kernels because a Dense layer needs all of its inputs before it can produce any output, so it can pass data one value at a time on one side only.
dotreads an array and writes one value at a time;axpyreads one value at a time and writes an array;plainreads and writes arrays. The layers of a region are given dot, axpy, dot, axpy and so on, so that each dot and the axpy after it can run at the same time, one consuming what the other produces. A region with an odd number of layers starts with a plain layer, so that the region as a whole still begins and ends with an array, which is what the rest of the model expects.- 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.fuse_dense.SubstituteUnfusedStrategy
Bases:
OptimizerPassSwitch layers that asked for the fused strategy but could not be fused to the resource strategy.
These are the layers the planner did not put in a chain: a Dense layer on its own, a Conv1D or a Conv2D. Depthwise convolutions keep the latency strategy.
- 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.fuse_dense.ValidateDenseFusion
Bases:
ModelOptimizerPassCheck what the fusion passes decided, then report what was built.
For each Dense layer that asked for the strategy it checks the reuse factor (an error for 1, a warning for a value the layer cannot reach) or, with ReuseFactorAsInterval, that the requested interval can be reached and is the same for every layer of a region.
The report comes after all checks, so nothing is reported for a conversion that stops with an error. It lists each chain, the layers given fewer multipliers than their reuse factor allows, each layer that asked for the strategy but was not fused, and the pipeline style if the fusion passes changed it. FusedReport: false in the Model section turns it off; warnings and errors are always printed. The backend and io_parallel are checked earlier, by ValidateFusedStrategy and ValidateFusedIoType.
- 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.fused_templates module
- class hls4ml.backends.vitis.passes.fused_templates.DenseFusedConfigTemplate
Bases:
LayerConfigTemplate- format(node)
- class hls4ml.backends.vitis.passes.fused_templates.DenseFusedFunctionTemplate
Bases:
FunctionCallTemplate- format(node)