Add float scalar input support (#18751)#18751
Add float scalar input support (#18751)#18751digantdesai wants to merge 1 commit intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18751
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New Failures, 2 Unrelated FailuresAs of commit 20d6e88 with merge base e638059 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following jobs failed but were 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
Adds Python float scalar input support to the ExecuTorch Python bindings by converting float → double and wrapping it in EValue, addressing runtime failures for exported models that take floating-point scalar parameters (e.g., alpha/beta).
Changes:
- Convert Python
floatinputs toEValue(double)inPyModule::run_methodinput processing. - Convert Python
floatinputs toEValue(double)inPyMethod::set_inputsinput processing.
Comments suppressed due to low confidence (2)
extension/pybindings/pybindings.cpp:815
- The exception message says inputs must be a flat list of tensors, but this code path explicitly supports non-tensor inputs (None/bool/int/float). Consider updating the message to reflect the actually supported scalar types to avoid confusing users when they pass an unsupported input type.
} else {
throw std::runtime_error(
"Unsupported python type " + type_str +
". Ensure that inputs are passed as a flat list of tensors.");
extension/pybindings/pybindings.cpp:1145
- The exception message says inputs must be a flat list of tensors, but this conversion logic supports non-tensor inputs (None/bool/int/float). Consider updating the message to mention the supported scalar types to make debugging unsupported inputs clearer.
} else {
throw std::runtime_error(
"Unsupported python type " + type_str +
". Ensure that inputs are passed as a flat list of tensors.");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
31f410e to
dbd4966
Compare
Summary: The pybindings code handled bool and int scalar inputs but was missing support for float (Python float → C++ double). This caused failures when running models like Addmm that take float alpha/beta parameters, throwing 'Unsupported python type <class float>'. Added py::isinstance<py::float_> handling to convert Python floats to EValue(double) in both the portable and XNNPACK input processing paths. Differential Revision: D99845426
Summary: Pull Request resolved: pytorch#18751 The pybindings code handled bool and int scalar inputs but was missing support for float (Python float → C++ double). This caused failures when running models like Addmm that take float alpha/beta parameters, throwing 'Unsupported python type <class float>'. Added py::isinstance<py::float_> handling to convert Python floats to EValue(double) in both the portable and XNNPACK input processing paths. Differential Revision: D99845426
dbd4966 to
20d6e88
Compare
|
@digantdesai has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99845426. |
Summary:
The pybindings code handled bool and int scalar inputs but was missing
support for float (Python float → C++ double). This caused failures when
running models like Addmm that take float alpha/beta parameters, throwing
'Unsupported python type '.
Added py::isinstancepy::float_ handling to convert Python floats to
EValue(double) in both the portable and XNNPACK input processing paths.
Differential Revision: D99845426