Fix negative inter-op count in compute pool - #124960
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates InitComputePool to fall back to the default number of threads when inter_op_parallelism_threads is less than or equal to zero, and adds a unit test to verify this behavior. The feedback suggests strengthening the test assertion to ensure the thread pool size matches DefaultNumInterOpThreads() exactly, rather than just verifying it is greater than zero.
| opts.config.set_inter_op_parallelism_threads(-1); | ||
|
|
||
| thread::ThreadPool* pool = ComputePool(opts); | ||
| EXPECT_GT(pool->NumThreads(), 0); |
There was a problem hiding this comment.
The assertion EXPECT_GT(pool->NumThreads(), 0) is very weak and only verifies that the pool has at least one thread. Since the goal of passing a negative value is to fall back to the default number of threads, we should explicitly assert that pool->NumThreads() equals DefaultNumInterOpThreads(). This provides a much stronger guarantee that the default path was correctly taken.
| EXPECT_GT(pool->NumThreads(), 0); | |
| EXPECT_EQ(pool->NumThreads(), DefaultNumInterOpThreads()); |
Summary
inter_op_parallelism_threadsvalues passed to the process-wide compute pool as unspecified, using the existing default path.ComputePoolcreates a valid pool for-1.Addresses #124954.
Validation
git diff --checkbazel test --config=linux -k //tensorflow/core/common_runtime:process_util_test