[onert/python] Support inference benchmark#15192
Merged
glistening merged 2 commits intoSamsung:masterfrom Apr 23, 2025
Merged
Conversation
This commit adds inference benchmark sample and latency measurement support. - Added `inference_benchmark.py` sample for measuring inference latency and memory usage - Supports static shape override via `--input-shape` - Measures MODEL_LOAD / PREPARE / EXECUTE / PEAK memory (RSS) and I/O / run latency - Updated `session.infer()` API to optionally return latency metrics using `measure=True` - Fixed potential memory accumulation in `set_inputs()` and `set_outputs()` by clearing internal buffers each call - Added `_time_block()` context manager for clean latency measurement implementation ONE-DCO-1.0-Signed-off-by: ragmani <ragmani0216@gmail.com>
Contributor
Author
Contributor
Author
python3 runtime/onert/sample/minimal-python/src/inference_benchmark.py mobilenetv2 --backends cpu --input-shape 1,224,224,3 --repeat 100
======= Inference Benchmark =======
- Warmup runs : 3
- Measured runs : 100
- Prepare : 10.193 ms
- Avg I/O : 0.081 ms
- Avg Run : 10.520 ms
===================================
RSS
- MODEL_LOAD : 15112 KB
- PREPARE : 42280 KB
- EXECUTE : 72160 KB
- PEAK : 72160 KB
===================================
|
chunseoklee
reviewed
Apr 21, 2025
Contributor
Author
python3 runtime/onert/sample/minimal-python/src/inference_benchmark.py mobilenetv2 --backends cpu --input-shape 1,224,224,3 --repeat 10
======= Inference Benchmark =======
- Warmup runs : 3
- Measured runs : 10
- Prepare : 10.814 ms
- Avg I/O : 0.082 ms
- Avg Run : 10.831 ms
===================================
RSS
- MODEL_LOAD : 15068 KB
- PREPARE : 41728 KB
- EXECUTE : 41856 KB
- PEAK : 41856 KB
===================================Note that the above RSS figures exclude the memory footprint of both ONERT library and the Python libraries, ONERT library itself consumes roughly 3 MB. |
chunseoklee
approved these changes
Apr 21, 2025
Contributor
Author
|
@Samsung/one_onert PTAL |
Contributor
|
@ragmani Could you please update typo in title? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds inference benchmark sample and latency measurement support.
inference_benchmark.pysample for measuring inference latency and memory usage--input-shapesession.infer()API to optionally return latency metrics usingmeasure=Trueset_inputs()andset_outputs()by clearing internal buffers each call_time_block()context manager for clean latency measurement implementationONE-DCO-1.0-Signed-off-by: ragmani ragmani0216@gmail.com