hls4ml.templates package

Submodules

hls4ml.templates.templates module

class hls4ml.templates.templates.Backend(name)

Bases: object

get_config_template(kind)
get_function_template(kind)
get_include_list(kind)
register_source(file_name, source, destination_dir='nnet_utils')
register_templates(name, function_template, config_template, include_list=[])
hls4ml.templates.templates.get_available_backends()
hls4ml.templates.templates.get_backend(name)
hls4ml.templates.templates.get_supported_boards_dict()
hls4ml.templates.templates.register_backend(name, backend_cls)

hls4ml.templates.vivado_accelerator_config module

class hls4ml.templates.vivado_accelerator_config.VivadoAcceleratorConfig(config, model_inputs, model_outputs)

Bases: object

get_board()
get_board_info(board=None)
get_corrected_types()
get_driver()
get_driver_file()
get_driver_path()
get_input_type()
get_interface()
get_io_bitwidth()
get_output_type()
get_part()
get_tcl_file_path()

hls4ml.templates.vivado_accelerator_template module

class hls4ml.templates.vivado_accelerator_template.VivadoAcceleratorBackend

Bases: hls4ml.templates.vivado_template.VivadoBackend

create_initial_config(board='pynq-z2', part=None, clock_period=5, io_type='io_parallel', interface='axi_stream', driver='python', input_type='float', output_type='float')

Create initial accelerator config with default parameters :param device: one of the keys defined in supported_boards.json :param clock_period: clock period passed to hls project :param io_type: io_parallel or io_stream :param interface: axi_stream: generate hardware designs and drivers which exploit axi stream channels.

axi_master: generate hardware designs and drivers which exploit axi master channels. axi_lite : generate hardware designs and drivers which exploit axi lite channels. (Don’t use it to exchange large amount of data)

Parameters
  • driverpython: generates the python driver to use the accelerator in the PYNQ stack. c: generates the c driver to use the accelerator bare-metal.

  • input_type – the wrapper input precision. Can be float or an ap_type. Note: VivadoAcceleratorBackend will round the number of bits used to the next power-of-2 value.

  • output_type – the wrapper output precision. Can be float or an ap_type. Note: VivadoAcceleratorBackend will round the number of bits used to the next power-of-2 value.

Returns

populated config

make_bitfile()

hls4ml.templates.vivado_template module

class hls4ml.templates.vivado_template.VivadoBackend(name='Vivado')

Bases: hls4ml.templates.templates.Backend

compute_conv1d_instructions(in_W, in_C, kernel_size=3, stride=1, pad=0)
compute_conv2d_instructions(in_H, in_W, in_C, kernel_size=3, stride=1, pad=0)
convert_precision_string(precision)

Convert a precision string (e.g. “ap_fixed<16,6>” to the internal IntegerPrecisionTypes etc)

create_initial_config(part='xcku115-flvb2104-2-i', board=None, clock_period=5, io_type='io_parallel')
get_closest_reuse_factor(valid_rf, chosen_rf)

Returns closest value to chosen_rf. valid_rf is sorted (obtained from get_valid_reuse_factors()) If two numbers are equally close, return the smallest number.

get_valid_reuse_factors(layer)
product_type(data_T, weight_T)

Helper function to determine which product implementation to use during inference

set_closest_reuse_factor(layer)
set_target_reuse_factor(layer)

Module contents