Skip to content

Commit 8f1f709

Browse files
jmitrevsvloncar
authored andcommitted
Update documentation text; fix spelling error in docstring
1 parent 856e778 commit 8f1f709

File tree

5 files changed

+33
-25
lines changed

5 files changed

+33
-25
lines changed

docs/details.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
======================
2-
Backends and I/O Types
3-
======================
1+
================
2+
Software Details
3+
================
44

5-
Backends
6-
--------
5+
Frontends and Backends
6+
----------------------
77

8-
``hls4ml`` supports the concept of a *backend* that determines the target HLS language.
9-
Currently, Vivado HLS, Intel HLS, and Vitis HLS (experimental) are supported.
8+
In ``hls4ml`` there is a a concept of a *frontend* to parse the input NN into an internal model graph, and a *backend* that controls
9+
what type of output is produced from the graph. Frontends and backends can be independently chosen. Examples of frontends are the
10+
parsers for Keras or ONNX, and examples of backends are Vivado HLS, Intel HLS, and Vitis HLS. See :ref:`Status and Features` for the
11+
currently supported frontends and backends.
1012

1113
I/O Types
1214
---------

docs/flows.rst

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Optimizer Passes and Flows
33
==========================
44

5+
Internal Structure
6+
------------------
7+
58
The ``hls4ml`` library will parse models from Keras, PyTorch or ONNX into an internal execution graph. This model graph is represented with the
69
:py:class:`~hls4ml.model.graph.ModelGraph` class. The nodes in this graph, corresponding to the layer and operations of the input model are represented
710
by classes derived from the :py:class:`~hls4ml.model.layers.Layer` base class.
@@ -13,15 +16,17 @@ Layers can define expected attributes and can be verified for correctness, or to
1316
Optimizer passes
1417
----------------
1518

16-
To reach a state from which the code can be generated, internal model graph will undergo a series of optimizations (transformations), dubbed *optimization passes*.
17-
All transformations of the model and any modification to any layer's attributes must be implemented through an optimization pass. All optimizer passes derive from
18-
the :py:class:`~hls4ml.model.optimizer.optimizer.OptimizerPass` class. Optimizer passes are applied at the level of nodes/layers, however a special class
19-
:py:class:`~hls4ml.model.optimizer.optimizer.ModelOptimizerPass` exists that is applied on the full model. Subclasses of
20-
:py:class:`~hls4ml.model.optimizer.optimizer.OptimizerPass` must provide a criteria in ``match`` function that, if satisfied, will perform the transformation from
21-
``transform`` function. The boolean return value of ``transform`` indicates if the optimizer pass made changes to the model graph, requiring running the optimizers again.
22-
Example of an optimizer pass that runs on the full model, is :py:class:`~hls4ml.model.optimizer.passes.stamp.MakeStamp`, while an example of the layer optimizer is
23-
:py:class:`~hls4ml.model.optimizer.passes.fuse_biasadd` class that adds a bias to a :py:class:`~hls4ml.model.layers.Dense`,
24-
:py:class:`~hls4ml.model.layers.Conv1D`, or :py:class:`~hls4ml.model.layers.Conv2D` layer.
19+
To reach a state from which the code can be generated, the internal model graph undergoes a series of optimizations (transformations), dubbed
20+
*optimization passes*. All transformations of the model and any modification to any layer's attributes must be implemented through an optimization
21+
pass. All optimizer passes derive from the :py:class:`~hls4ml.model.optimizer.optimizer.OptimizerPass` class. Optimizer passes are usually applied to
22+
nodes/layers; however, a special class :py:class:`~hls4ml.model.optimizer.optimizer.ModelOptimizerPass` exists that is applied on the full model. An
23+
example of a layer optimizer is :py:class:`~hls4ml.model.optimizer.passes.fuse_biasadd`, which adds a bias to a
24+
:py:class:`~hls4ml.model.layers.Dense`, :py:class:`~hls4ml.model.layers.Conv1D`, or :py:class:`~hls4ml.model.layers.Conv2D` layer, while an example of
25+
an optimizer pass that runs on the full model is :py:class:`~hls4ml.model.optimizer.passes.stamp.MakeStamp`, which creates a unique number (stamp).
26+
27+
Subclasses of :py:class:`~hls4ml.model.optimizer.optimizer.OptimizerPass` must provide a criteria in ``match`` function that, if satisfied, will
28+
perform the transformation from ``transform`` function. The boolean return value of ``transform`` indicates if the optimizer pass made changes to the
29+
model graph that may require running the optimizers again. In that case, optimizers in a flow are run again.
2530

