hls4ml.writer package
Submodules
hls4ml.writer.catapult_writer module
- class hls4ml.writer.catapult_writer.CatapultWriter
Bases:
Writer
- print_array_to_cpp(var, odir, write_txt_file=True)
Write a weights array to C++ header files.
- Parameters:
var (WeightVariable) – Weight to write
odir (str) – Output directory
write_txt_file (bool, optional) – Write txt files in addition to .h files. Defaults to True.
- write_bridge(model)
Write the Python-C++ bridge (myproject_bridge.cpp)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_build_script(model)
Write the TCL/Shell build scripts (build_prj.tcl, build_lib.sh)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_defines(model)
Write the C++ type definitions file (defines.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_generated_code(model)
Write the generated code (nnet_code_gen.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_hls(model)
- write_nnet_utils(model)
Copy the nnet_utils, AP types headers and any custom source to the project output directory
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_output_dir(model)
Write the base output directory
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_parameters(model)
Write the C++ layer config file (parameters.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_cpp(model)
Write the main architecture source file (myproject.cpp)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_header(model)
Write the main architecture header file (myproject.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_tar(model)
Write the generated project as a .tar.gz archive
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_test_bench(model)
Write the testbench files (myproject_test.cpp and input/output .dat files)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_weights(model)
Write the weights into header files
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_yml(model)
Write the config to the YAML file
- Parameters:
model (ModelGraph) – the hls4ml model.
hls4ml.writer.oneapi_writer module
- class hls4ml.writer.oneapi_writer.OneAPIWriter
Bases:
Writer
- get_max_reuse_factor(model)
- print_array_to_cpp(var, layer, odir)
Write a weights array to C++ header files.
- Parameters:
var (WeightVariable) – Weight to write
layer (Layer) – Instance of the layer to which the weights belong
odir (str) – Output directory
- write_activation_tables(model)
Write the lookup tables for activation functions
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_bridge(model)
Write the Python-C++ bridge (myproject_bridge.cpp)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_build_script(model)
Write the build scripts (Makefile, build_lib.sh)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_defines(model)
Write the C++ type definitions file (defines.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_hls(model)
- write_nnet_utils(model)
Copy the nnet_utils, AP types headers and any custom source to the project output directory
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_parameters(model)
Write the C++ layer config file (parameters.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_cpp(model)
Write the main architecture source file (myproject.cpp)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_dir(model)
Write the base project directory
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_header(model)
Write the main architecture header file (myproject.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_tar(model)
Write the generated project as a .tar.gz archive
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_test_bench(model)
Write the testbench
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_weights(model)
Write the weights into header files
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_yml(model)
Write the config to the YAML file
- Parameters:
model (ModelGraph) – the hls4ml model.
hls4ml.writer.quartus_writer module
- class hls4ml.writer.quartus_writer.QuartusWriter
Bases:
Writer
- get_max_reuse_factor(model)
- next_pow2(x)
- print_array_to_cpp(var, layer, odir)
Write a weights array to C++ header files.
- Parameters:
var (WeightVariable) – Weight to write
layer (Layer) – Instance of the layer to which the weights belong
odir (str) – Output directory
- write_activation_tables(model)
Write the lookup tables for activation functions
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_bridge(model)
Write the Python-C++ bridge (myproject_bridge.cpp)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_build_script(model)
Write the build scripts (Makefile, build_lib.sh)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_defines(model)
Write the C++ type definitions file (defines.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_hls(model)
- write_nnet_utils(model)
Copy the nnet_utils, AP types headers and any custom source to the project output directory
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_parameters(model)
Write the C++ layer config file (parameters.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_cpp(model)
Write the main architecture source file (myproject.cpp)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_dir(model)
Write the base project directory
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_header(model)
Write the main architecture header file (myproject.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_tar(model)
Write the generated project as a .tar.gz archive
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_test_bench(model)
Write the testbench
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_testbench_parallel(model)
Write the testbench file for io_parallel (myproject_test.cpp and input/output .dat files)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_testbench_stream(model)
Write the testbench file for io_stream (myproject_test.cpp and input/output .dat files)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_weights(model)
Write the weights into header files
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_yml(model)
Write the config to the YAML file
- Parameters:
model (ModelGraph) – the hls4ml model.
hls4ml.writer.symbolic_writer module
- class hls4ml.writer.symbolic_writer.SymbolicExpressionWriter
Bases:
VivadoWriter
- write_build_script(model)
Write the TCL/Shell build scripts (project.tcl, build_prj.tcl, vivado_synth.tcl, build_lib.sh)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_hls(model)
- write_nnet_utils(model)
Copy the nnet_utils, AP types headers and any custom source to the project output directory
- Parameters:
model (ModelGraph) – the hls4ml model.
hls4ml.writer.vitis_writer module
- class hls4ml.writer.vitis_writer.VitisWriter
Bases:
VivadoWriter
- write_hls(model)
Write the HLS project. Calls the steps from VivadoWriter, adapted for Vitis
- write_nnet_utils_overrides(model)
hls4ml.writer.vivado_accelerator_writer module
- class hls4ml.writer.vivado_accelerator_writer.VivadoAcceleratorWriter
Bases:
VivadoWriter
- modify_build_script(model)
Modify the build_prj.tcl and build_lib.sh scripts to add the extra wrapper files and set the top function
- write_axi_wrapper(model)
Write a top level HLS C++ file to wrap the hls4ml project with AXI interfaces :param model: The ModelGraph to write the wrapper for
- write_board_script(model)
Write the tcl scripts and kernel sources to create a Vivado IPI project for the VivadoAccelerator
- write_driver(model)
- write_hls(model)
Write the HLS project. Calls the VivadoBackend writer, and extra steps for VivadoAccelerator/AXI interface
- write_new_tar(model)
- write_wrapper_test(model)
hls4ml.writer.vivado_writer module
- class hls4ml.writer.vivado_writer.VivadoWriter
Bases:
Writer
- print_array_to_cpp(var, odir, namespace=None, write_txt_file=True)
Write a weights array to C++ header files.
- Parameters:
var (WeightVariable) – Weight to write
odir (str) – Output directory
namespace (str, optional) – Writes a namespace for the weights to avoid clashes with global variables.
write_txt_file (bool, optional) – Write txt files in addition to .h files. Defaults to True.
- write_bridge(model)
Write the Python-C++ bridge (myproject_bridge.cpp)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_build_script(model)
Write the TCL/Shell build scripts (project.tcl, build_prj.tcl, vivado_synth.tcl, build_lib.sh)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_defines(model)
Write the C++ type definitions file (defines.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_generated_code(model)
Write the generated code (nnet_code_gen.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_hls(model)
- write_nnet_utils(model)
Copy the nnet_utils, AP types headers and any custom source to the project output directory
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_parameters(model)
Write the C++ layer config file (parameters.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_cpp(model)
Write the main architecture source file (myproject.cpp)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_dir(model)
Write the base project directory
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_project_header(model)
Write the main architecture header file (myproject.h)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_tar(model)
Write the generated project as a .tar.gz archive
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_test_bench(model)
Write the testbench files (myproject_test.cpp and input/output .dat files)
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_weights(model)
Write the weights into header files
- Parameters:
model (ModelGraph) – the hls4ml model.
- write_yml(model)
Write the config to the YAML file
- Parameters:
model (ModelGraph) – the hls4ml model.
hls4ml.writer.writers module
- hls4ml.writer.writers.get_writer(name)
- hls4ml.writer.writers.register_writer(name, writer_cls)