Analysis

If you want to know more details about analysis passes, please take a look at section “Analysis Pass” in chapter Internals.

Submodules

Analysis Passes

qonnx.analysis.base

How to write an analysis pass for QONNX

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.

qonnx.analysis.inference_cost

qonnx.analysis.inference_cost.aggregate_dict_keys(res_dict)
qonnx.analysis.inference_cost.get_node_tensor_dtypes(model, node)
qonnx.analysis.inference_cost.get_node_tensor_shapes(model, node)
qonnx.analysis.inference_cost.get_node_weight_density(model, w_name)
qonnx.analysis.inference_cost.inference_cost(model, discount_sparsity=True, cost_breakdown=False)

Ensure all nodes have unique names prior to calling this analysis pass.

qonnx.analysis.inference_cost.inference_cost_conv(model, node, discount_sparsity)
qonnx.analysis.inference_cost.inference_cost_matmul(model, node, discount_sparsity)
qonnx.analysis.inference_cost.inference_cost_upsample(model, node, discount_sparsity)

qonnx.analysis.tensor_stats

qonnx.analysis.tensor_stats.main()
qonnx.analysis.tensor_stats.tensor_stats(modelwrapper_or_filename, act_dump_dir: str, output_stats_dir: str, *, axes='1', plot=True, report_mode: functools.partial(<function _use_class at 0x7f8655d4c940>, <class 'clize.parser.use_mixin.<locals>._PosWithMixin'>, <class 'clize.parser.use_mixin.<locals>._VarargsWithMixin'>, <class 'clize.parser.use_mixin.<locals>._NamedWithMixin'>, <function unimplemented_parameter at 0x7f8655d4c4c0>, {'case_sensitive': None, 'list_name': 'list', 'values': [('range', ['range', ]'Report ranges'), ('stuck_channel', ['stuck_channel', ]'Report stuck channels'), ('zerostuck_channel', ['zerostuck_channel', ]'Report 0-stuck channels')]}) = 'range')
qonnx.analysis.tensor_stats.update_tensor_stats(tensor, axes, ret_dict={})

qonnx.analysis.topology

qonnx.analysis.topology.all_tensors_f32(model)

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

Returns {“all_tensors_f32”: Bool}.

qonnx.analysis.topology.get_per_tensor_fanouts(model)

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

qonnx.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}.

qonnx.analysis.topology.node_inputs_in_expected_order(model)

Verifies that the node inputs are ordered in the way that QONNX 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}.

qonnx.analysis.topology.nodes_topologically_sorted(model)

Verifies that graph.node is topologically sorted. This is required by the ONNX specification.

Returns {“nodes_topologically_sorted”: 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. Please note that many FINN CustomOps don’t yet implement the verify_node function required for this analysis pass to work correctly.

Returns {node op_type : info_messages}

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