Analysis

How to write an analysis pass for FINN

An analysis pass traverses the graph structure and produces information about certain properties. The convention is to take in a ModelWrapper, and return a dictionary of named properties that the analysis extracts.

Analysis Passes

finn.analysis.topology

finn.analysis.topology.all_tensors_f32(model)

Checks whether all tensors have a float32 dtype, extra quantization annotations notwithstanding.

Returns {“all_tensors_f32”: Bool}.

finn.analysis.topology.get_per_tensor_fanouts(model)

Returns a dictionary of {tensor_name: tensor_fanout} for the model.

finn.analysis.topology.is_linear(model)

Checks whether the given model graph is linear. This is done by looking at the fan-out of each tensor. All tensors have a fan-out <= 1 in a linear graph.

Returns {“is_linear”: Bool}.

finn.analysis.topology.node_inputs_in_expected_order(model)

Verifies that the node inputs are ordered in the way that FINN expects them. When a node has a mixture of static (= constant, initialized) inputs and dynamic inputs, the dynamic input should come first, followed by the static one. Only verifiable for a small subset of op_types for now.

Returns {“node_inputs_in_expected_order”: Bool}.

finn.analysis.verify_custom_nodes

finn.analysis.verify_custom_nodes.verify_nodes(model)

Checks if custom ops in graph are correctly built, with all attributes and inputs.

Returns {node op_type : info_messages}

  • info_messages: is list of strings about the result of the verification.