Skip to content

Commit b3dce6d

Browse files
digantdesaimeta-codesync[bot]
authored andcommitted
Add float scalar input support (#18751)
Summary: Pull Request resolved: #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. Reviewed By: 3l1 Differential Revision: D99845426
1 parent 75ba558 commit b3dce6d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

extension/pybindings/pybindings.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ struct PyModule final {
807807
cpp_inputs.push_back(EValue(py::cast<bool>(python_input)));
808808
} else if (py::isinstance<py::int_>(python_input)) {
809809
cpp_inputs.push_back(EValue(py::cast<int64_t>(python_input)));
810+
} else if (py::isinstance<py::float_>(python_input)) {
811+
cpp_inputs.push_back(EValue(py::cast<double>(python_input)));
810812
} else {
811813
throw std::runtime_error(
812814
"Unsupported python type " + type_str +
@@ -1135,6 +1137,8 @@ struct PyMethod final {
11351137
cpp_inputs.push_back(EValue(py::cast<bool>(python_input)));
11361138
} else if (py::isinstance<py::int_>(python_input)) {
11371139
cpp_inputs.push_back(EValue(py::cast<int64_t>(python_input)));
1140+
} else if (py::isinstance<py::float_>(python_input)) {
1141+
cpp_inputs.push_back(EValue(py::cast<double>(python_input)));
11381142
} else {
11391143
throw std::runtime_error(
11401144
"Unsupported python type " + type_str +

0 commit comments

Comments
 (0)