Metal backend: Add INT32 and BOOL dtype support#18874
Metal backend: Add INT32 and BOOL dtype support#18874manuelcandales wants to merge 2 commits intomainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18874
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 2 New Failures, 3 Unrelated FailuresAs of commit e7a7acc with merge base 5707e2a ( NEW FAILURES - The following jobs have failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Apple Metal runtime shims’ dtype allowlist so AOTI-generated models can use int32 tensors (e.g., topk indices) and bool tensors (e.g., attention masks) without failing dtype validation.
Changes:
- Add
INT32andBOOLentries to the Metal backendSupportedDTypesenum. - Extend
is_dtype_supported_in_et_metal()to acceptINT32andBOOL. - Simplify the
validate_dtype()error log message.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| backends/apple/metal/runtime/shims/utils.h | Adds INT32 and BOOL to the supported dtype enum. |
| backends/apple/metal/runtime/shims/utils.cpp | Allows INT32/BOOL in dtype validation and updates the unsupported-dtype log message. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "Unsupported dtype: %d", | ||
| dtype); |
There was a problem hiding this comment.
The updated log message in validate_dtype regresses debuggability vs the previous version: it no longer indicates which dtype codes are supported. Please either restore the supported-dtypes list (updated to include INT32 and BOOL) or log it in a way that stays in sync with is_dtype_supported_in_et_metal (e.g., via a single source of truth).
| "Unsupported dtype: %d", | |
| dtype); | |
| "Unsupported dtype: %d. Supported dtype codes: [%d, %d, %d, %d, %d, %d]", | |
| dtype, | |
| static_cast<int32_t>(SupportedDTypes::UINT8), | |
| static_cast<int32_t>(SupportedDTypes::INT32), | |
| static_cast<int32_t>(SupportedDTypes::INT64), | |
| static_cast<int32_t>(SupportedDTypes::FLOAT32), | |
| static_cast<int32_t>(SupportedDTypes::BOOL), | |
| static_cast<int32_t>(SupportedDTypes::BFLOAT16)); |
AOTI-generated code creates int32 tensors for topk indexing and bool
tensors for attention masks. Add both to the SupportedDTypes enum and
validation function.
Authored with Claude.