# hls4ml.model.optimizer.passes package

## hls4ml.model.optimizer.passes.bn_fuse module

class hls4ml.model.optimizer.passes.bn_fuse.FuseBatchNormalization
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.

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

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

class hls4ml.model.optimizer.passes.transpose_opt.RemoveUselessTranspose
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]