From 2134876c6f14e78a1b207d7e08b2ee3b88516c22 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Mon, 8 Aug 2022 14:36:44 +0800 Subject: [PATCH] fix PyObject_CheckFloatOrToFloat (#44967) --- paddle/fluid/pybind/op_function_common.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/pybind/op_function_common.cc b/paddle/fluid/pybind/op_function_common.cc index 25dbf5ebb2f..2f1408257ff 100644 --- a/paddle/fluid/pybind/op_function_common.cc +++ b/paddle/fluid/pybind/op_function_common.cc @@ -87,7 +87,8 @@ bool PyObject_CheckLongOrToLong(PyObject** obj) { bool PyObject_CheckFloatOrToFloat(PyObject** obj) { // sometimes users provide PyLong or numpy.int64 but attr is float if (PyFloat_Check(*obj) || PyLong_Check(*obj) || - PyObject_IsInstance(*obj, (PyObject*)g_varbase_pytype)) { // NOLINT + PyObject_IsInstance(*obj, (PyObject*)g_varbase_pytype) || // NOLINT + PyObject_IsInstance(*obj, (PyObject*)p_tensor_type)) { // NOLINT return true; } if (std::string(((PyTypeObject*)(*obj)->ob_type)->tp_name) // NOLINT -- GitLab