hls4ml.model.optimizer.passes package

Submodules

hls4ml.model.optimizer.passes.bn_fuse module

class hls4ml.model.optimizer.passes.bn_fuse.FuseBatchNormalization

Bases: hls4ml.model.optimizer.optimizer.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.model.optimizer.passes.fuse_biasadd module

class hls4ml.model.optimizer.passes.fuse_biasadd.FuseBiasAdd

Bases: hls4ml.model.optimizer.optimizer.OptimizerPass

Fuses BiasAdd into Dense/Conv2D layer (common in TF models).

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.model.optimizer.passes.multi_dense module

class hls4ml.model.optimizer.passes.multi_dense.ReplaceMultidimensionalDenseWithConv

Bases: hls4ml.model.optimizer.optimizer.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.model.optimizer.passes.nop module

class hls4ml.model.optimizer.passes.nop.EliminateLinearActivation

Bases: hls4ml.model.optimizer.optimizer.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.model.optimizer.passes.precision_merge module

class hls4ml.model.optimizer.passes.precision_merge.SetPrecisionConcat

Bases: hls4ml.model.optimizer.optimizer.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)

Set concat output precision

hls4ml.model.optimizer.passes.precision_merge.get_concat_type(itype1, itype2)

hls4ml.model.optimizer.passes.qkeras module

hls4ml.model.optimizer.passes.transpose_opt module

class hls4ml.model.optimizer.passes.transpose_opt.RemoveUselessTranspose

Bases: hls4ml.model.optimizer.optimizer.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)

Remove a transpose layer if it doesn’t do anything. i.e 1D input and perm = [0]

Module contents