2631
Optimizers can be general, independent of the backend, in which case they are located in :py:mod:`hls4ml.model.optimizer.passes`, or they may be backend-specific,
2732
in which case they are located in a folder dependent on the backend, e.g., :py:mod:`hls4ml.backends.vivado.passes` or
@@ -44,10 +49,11 @@ New optimizers can be registered with the :py:func:`~hls4ml.model.optimizer.opti
4449

4550
Flows
4651
-----
47-
A :py:class:`~hls4ml.model.flow.flow.Flow` is an ordered set of optimizers that represent a single stage in the conversion process. The optimizers from a flow are applied
48-
until they no longer make changes to the model graph after which the next flow (stage) can start. Flows may depend on other flows being applied before them,
49-
ensuring the model graph is in a desired state before a flow starts. The function :py:func:`~hls4ml.model.flow.flow.register_flow` is used to register a new flow. Flows
50-
are applied on a model graph with :py:func:`~hls4ml.model.graph.ModelGraph.apply_flow`.
52+
A :py:class:`~hls4ml.model.flow.flow.Flow` is an ordered set of optimizers that represent a single stage in the conversion process. The optimizers
53+
from a flow are applied in sequence until they no longer make changes to the model graph (controlled by the ``transform`` return value), after which
54+
the next flow (stage) can start. Flows may require that other flows are applied before them, ensuring the model graph is in a desired state before a
55+
flow starts. The function :py:func:`~hls4ml.model.flow.flow.register_flow` is used to register a new flow. Flows are applied on a model graph with
56+
:py:func:`~hls4ml.model.graph.ModelGraph.apply_flow`.
5157

5258
There are common model-level flows that can run regardless of the backend, and there are backend-specific flows.
5359
The `convert and optimize <https://github.com/fastmachinelearning/hls4ml/blob/7c0a065935904f50bd7e4c547f85354b36276092/hls4ml/model/optimizer/__init__.py#L14-L20>`_

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
status
77
setup
88
release_notes
9-
command
109
details
1110
flows
11+
command
1212
reference
1313

1414
.. toctree::

docs/status.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Status and Features
33
===================
44

55
Status
6-
========
6+
======
77

88
The latest version (built from ``main``) is |version|.
99
The stable version (released on PyPI) is |release|.
@@ -49,14 +49,14 @@ A summary of the on-going status of the ``hls4ml`` tool is in the table below.
4949
* - MLP
5050
- ``supported``
5151
- ``limited``
52-
- ``supported``
52+
- ``in development``
5353
- ``supported``
5454
- ``supported``
5555
- ``experimental``
5656
* - CNN
5757
- ``supported``
5858
- ``limited``
59-
- ``supported``
59+
- ``in development``
6060
- ``supported``
6161
- ``supported``
6262
- ``experimental``

hls4ml/model/optimizer/optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def optimize_model(model, passes):
301301
passes (list): List of passes to apply.
302302
303303
Returns:
304-
set: The set of applied passes (the pases that matched the predicate).
304+
set: The set of applied passes (the passes that matched the predicate).
305305
"""
306306
optimizers = {opt_pass: get_optimizer(opt_pass) for opt_pass in passes}
307307
applied_passes = set()

0 commit comments

Comments
 (0)