Skip to content

[Feature]: Add execution provider selection and inference benchmarkingΒ #815

@fmutlu68

Description

@fmutlu68

πŸš€ Feature Description

Add execution provider selection (CPU/CUDA) and multi-iteration inference benchmarking to the existing examples/onnx example.

πŸ“‚ Feature Category

Testing Infrastructure

πŸ’‘ Motivation

The current examples/onnx example only runs inference using the default CPU execution provider with a single pass. This doesn't reflect real-world applications where backend selection and accurate latency measurement are critical. When evaluating models for deployment on different hardware (CPU vs GPU), having a quick way to compare execution providers within the same example is essential.

πŸ’­ Proposed Solution

  • Add a --device CLI flag to select the execution provider (cpu or cuda)
  • Add a --num-iterations CLI flag for multi-run benchmarking (default: 10)
  • Add a warm-up run before timed iterations to exclude cold-start overhead
    (memory allocation, graph optimization, kernel compilation)
  • Print latency statistics (mean, min, max) across iterations
  • Update README with usage examples for both CPU and CUDA execution

πŸ“š Library Reference

πŸ”„ Alternatives Considered

Considered creating a completely new example, but improving the existing one keeps codebase lean and provides immediate value to current users of the ONNX example.

🎯 Use Cases

πŸ“ Additional Context

This is a small, focused improvement to an existing example. The changes are compatible, default behavior remains CPU with a single run if no extra flags are provided.

🀝 Contribution Intent

  • I plan to submit a PR to implement this feature
  • I'm requesting this feature but not planning to implement it

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededtriagewait for a maintainer to approve and assign this ticket

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions