:orphan: .. _benchmarks-gallery: Benchmarks ========== A gallery of benchmarks comparing the SIMD-accelerated CPU kernels provided by ``onnx-light-cpu`` against other back-ends such as ``numpy``, ``onnxruntime`` and ``onnx-light``'s built-in reference kernels. The Gemm and Attention corpora used by the :doc:`Gemm and MatMul roadmap ` are implemented as C++ backend cases in ``TestMode::BENCHMARK``. This is the benchmark framework provided by ``onnx-light``: cases are generated lazily in C++, exposed through ``CollectTestCases``, and consumed by the common benchmark recorder. The Gemm cases live in ``onnx_light_cpu/backend_test/cases/math/cases_gemm.cc``; the Attention cases live in ``onnx-light``'s C++ backend-test registry. The Gemm corpus contains shape-forced cases for every prepared algorithm: ``direct`` (small K), ``skinny_m``, ``skinny_n``, ``split_k`` (large K with a small output), and square/transformer shapes (general five-loop). Every shape is registered for each element type the ``GemmKernel`` implements -- ``float32``, ``float16`` and ``bfloat16`` -- so the corpus also measures the fp16/bf16 widen/round-trip overhead. Standalone recorders run on their calling thread. Integration benchmarks compare participant counts through the ``onnx-light`` session ``cpu_execution`` policy, which owns thread count, affinity, and spin behavior. ``onnx-light-cpu`` does not create workers or read thread-control environment variables. The unary backend corpus samples both sides of the ``Exp`` and ``Log`` scheduling thresholds. ``plot_exp_log_benchmark.py`` visualizes those transitions. ``plot_tree_ensemble_benchmark.py`` visualizes representative cases from the maintained TreeEnsemble parity runner; it does not claim backend-test kernel coverage because TreeEnsemble is not registered there. ``plot_backend_cases_benchmark.py`` walks a subset of the ``TestMode::BENCHMARK`` ``test_cpu_*`` backend test cases -- covering every operator with an onnx-light-cpu backend test registration (``Abs``, ``Exp``, ``Log``, ``Gemm`` and ``Not``) -- and times each one through onnx-light (with onnx-light-cpu's accelerated kernels registered) and through ONNX Runtime, using the exact same generated model and inputs for both. .. raw:: html
.. raw:: html
.. thumbnail-parent-div-open .. raw:: html
.. only:: html .. image:: /auto_examples/benchmarks/images/thumb/sphx_glr_plot_custom_operators_benchmark_thumb.png :alt: :doc:`/auto_examples/benchmarks/plot_custom_operators_benchmark` .. raw:: html
Benchmark custom operators against ONNX Runtime
.. raw:: html
.. only:: html .. image:: /auto_examples/benchmarks/images/thumb/sphx_glr_plot_exp_log_benchmark_thumb.png :alt: :doc:`/auto_examples/benchmarks/plot_exp_log_benchmark` .. raw:: html
Benchmark Exp and Log parallel scheduling
.. raw:: html
.. only:: html .. image:: /auto_examples/benchmarks/images/thumb/sphx_glr_plot_tree_ensemble_benchmark_thumb.png :alt: :doc:`/auto_examples/benchmarks/plot_tree_ensemble_benchmark` .. raw:: html
Benchmark TreeEnsemble scheduling scenarios
.. raw:: html
.. only:: html .. image:: /auto_examples/benchmarks/images/thumb/sphx_glr_plot_gemm_benchmark_thumb.png :alt: :doc:`/auto_examples/benchmarks/plot_gemm_benchmark` .. raw:: html
Benchmark Gemm: numpy vs onnxruntime vs onnx-light vs onnx-light-cpu
.. raw:: html
.. only:: html .. image:: /auto_examples/benchmarks/images/thumb/sphx_glr_plot_abs_benchmark_thumb.png :alt: :doc:`/auto_examples/benchmarks/plot_abs_benchmark` .. raw:: html
Benchmark Abs: onnxruntime vs onnx-light + onnx-light-cpu
.. raw:: html
.. only:: html .. image:: /auto_examples/benchmarks/images/thumb/sphx_glr_plot_gemm_dtype_benchmark_thumb.png :alt: :doc:`/auto_examples/benchmarks/plot_gemm_dtype_benchmark` .. raw:: html
Benchmark Gemm: float32 vs float16 vs bfloat16 across kernel code paths
.. raw:: html
.. only:: html .. image:: /auto_examples/benchmarks/images/thumb/sphx_glr_plot_backend_cases_benchmark_thumb.png :alt: :doc:`/auto_examples/benchmarks/plot_backend_cases_benchmark` .. raw:: html
Benchmark backend test cases against ONNX Runtime
.. thumbnail-parent-div-close .. raw:: html
.. toctree:: :hidden: /auto_examples/benchmarks/plot_custom_operators_benchmark /auto_examples/benchmarks/plot_exp_log_benchmark /auto_examples/benchmarks/plot_tree_ensemble_benchmark /auto_examples/benchmarks/plot_gemm_benchmark /auto_examples/benchmarks/plot_abs_benchmark /auto_examples/benchmarks/plot_gemm_dtype_benchmark /auto_examples/benchmarks/plot_backend_cases_benchmark .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-gallery .. container:: sphx-glr-download sphx-glr-download-python :download:`Download all examples in Python source code: benchmarks_python.zip ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download all examples in Jupyter notebooks: benchmarks_jupyter.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_