hls4ml.backends.altera package
Subpackages
- hls4ml.backends.altera.passes package
- Submodules
- hls4ml.backends.altera.passes.bn_quant module
- hls4ml.backends.altera.passes.clone_templates module
- hls4ml.backends.altera.passes.convolution_templates module
- hls4ml.backends.altera.passes.convolution_winograd module
- hls4ml.backends.altera.passes.core_templates module
ActivationConfigTemplateActivationFunctionTemplateActivationStreamFunctionTemplateActivationTaskSequenceTemplateBatchNormalizationConfigTemplateBatchNormalizationFunctionTemplateBatchNormalizationStreamFunctionTemplateBatchNormalizationTaskSequenceTemplateDenseConfigTemplateDenseFunctionTemplateDenseStreamFunctionTemplateDenseTaskSequenceTemplateHardActivationConfigTemplatePReLUActivationStreamFunctionTemplatePReLUFunctionTemplateParamActivationConfigTemplateParametrizedActivationFunctionTemplateParametrizedActivationStreamFunctionTemplateParametrizedActivationTaskSequenceTemplateSoftmaxConfigTemplate
- hls4ml.backends.altera.passes.einsum module
- hls4ml.backends.altera.passes.einsum_dense module
- hls4ml.backends.altera.passes.embedding_templates module
- hls4ml.backends.altera.passes.feature_check module
- hls4ml.backends.altera.passes.merge_templates module
- hls4ml.backends.altera.passes.pointwise module
- hls4ml.backends.altera.passes.pooling_templates module
- hls4ml.backends.altera.passes.quantization_templates module
- hls4ml.backends.altera.passes.recurrent_templates module
- hls4ml.backends.altera.passes.reshaping_templates module
ReshapeConfigTemplateReshapeFunctionTemplateReshapeTaskSequenceTemplateReshapingStreamFunctionTemplateResizeConfigTemplateResizeFunctionTemplateResizeTaskSequenceTemplateTransposeConfigTemplateTransposeFunctionTemplateTransposeTaskSequenceTemplateZeroPaddingConfigTemplateZeroPaddingFunctionTemplateZeroPaddingTaskSequenceTemplate
- hls4ml.backends.altera.passes.resource_strategy module
- hls4ml.backends.altera.passes.transform_types module
- Module contents
Submodules
hls4ml.backends.altera.altera_backend module
- class hls4ml.backends.altera.altera_backend.AlteraBackend
Bases:
FPGABackend- build(model, build_type='fpga_emu', run=False)
Builds the project using the Altera DPC++ compiler toolchain.
- Parameters:
model (ModelGraph) – The model to build
build_type – What to build (e.g. fpga_emu, fpga_sim, fpga, report)
optional – What to build (e.g. fpga_emu, fpga_sim, fpga, report)
run – Whether to run the testbench
optional – Whether to run the testbench
Errors raise exceptions
- 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:
Path
- create_initial_config(part='Agilex7', clock_period=5, hyperopt_handshake=False, io_type='io_parallel', namespace=None, write_tar=False, **_)
Create initial configuration of the Altera backend.
- Parameters:
part (str, optional) – The FPGA part to be used. Defaults to ‘Agilex7’.
clock_period (int, optional) – The clock period in ns. Defaults to 5.
hyperopt_handshake (bool, optional) – Should hyper-optimized handshaking be used? Defaults to False
io_type (str, optional) – Type of implementation used. One of ‘io_parallel’ or ‘io_stream’. Defaults to ‘io_parallel’.
namespace (str, optional) – Namespace for the kernel and pipe declarations. If None, the project name is used, with the stamp appended if the project name is the default ‘myproject’. Defaults to None.
write_tar (bool, optional) – If True, compresses the output directory into a .tar.gz file. Defaults to False.
- Returns:
initial configuration.
- Return type:
dict
- get_default_flow()
The name of the default flow of the backend.
Default flow is used as the conversion target if the target flow has not been specified.
- get_writer_flow()
- init_activation(layer)
- init_base_layer(layer)
- init_conv1d(layer)
- init_conv2d(layer)
- init_dense(layer)
- init_einsum_dense(layer: EinsumDense) None
- init_embed(layer)
- init_gru(layer)
- init_lstm(layer)
- init_simple_rnn(layer)
- init_softmax(layer)
hls4ml.backends.altera.altera_template module
This package includes Altera-specific templates
- class hls4ml.backends.altera.altera_template.StreamFunctionCallTemplate(layer_class)
Bases:
TemplateBase class for the streaming function call templates in Altera: provides the ‘stream_function_cpp’ attribute. This generally provides the async call to the task sequence that executes the streaming function.
Note: the include header files are specified in the regular FunctionCallTemplate, not here.
- Parameters:
layer_class (Layer or list, tuple, or set of Layers) – The Layers that this template handles.
- transform(model, node)
Transformation to apply if matching was successful.
Transform should return a boolean value indicating if the model graph was altered (by adding/removing nodes).
- Parameters:
model (ModelGraph) – Model to optimize
node (Layer) – The matched node in the model graph.
- class hls4ml.backends.altera.altera_template.TaskSequenceTemplate(layer_class)
Bases:
TemplateBase class for the task sequence definition in Altera: provides the ‘task_sequence_cpp’ attribute. This defines the task sequence that is then called by the StreamFunctionCallTemplate.
- Parameters:
layer_class (Layer or list, tuple, or set of Layers) – The Layers that this template handles.
- transform(model, node)
Transformation to apply if matching was successful.
Transform should return a boolean value indicating if the model graph was altered (by adding/removing nodes).
- Parameters:
model (ModelGraph) – Model to optimize
node (Layer) – The matched node in the model graph.
hls4ml.backends.altera.altera_types module
This package includes Altera-specific customizations to the variable types
- class hls4ml.backends.altera.altera_types.ACExponentPrecisionDefinition
Bases:
PrecisionDefinition- definition_cpp()
- class hls4ml.backends.altera.altera_types.AggregratedArrayVariableConverter(type_converter, prefix, definition_cls)
Bases:
objectThis is a bit of an extension of the standard ArrayVariableConverter
- convert(tensor_var, pragma='', depth=0, n_pack=1)
- class hls4ml.backends.altera.altera_types.AlteraACTypeConverter
Bases:
FPGAPrecisionConverter
- class hls4ml.backends.altera.altera_types.AlteraArrayVariableConverter(type_converter)
- class hls4ml.backends.altera.altera_types.AlteraArrayVariableDefinition
Bases:
VariableDefinition- definition_cpp(name_suffix='', as_reference=False)
- class hls4ml.backends.altera.altera_types.AlteraCompressedTypeConverter
Bases:
TypeDefinition,TypePrecisionConverterUse a tuple for storing a compressed type for Altera since it’s better supported. (Currently unused)
- convert_precision(precision_converter)
- definition_cpp()
tuple format is row_index, col_index, weight
- class hls4ml.backends.altera.altera_types.AlteraExponentTypeConverter
Bases:
TypeDefinition,TypePrecisionConverterUse a pair for storing a exponent type for Altera since it’s better supported
- convert_precision(precision_converter)
- definition_cpp()
- class hls4ml.backends.altera.altera_types.AlteraHLSTypeConverter(precision_converter)
Bases:
HLSTypeConverter
- class hls4ml.backends.altera.altera_types.AlteraInplaceArrayVariableConverter(type_converter)
- class hls4ml.backends.altera.altera_types.AlteraInplaceArrayVariableDefinition
Bases:
VariableDefinition- definition_cpp()
- class hls4ml.backends.altera.altera_types.AlteraInplaceStreamVariableConverter(type_converter)
- class hls4ml.backends.altera.altera_types.AlteraInplaceStreamVariableDefinition
Bases:
VariableDefinition- definition_cpp()
- class hls4ml.backends.altera.altera_types.AlteraInterfaceVariableConverter(type_converter)
- class hls4ml.backends.altera.altera_types.AlteraInterfaceVariableDefinition
Bases:
VariableDefinition- declare_cpp(pipe_min_size=0, indent='')
- definition_cpp(name_suffix='', as_reference=False)
- class hls4ml.backends.altera.altera_types.AlteraPackedTypeConverter
Bases:
TypeDefinition,TypePrecisionConverter- convert_precision(precision_converter)
- definition_cpp()
- class hls4ml.backends.altera.altera_types.AlteraStaticWeightVariableConverter(type_converter)
Bases:
object- convert(weight_var)
- class hls4ml.backends.altera.altera_types.AlteraStaticWeightVariableDefinition
Bases:
VariableDefinition- definition_cpp(reuse_factor)
Write the appropriate weight definiiton
- class hls4ml.backends.altera.altera_types.AlteraStreamVariableConverter(type_converter)
- class hls4ml.backends.altera.altera_types.AlteraStreamVariableDefinition
Bases:
VariableDefinition- declare_cpp(indent='')
- definition_cpp(name_suffix='', as_reference=True)