hls4ml.utils package

Submodules

hls4ml.utils.config module

hls4ml.utils.config.config_from_keras_model(model, granularity='model', default_precision='ap_fixed<16, 6>', default_reuse_factor=1)
hls4ml.utils.config.create_vivado_config(output_dir='my-hls-test', project_name='myproject', fpga_part='xcku115-flvb2104-2-i', clock_period=5, io_type='io_parallel')

hls4ml.utils.example_models module

hls4ml.utils.example_models.fetch_example_list()
hls4ml.utils.example_models.fetch_example_model(model_name)

Download an example model (and example data & configuration if available) from github repo to working directory, and return the corresponding configuration:

https://github.com/hls-fpga-machine-learning/example-models

Use fetch_example_list() to see all the available models.

Parameters

model_name (-) – string, name of the example model in the repo. Example: fetch_example_model(‘KERAS_3layer.json’)

Returns

  • Dictionary that stores the configuration to the model

hls4ml.utils.plot module

Utilities related to model visualization.

hls4ml.utils.plot.add_edge(dot, src, dst)
hls4ml.utils.plot.check_pydot()

Returns True if PyDot and Graphviz are available.

hls4ml.utils.plot.model_to_dot(model, show_shapes=False, show_layer_names=True, show_precision=False, rankdir='TB', dpi=96, subgraph=False)

Convert a HLS model to dot format.

Parameters
  • model – A HLS model instance.

  • show_shapes – whether to display shape information.

  • show_layer_names – whether to display layer names.

  • show_precision – whether to display precision of layer’s variables.

  • rankdirrankdir argument passed to PyDot, a string specifying the format of the plot: ‘TB’ creates a vertical plot; ‘LR’ creates a horizontal plot.

  • dpi – Dots per inch.

  • subgraph – whether to return a pydot.Cluster instance.

Returns

A pydot.Dot instance representing the HLS model or a pydot.Cluster instance representing nested model if subgraph=True.

Raises

ImportError – if graphviz or pydot are not available.

hls4ml.utils.plot.plot_model(model, to_file='model.png', show_shapes=False, show_layer_names=True, show_precision=False, rankdir='TB', dpi=96)

Converts a HLS model to dot format and save to a file.

Parameters
  • model – A HLS model instance

  • to_file – File name of the plot image.

  • show_shapes – whether to display shape information.

  • show_layer_names – whether to display layer names.

  • show_precision – whether to display precision of layer’s variables.

  • rankdirrankdir argument passed to PyDot, a string specifying the format of the plot: ‘TB’ creates a vertical plot; ‘LR’ creates a horizontal plot.

  • dpi – Dots per inch.

Returns

A Jupyter notebook Image object if Jupyter is installed. This enables in-line display of the model plots in notebooks.

Module contents