Skip to content

Add float scalar input support (#18751)#18751

Open
digantdesai wants to merge 1 commit intopytorch:mainfrom
digantdesai:export-D99845426
Open

Add float scalar input support (#18751)#18751
digantdesai wants to merge 1 commit intopytorch:mainfrom
digantdesai:export-D99845426

Conversation

@digantdesai
Copy link
Copy Markdown
Contributor

@digantdesai digantdesai commented Apr 7, 2026

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

Copilot AI review requested due to automatic review settings April 7, 2026 21:28
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 7, 2026

🔗 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 Failures

As of commit 20d6e88 with merge base e638059 (image):

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.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Python float scalar input support to the ExecuTorch Python bindings by converting floatdouble and wrapping it in EValue, addressing runtime failures for exported models that take floating-point scalar parameters (e.g., alpha/beta).

Changes:

  • Convert Python float inputs to EValue(double) in PyModule::run_method input processing.
  • Convert Python float inputs to EValue(double) in PyMethod::set_inputs input 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.

@meta-codesync meta-codesync bot changed the title Add float scalar input support Add float scalar input support (#18751) Apr 8, 2026
digantdesai added a commit to digantdesai/executorch-1 that referenced this pull request Apr 8, 2026
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
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Apr 8, 2026

@digantdesai has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99845426.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants