qonnx.util.inference_cost (module)

qonnx.util.inference_cost.compute_bops(inf_cost_dict)
qonnx.util.inference_cost.compute_mem_bits(inf_cost_dict, filter_string='mem_w')
qonnx.util.inference_cost.inference_cost(model_filename, *, output_json=None, output_onnx=None, preprocess=True, discount_sparsity=True)

Print the inference cost estimate metric for given ONNX model. Supports the Quant op for weight/activation quantization.

Parameters
  • model_filename – Filename for ONNX model

  • output_json – Optional JSON filename to save the inference cost dict

  • output_onnx – Optional ONNX filename to save the final model after any preprocessing

  • preprocess – If set, run preprocessing steps such as shape inference, datatype inference and constant folding. Strongly recommended.

  • discount_sparsity – If set, will discount op cost of MAC ops with a constant zero weight, and the mem cost of constant zero weights.

qonnx.util.inference_cost.main()