You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/configuration.rst
+35-3Lines changed: 35 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,18 @@ We currently support two ways of setting hls4ml's model configuration. This page
9
9
10
10
.. contents:: \
11
11
12
+
The Python API approach is recommended for most users as there are more utilities to help create the configuration dictionaries.
12
13
13
14
**NOTE:**
14
15
15
16
16
17
*
17
18
One important part of ``hls4ml`` to remember is that the user is responsible for the format of the inputs. There is no automatic formatting or normalization so this must be done in the training.
18
19
19
-
*
20
+
..
21
+
*
20
22
For developers, you might also want to checkout this section: `Detailed configuration in converted hls codes <#detailed-configuration-in-converted-hls-codes>`_.
23
+
*Broken link*
21
24
22
25
----
23
26
@@ -31,11 +34,26 @@ Using hls4ml, you can quickly generate a simple configuration dictionary from a
For more advanced and detailed configuration, you can also set them through the created dictionary. For example, to change the reuse factor:
37
+
This python dictionary can be edited as needed. A more advanced configuration can be generated by, for example:
38
+
39
+
.. code-block:: python
40
+
41
+
import hls4ml
42
+
config = hls4ml.utils.config_from_keras_model(
43
+
model,
44
+
granularity='name',
45
+
default_precision='fixed<16,6>',
46
+
backend='Vitis')
47
+
48
+
This will include per-layer configuration based on the model. Including the backend is recommended because some configation options depend on the backend. Note, the precisions at the
49
+
higher granularites usually default to 'auto', which means that ``hls4ml`` will try to set it automatically. Note that higher granularity settings take precendence
50
+
over model-level settings. See :py:class:`~hls4ml.utils.config.config_from_keras_model` for more information on the various options.
51
+
52
+
One can override specific values before using the configuration:
35
53
36
54
.. code-block:: python
37
55
38
-
config['Model']['ReuseFactor'] =2
56
+
config['LayerName']['fc1']['ReuseFactor'] =2
39
57
40
58
Or to set the precision of a specific layer's weight:
41
59
@@ -45,6 +63,20 @@ Or to set the precision of a specific layer's weight:
45
63
46
64
To better understand how the configuration hierachy works, refer to the next section for more details.
47
65
66
+
Finally, one then uses the configuration to create an hls model:
0 commit comments