From b3dce6d9c091b99cac9c75d09b6e7d36d5ef008f Mon Sep 17 00:00:00 2001 From: Digant Desai Date: Thu, 16 Apr 2026 07:36:54 -0700 Subject: [PATCH] Add float scalar input support (#18751) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/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 '. Added py::isinstance handling to convert Python floats to EValue(double) in both the portable and XNNPACK input processing paths. Reviewed By: 3l1 Differential Revision: D99845426 --- extension/pybindings/pybindings.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extension/pybindings/pybindings.cpp b/extension/pybindings/pybindings.cpp index 684a345e334..0b80363f211 100644 --- a/extension/pybindings/pybindings.cpp +++ b/extension/pybindings/pybindings.cpp @@ -807,6 +807,8 @@ struct PyModule final { cpp_inputs.push_back(EValue(py::cast(python_input))); } else if (py::isinstance(python_input)) { cpp_inputs.push_back(EValue(py::cast(python_input))); + } else if (py::isinstance(python_input)) { + cpp_inputs.push_back(EValue(py::cast(python_input))); } else { throw std::runtime_error( "Unsupported python type " + type_str + @@ -1135,6 +1137,8 @@ struct PyMethod final { cpp_inputs.push_back(EValue(py::cast(python_input))); } else if (py::isinstance(python_input)) { cpp_inputs.push_back(EValue(py::cast(python_input))); + } else if (py::isinstance(python_input)) { + cpp_inputs.push_back(EValue(py::cast(python_input))); } else { throw std::runtime_error( "Unsupported python type " + type_str +