Expose CPU inference thread count via BaseOptions.num_threads - #6322
Open
velonica0 wants to merge 1 commit into
Open
Expose CPU inference thread count via BaseOptions.num_threads#6322velonica0 wants to merge 1 commit into
velonica0 wants to merge 1 commit into
Conversation
Adds a num_threads field to BaseOptions (Python/C/C++) that sets the XNNPACK delegate thread count for CPU inference; unset keeps the current single-threaded default.
Author
|
Hi, @HarishPermal |
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.
Close #3644 #6151
Description:
MediaPipe Tasks CPU inference runs single-threaded on non-mobile platforms with no way to change it from the public API. This adds a num_threads field to BaseOptions across the Python, C, and C++ layers. When set (> 0) with the CPU delegate, it emits an XNNPACK delegate with that thread count; unset keeps the current single-threaded default, so existing behavior is unchanged.
Changed
base_options.py, base_options_c.py, c/core/base_options.h, base_options_converter.cc, cc/core/base_options.h, base_options.cc, and base_options_test.cc (unit tests for the new field).
Testing:
Base_options_test passes; a real-model run confirmed output is bit-identical across 1/2/4 threads.
Related issues: