hls4ml.model.optimizer.passes package

Submodules

hls4ml.model.optimizer.passes.bn_fuse module

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

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

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

Bases: 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: 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: 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: 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.stamp module

class hls4ml.model.optimizer.passes.stamp.MakeStamp

Bases: ModelOptimizerPass

transform(model)

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.transpose_opt module

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

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)

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

Module contents