@@ -293,7 +293,8 @@ static PyObject* tensor__add__method(TensorObject* self,
293293 other_tensor = other_tensor_ref;
294294 } else {
295295 if (IsNumpyArray (other_obj)) {
296- py::object numpy_value = py::object (py::handle (other_obj), true );
296+ py::object numpy_value =
297+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
297298 other_tensor = paddle::Tensor (place);
298299 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
299300 } else {
@@ -397,7 +398,8 @@ static PyObject* tensor__sub__method(TensorObject* self,
397398 other_tensor = other_tensor_ref;
398399 } else {
399400 if (IsNumpyArray (other_obj)) {
400- py::object numpy_value = py::object (py::handle (other_obj), true );
401+ py::object numpy_value =
402+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
401403 other_tensor = paddle::Tensor (place);
402404 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
403405 } else {
@@ -499,7 +501,8 @@ static PyObject* tensor__rsub__method(TensorObject* self,
499501 other_tensor = other_tensor_ref;
500502 } else {
501503 if (IsNumpyArray (other_obj)) {
502- py::object numpy_value = py::object (py::handle (other_obj), true );
504+ py::object numpy_value =
505+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
503506 other_tensor = paddle::Tensor (place);
504507 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
505508 } else {
@@ -605,7 +608,8 @@ static PyObject* tensor__mul__method(TensorObject* self,
605608 other_tensor = other_tensor_ref;
606609 } else {
607610 if (IsNumpyArray (other_obj)) {
608- py::object numpy_value = py::object (py::handle (other_obj), true );
611+ py::object numpy_value =
612+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
609613 other_tensor = paddle::Tensor (place);
610614 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
611615 } else {
@@ -708,7 +712,8 @@ static PyObject* tensor__div__method(TensorObject* self,
708712 other_tensor = other_tensor_ref;
709713 } else {
710714 if (IsNumpyArray (other_obj)) {
711- py::object numpy_value = py::object (py::handle (other_obj), true );
715+ py::object numpy_value =
716+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
712717 other_tensor = paddle::Tensor (place);
713718 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
714719 } else {
@@ -814,7 +819,8 @@ static PyObject* tensor__rdiv__method(TensorObject* self,
814819 other_tensor = other_tensor_ref;
815820 } else {
816821 if (IsNumpyArray (other_obj)) {
817- py::object numpy_value = py::object (py::handle (other_obj), true );
822+ py::object numpy_value =
823+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
818824 other_tensor = paddle::Tensor (place);
819825 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
820826 } else {
@@ -924,7 +930,8 @@ static PyObject* tensor__gt__method(TensorObject* self,
924930 other_tensor = other_tensor_ref;
925931 } else {
926932 if (IsNumpyArray (other_obj)) {
927- py::object numpy_value = py::object (py::handle (other_obj), true );
933+ py::object numpy_value =
934+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
928935 other_tensor = paddle::Tensor (place);
929936 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
930937 } else {
@@ -1024,7 +1031,8 @@ static PyObject* tensor__ge__method(TensorObject* self,
10241031 other_tensor = other_tensor_ref;
10251032 } else {
10261033 if (IsNumpyArray (other_obj)) {
1027- py::object numpy_value = py::object (py::handle (other_obj), true );
1034+ py::object numpy_value =
1035+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
10281036 other_tensor = paddle::Tensor (place);
10291037 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
10301038 } else {
@@ -1125,7 +1133,8 @@ static PyObject* tensor__mod__method(TensorObject* self,
11251133 other_tensor = other_tensor_ref;
11261134 } else {
11271135 if (IsNumpyArray (other_obj)) {
1128- py::object numpy_value = py::object (py::handle (other_obj), true );
1136+ py::object numpy_value =
1137+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
11291138 other_tensor = paddle::Tensor (place);
11301139 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
11311140 } else {
@@ -1222,7 +1231,8 @@ static PyObject* tensor__matmul__method(TensorObject* self,
12221231 other_tensor = other_tensor_ref;
12231232 } else {
12241233 if (IsNumpyArray (other_obj)) {
1225- py::object numpy_value = py::object (py::handle (other_obj), true );
1234+ py::object numpy_value =
1235+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
12261236 other_tensor = paddle::Tensor (place);
12271237 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
12281238 } else {
@@ -1350,7 +1360,8 @@ static PyObject* tensor__lt__method(TensorObject* self,
13501360 other_tensor = other_tensor_ref;
13511361 } else {
13521362 if (IsNumpyArray (other_obj)) {
1353- py::object numpy_value = py::object (py::handle (other_obj), true );
1363+ py::object numpy_value =
1364+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
13541365 other_tensor = paddle::Tensor (place);
13551366 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
13561367 } else {
@@ -1450,7 +1461,8 @@ static PyObject* tensor__le__method(TensorObject* self,
14501461 other_tensor = other_tensor_ref;
14511462 } else {
14521463 if (IsNumpyArray (other_obj)) {
1453- py::object numpy_value = py::object (py::handle (other_obj), true );
1464+ py::object numpy_value =
1465+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
14541466 other_tensor = paddle::Tensor (place);
14551467 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
14561468 } else {
@@ -1551,7 +1563,8 @@ static PyObject* tensor__floordiv__method(TensorObject* self,
15511563 other_tensor = other_tensor_ref;
15521564 } else {
15531565 if (IsNumpyArray (other_obj)) {
1554- py::object numpy_value = py::object (py::handle (other_obj), true );
1566+ py::object numpy_value =
1567+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
15551568 other_tensor = paddle::Tensor (place);
15561569 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
15571570 } else {
@@ -1655,7 +1668,8 @@ static PyObject* tensor__pow__method(TensorObject* self,
16551668 other_tensor = other_tensor_ref;
16561669 } else {
16571670 if (IsNumpyArray (other_obj)) {
1658- py::object numpy_value = py::object (py::handle (other_obj), true );
1671+ py::object numpy_value =
1672+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
16591673 other_tensor = paddle::Tensor (place);
16601674 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
16611675 } else {
@@ -1755,7 +1769,8 @@ static PyObject* tensor__rpow__method(TensorObject* self,
17551769 other_tensor = other_tensor_ref;
17561770 } else {
17571771 if (IsNumpyArray (other_obj)) {
1758- py::object numpy_value = py::object (py::handle (other_obj), true );
1772+ py::object numpy_value =
1773+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
17591774 other_tensor = paddle::Tensor (place);
17601775 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
17611776 } else {
@@ -1855,7 +1870,8 @@ static PyObject* tensor__ne__method(TensorObject* self,
18551870 other_tensor = other_tensor_ref;
18561871 } else {
18571872 if (IsNumpyArray (other_obj)) {
1858- py::object numpy_value = py::object (py::handle (other_obj), true );
1873+ py::object numpy_value =
1874+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
18591875 other_tensor = paddle::Tensor (place);
18601876 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
18611877 } else {
@@ -1954,7 +1970,8 @@ static PyObject* tensor__eq__method(TensorObject* self,
19541970 other_tensor = other_tensor_ref;
19551971 } else {
19561972 if (IsNumpyArray (other_obj)) {
1957- py::object numpy_value = py::object (py::handle (other_obj), true );
1973+ py::object numpy_value =
1974+ py::reinterpret_borrow<py::object>(py::handle (other_obj));
19581975 other_tensor = paddle::Tensor (place);
19591976 InitTensorWithNumpyValue (numpy_value, place, &other_tensor);
19601977 } else {
0 commit comments