Infinite loop in XNNExecutor::resize_outputs#17181
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17181
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 1 Unrelated FailureAs of commit 40c4f93 with merge base 56adf76 ( NEW FAILURES - The following jobs have failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
54d7f8a to
750401f
Compare
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
Fixes an infinite loop in XNNExecutor::resize_outputs when converting XNNPACK argmax indices from int32 to int64, and adds a regression test to cover the conversion path.
Changes:
- Use a signed loop index (
ssize_t) when iterating backwards overnumel()inXNNExecutor::resize_outputs. - Add an XNNPACK runtime test that exercises argmax-pooling index output conversion to int64 (and would previously hang due to the infinite loop).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| backends/xnnpack/runtime/XNNExecutor.cpp | Fixes the backwards loop in int32→int64 index conversion to avoid unsigned underflow/infinite looping. |
| backends/xnnpack/test/runtime/test_xnnexecutor.cpp | Adds a regression test validating argmax index conversion into a Long tensor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (out_tensor->scalar_type() == ScalarType::Long) { | ||
| int64_t* data_64 = out_tensor->mutable_data_ptr<int64_t>(); | ||
| const int32_t* data_32 = out_tensor->const_data_ptr<int32_t>(); | ||
| for (size_t j = out_tensor->numel() - 1; j >= 0; --j) { |
There was a problem hiding this comment.
Wow, I'm surprised this has wasn't caught before.
750401f to
40c4f93
Compare
Summary
size_t --> ssize_t so it's signed and won't loop indefinitely.
Test plan