gmalivenko / onnx-opcounter

Count number of parameters / MACs / FLOPS for ONNX models.
Apache License 2.0
89 stars 21 forks source link
cli flops machine-learning macs onnx onnx-models

ONNX Operations Counter [WIP]

GitHub License Downloads PyPI

Counts number of parameters / MACs for ONNX models.

Installation

pip install onnx_opcounter

Basic Usage

Using CLI (calculate number of parameters)

onnx_opcounter {path_to_onnx_model}

Using CLI (calculate number of parameters and MACs)

onnx_opcounter --calculate-macs {path_to_onnx_model}

Using API

from onnx_opcounter import calculate_params
import onnx

model = onnx.load_model('./path/to/onnx/model')
params = calculate_params(model)

print('Number of params:', params)

License

The software is covered by Apache License 2.0.