hls4ml.backends.fpga.passes package

Submodules

hls4ml.backends.fpga.passes.bram_weights module

class hls4ml.backends.fpga.passes.bram_weights.RegisterBramWeights

Bases: OptimizerPass

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

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.fpga.passes.clone module

class hls4ml.backends.fpga.passes.clone.Clone(model, name, attributes, inputs, outputs=None)

Bases: Layer

Inserted after the layer whose output is used more than once.

initialize()
class hls4ml.backends.fpga.passes.clone.CloneFunctionTemplate

Bases: FunctionCallTemplate

format(node)
class hls4ml.backends.fpga.passes.clone.CloneOutput

Bases: OptimizerPass

Clones streams that are used multiple times

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

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.fpga.passes.clone.register_clone(backend)

hls4ml.backends.fpga.passes.codegen module

class hls4ml.backends.fpga.passes.codegen.GenerateConvIm2col

Bases: OptimizerPass

Generates tcode for im2col step of 1D/2d convolution

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

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.fpga.passes.embedding module

class hls4ml.backends.fpga.passes.embedding.EmbeddingConfigTemplate

Bases: LayerConfigTemplate

format(node)
class hls4ml.backends.fpga.passes.embedding.EmbeddingFunctionTemplate

Bases: FunctionCallTemplate

format(node)

hls4ml.backends.fpga.passes.final_reshape module

class hls4ml.backends.fpga.passes.final_reshape.RemoveFinalReshape

Bases: OptimizerPass

Remove reshape if final layer

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

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.fpga.passes.fix_softmax_table_size module

class hls4ml.backends.fpga.passes.fix_softmax_table_size.FixSoftmaxTableSize

Bases: OptimizerPass

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

transform(model, node: Layer)

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.fpga.passes.fix_softmax_table_size.register_softmax__table_size_fix(backend)

hls4ml.backends.fpga.passes.hgq_proxy_model module

class hls4ml.backends.fpga.passes.hgq_proxy_model.ProcessFixedPointQuantizerCall

Bases: FunctionCallTemplate

format(node)
class hls4ml.backends.fpga.passes.hgq_proxy_model.ProcessFixedPointQuantizerLayer

Bases: OptimizerPass

match(node: Layer)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

transform(model, node: FixedPointQuantizer)

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.fpga.passes.hgq_proxy_model.ProcessUnaryLUTCall

Bases: FunctionCallTemplate

format(node)
hls4ml.backends.fpga.passes.hgq_proxy_model.generate_mask_fn(name: str, shape: tuple[int, ...], k: ndarray, b: ndarray, i: ndarray, RND: str, SAT: str, backend: str) str

Generate heterogenous quantization mask function, ONLY works for IOType=io_parallel

hls4ml.backends.fpga.passes.hgq_proxy_model.register_hgq_proxy_model(backend: Backend)
hls4ml.backends.fpga.passes.hgq_proxy_model.to_acfixed(k, b, i, RND, SAT)
hls4ml.backends.fpga.passes.hgq_proxy_model.to_apfixed(k, b, i, RND, SAT)

hls4ml.backends.fpga.passes.inplace_parallel_reshape module

class hls4ml.backends.fpga.passes.inplace_parallel_reshape.InplaceParallelReshape

Bases: OptimizerPass

Replaces the output variable of Reshape layer with an inplace variable when using io_parallel.

This is done because in io_parallel tensors are stored as flat arrays, requiring no reshaping.

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

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.fpga.passes.inplace_stream_flatten module

class hls4ml.backends.fpga.passes.inplace_stream_flatten.InplaceStreamFlatten

Bases: OptimizerPass

Replaces the output variable of Reshape (flatten) layer with an inplace variable when using io_stream.

This optimizer avoids the expensive repacking of the stream when Reshape layer flattens the tensor to 1d.

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

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.fpga.passes.remove_softmax module

class hls4ml.backends.fpga.passes.remove_softmax.SkipSoftmax

Bases: OptimizerPass

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

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.fpga.passes.repack_stream module

class hls4ml.backends.fpga.passes.repack_stream.Repack(model, name, attributes, inputs, outputs=None)

Bases: Layer

Inserted between layers with different packing factors.

initialize()
class hls4ml.backends.fpga.passes.repack_stream.RepackFunctionTemplate

Bases: FunctionCallTemplate

format(node)
class hls4ml.backends.fpga.passes.repack_stream.ReshapeStream

Bases: OptimizerPass

Repacks stream for Reshape layer

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

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.fpga.passes.repack_stream.register_repack_stream(backend)

hls4ml.backends.fpga.passes.xnor_pooling module

class hls4ml.backends.fpga.passes.xnor_pooling.XnorPooling

Bases: OptimizerPass

For correct behavior, for MaxPooling and similar, for XnorPrecisionType, have to propagate the type to the output.

match(node)

Predicate to match on a given node.

Parameters:

node (Layer) – Node in the model graph to try matching the optimizer on.

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.

Module contents