hls4ml.backends.fpga package
Subpackages
Submodules
hls4ml.backends.fpga.fpga_backend module
-
class
hls4ml.backends.fpga.fpga_backend.FPGABackend(name) Bases:
hls4ml.backends.backend.Backend-
compile(model) Compile the generated project that can be linked into Python runtime.
- Parameters
model (ModelGraph) – Model to compile.
- Raises
Exception – If the project failed to compile
- Returns
Returns the name of the compiled library.
- Return type
string
-
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)
-
classmethod
convert_precision_string(precision)
-
create_layer_class(layer_class) Wrap the original layer class into the backend-specific layer class.
Backends should extend base layer classes with new attributes and variables as needed. These new classes are then used within the model.
- Parameters
layer_class (class) – Base class to extend
-
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_layer_mult_size(layer)
-
get_valid_reuse_factors(n_in, n_out)
-
get_writer_flow()
-
product_type(data_T, weight_T) Helper function to determine which product implementation to use during inference
-
set_closest_reuse_factor(layer, n_in, n_out, attribute='reuse_factor')
-
set_target_reuse_factor(layer)
-
write(model) Write the generated project to disk.
This function converts the model to C++ and writes the generated files in the output directory specified in the config.
- Parameters
model (ModelGraph) – Model to write.
-
write_hls(model)
-
hls4ml.backends.fpga.fpga_layers module
-
class
hls4ml.backends.fpga.fpga_layers.BatchNormalizationQuantizedTanh(model, name, attributes, inputs, outputs=None) Bases:
hls4ml.model.layers.LayerMerged Batch Normalization and quantized (binary or ternary) Tanh layer. The mean, variance, beta, gamma parameters are folded into the threshold(s) at which the sign of the input flips after the quantized (binary or ternary) Tanh activation.
-
initialize()
-
set_thresholds(scale, bias, ternary_threshold=0.5)
-
hls4ml.backends.fpga.fpga_types module
-
class
hls4ml.backends.fpga.fpga_types.ACFixedPrecisionDefinition Bases:
hls4ml.backends.fpga.fpga_types.PrecisionDefinition-
definition_cpp()
-
-
class
hls4ml.backends.fpga.fpga_types.ACIntegerPrecisionDefinition Bases:
hls4ml.backends.fpga.fpga_types.PrecisionDefinition-
definition_cpp()
-
-
class
hls4ml.backends.fpga.fpga_types.ACTypeConverter Bases:
hls4ml.backends.fpga.fpga_types.FixedPrecisionConverter
-
class
hls4ml.backends.fpga.fpga_types.APFixedPrecisionDefinition Bases:
hls4ml.backends.fpga.fpga_types.PrecisionDefinition-
definition_cpp()
-
-
class
hls4ml.backends.fpga.fpga_types.APIntegerPrecisionDefinition Bases:
hls4ml.backends.fpga.fpga_types.PrecisionDefinition-
definition_cpp()
-
-
class
hls4ml.backends.fpga.fpga_types.APTypeConverter Bases:
hls4ml.backends.fpga.fpga_types.FixedPrecisionConverter
-
class
hls4ml.backends.fpga.fpga_types.ArrayVariableConverter(type_converter, prefix, definition_cls) Bases:
object-
convert(tensor_var, pragma='partition')
-
-
class
hls4ml.backends.fpga.fpga_types.BramWeightVariableConverter Bases:
object-
classmethod
convert(weight_var)
-
classmethod
-
class
hls4ml.backends.fpga.fpga_types.CompressedTypeConverter Bases:
hls4ml.backends.fpga.fpga_types.TypeDefinition,hls4ml.backends.fpga.fpga_types.TypePrecisionConverter-
convert_precision(precision_converter)
-
definition_cpp()
-
-
class
hls4ml.backends.fpga.fpga_types.ExponentTypeConverter Bases:
hls4ml.backends.fpga.fpga_types.TypeDefinition,hls4ml.backends.fpga.fpga_types.TypePrecisionConverter-
convert_precision(precision_converter)
-
definition_cpp()
-
-
class
hls4ml.backends.fpga.fpga_types.FixedPrecisionConverter(type_map, prefix) Bases:
hls4ml.backends.fpga.fpga_types.PrecisionConverter-
convert(precision_type)
-
-
class
hls4ml.backends.fpga.fpga_types.HLSTypeConverter(precision_converter) Bases:
object-
convert(atype)
-
-
class
hls4ml.backends.fpga.fpga_types.InplaceVariableConverter(type_converter, prefix) Bases:
object-
convert(tensor_var, io_type)
-
-
class
hls4ml.backends.fpga.fpga_types.NamedTypeConverter Bases:
hls4ml.backends.fpga.fpga_types.TypeDefinition,hls4ml.backends.fpga.fpga_types.TypePrecisionConverter-
definition_cpp()
-
-
class
hls4ml.backends.fpga.fpga_types.PackedTypeConverter Bases:
hls4ml.backends.fpga.fpga_types.TypeDefinition,hls4ml.backends.fpga.fpga_types.TypePrecisionConverter-
definition_cpp()
-
-
class
hls4ml.backends.fpga.fpga_types.QuartusArrayVariableConverter(type_converter) Bases:
hls4ml.backends.fpga.fpga_types.ArrayVariableConverter
-
class
hls4ml.backends.fpga.fpga_types.QuartusArrayVariableDefinition Bases:
hls4ml.backends.fpga.fpga_types.VariableDefinition-
definition_cpp(name_suffix='', as_reference=False)
-
-
class
hls4ml.backends.fpga.fpga_types.QuartusInplaceVariableConverter(type_converter) Bases:
hls4ml.backends.fpga.fpga_types.InplaceVariableConverter
-
class
hls4ml.backends.fpga.fpga_types.QuartusStructMemberVariableConverter(type_converter) Bases:
hls4ml.backends.fpga.fpga_types.StructMemberVariableConverter
-
class
hls4ml.backends.fpga.fpga_types.QuartusStructMemberVariableDefinition Bases:
hls4ml.backends.fpga.fpga_types.VariableDefinition-
definition_cpp(name_suffix='', as_reference=False)
-
-
class
hls4ml.backends.fpga.fpga_types.StaticWeightVariableConverter(type_converter) Bases:
object-
convert(weight_var)
-
-
class
hls4ml.backends.fpga.fpga_types.StaticWeightVariableDefinition Bases:
hls4ml.backends.fpga.fpga_types.VariableDefinition-
definition_cpp(name_suffix='', as_reference=False)
-
-
class
hls4ml.backends.fpga.fpga_types.StreamVariableConverter(type_converter, prefix, definition_cls) Bases:
object-
convert(tensor_var, n_pack=1, depth=0)
-
-
class
hls4ml.backends.fpga.fpga_types.StructMemberVariableConverter(type_converter, prefix, definition_cls) Bases:
object-
convert(tensor_var, pragma='partition', struct_name=None)
-
-
class
hls4ml.backends.fpga.fpga_types.TypePrecisionConverter Bases:
object-
convert_precision(precision_converter)
-
-
class
hls4ml.backends.fpga.fpga_types.VariableDefinition Bases:
object-
definition_cpp(name_suffix='', as_reference=False)
-
-
class
hls4ml.backends.fpga.fpga_types.VivadoArrayVariableConverter(type_converter) Bases:
hls4ml.backends.fpga.fpga_types.ArrayVariableConverter
-
class
hls4ml.backends.fpga.fpga_types.VivadoArrayVariableDefinition Bases:
hls4ml.backends.fpga.fpga_types.VariableDefinition-
definition_cpp(name_suffix='', as_reference=False)
-
-
class
hls4ml.backends.fpga.fpga_types.VivadoInplaceVariableConverter(type_converter) Bases:
hls4ml.backends.fpga.fpga_types.InplaceVariableConverter
-
class
hls4ml.backends.fpga.fpga_types.VivadoStreamVariableConverter(type_converter) Bases:
hls4ml.backends.fpga.fpga_types.StreamVariableConverter
-
class
hls4ml.backends.fpga.fpga_types.VivadoStreamVariableDefinition Bases:
hls4ml.backends.fpga.fpga_types.VariableDefinition-
definition_cpp(name_suffix='', as_reference=False)
-