yobx.helpers.stats_helper#
ModelStatistics#
- class yobx.helpers.ModelStatistics(model: ModelProto | GraphBuilderExtendedProtocol, verbose: int = 0)[source]#
Computes statistics on an ONNX model, including node counts per op_type and estimated FLOPs.
model may be either an
onnx.ModelProtoor aGraphBuilderExtendedProtocolinstance. When a graph builder is provided its already-computed shape information is used directly (no second shape-inference pass is run) and the ONNX model is obtained viato_onnx().- Parameters:
model – ONNX model or graph builder
verbose – verbosity level passed to
BasicShapeBuilder(ignored when model is a graph builder)
Usage:
stats = ModelStatistics(model).compute()
- compute() Dict[str, Any][source]#
Runs the full analysis and returns a statistics dictionary.
- Returns:
dictionary with the following keys:
"n_nodes"– total number of nodes"node_count_per_op_type"– dict mapping op_type → count"total_estimated_flops"– total estimated FLOPs (int or None)"flops_per_op_type"– dict mapping op_type → estimated FLOPs (None means the cost could not be estimated for some nodes)"node_stats"– list of per-node dicts with keysop_type,name,inputs,outputs,estimated_flops
model_statistics#
- yobx.helpers.model_statistics(model: ModelProto | GraphBuilderExtendedProtocol, verbose: int = 0) Dict[str, Any][source]#
Computes statistics on an ONNX model.
This is a convenience wrapper around
ModelStatistics.- Parameters:
model – ONNX model or graph builder
verbose – verbosity level
- Returns:
statistics dictionary — see
ModelStatistics.compute()for details
Module#
Functions to compute statistics on an ONNX model such as number of nodes per op_type and estimation of computational cost.
- yobx.helpers.stats_helper.model_statistics(model: ModelProto | GraphBuilderExtendedProtocol, verbose: int = 0) Dict[str, Any][source]#
Computes statistics on an ONNX model.
This is a convenience wrapper around
ModelStatistics.- Parameters:
model – ONNX model or graph builder
verbose – verbosity level
- Returns:
statistics dictionary — see
ModelStatistics.compute()for details