From 033b27488371b856642878237a819466087c3dc9 Mon Sep 17 00:00:00 2001 From: zhangbo9674 <82555433+zhangbo9674@users.noreply.github.com> Date: Thu, 31 Mar 2022 15:36:16 +0800 Subject: [PATCH] fix python c bug for eager tensor (#41158) --- paddle/fluid/pybind/op_function_common.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/pybind/op_function_common.cc b/paddle/fluid/pybind/op_function_common.cc index 1d483abd77..614689b148 100644 --- a/paddle/fluid/pybind/op_function_common.cc +++ b/paddle/fluid/pybind/op_function_common.cc @@ -59,13 +59,15 @@ class OpAttrTypeMap { extern PyTypeObject* g_varbase_pytype; extern PyTypeObject* g_vartype_pytype; extern PyTypeObject* g_blockdesc_pytype; +extern PyTypeObject* p_tensor_type; bool PyObject_CheckBool(PyObject** obj) { return PyBool_Check(*obj); } bool PyObject_CheckLongOrToLong(PyObject** obj) { if ((PyLong_Check(*obj) && !PyBool_Check(*obj)) || PyObject_IsInstance(*obj, (PyObject*)g_vartype_pytype) || // NOLINT - 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; } -- GitLab