MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / tensor__mod__method

Function tensor__mod__method

paddle/fluid/pybind/eager_math_op_patch.cc:1094–1201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1092 }
1093 }
1094
1095 // 3. calculation
1096 VLOG(6) << "Calling greater_than_ad_func in tensor__gt__method";
1097 {
1098 eager_gil_scoped_release guard;
1099 ret = greater_than_ad_func(self_tensor, other_tensor);
1100 }
1101
1102 return ToPyObject(ret);
1103 EAGER_CATCH_AND_THROW_RETURN_NULL
1104}
1105
1106static PyObject* tensor__ge__method(TensorObject* self,
1107 PyObject* args,
1108 PyObject* kwargs) {
1109 phi::RecordEvent pythonc_record_event(
1110 "__ge__ pybind_patch_func", phi::TracerEventType::UserDefined, 1);
1111
1112 EAGER_TRY
1113 VLOG(4) << "Running Eager tensor__ge__method";
1114
1115 SetPythonStack();
1116
1117 // Set Device ID
1118 auto place = egr::Controller::Instance().GetExpectedPlace();
1119 SetDevice(place);
1120
1121 Tensor ret;
1122 Tensor self_tensor = self->tensor;
1123 PyObject* other_obj = PyTuple_GET_ITEM(args, 0);
1124
1125 // 1. scalar exists cases
1126 // there is no scalar function for __ge__ now
1127 if (PyFloat_Check(other_obj) || PyCheckInteger(other_obj) ||
1128 IsNumpyType(other_obj)) {
1129 if (PyFloat_Check(other_obj)) {
1130 if (_supported_int_dtype_.find(self_tensor.dtype()) !=
1131 _supported_int_dtype_.end()) {
1132 eager_gil_scoped_release guard;
1133 self_tensor = cast_ad_func(self_tensor, DataType::FLOAT32);
1134 }
1135 } else if (PyCheckInteger(other_obj) &&
1136 self_tensor.dtype() == DataType::BOOL) {
1137 eager_gil_scoped_release guard;
1138 self_tensor = cast_ad_func(self_tensor, DataType::INT64);
1139 }
1140 } else if (PyComplex_Check(other_obj)) {
1141 if (is_support_complex(self_tensor.dtype()) == false) {
1142 eager_gil_scoped_release guard;
1143 self_tensor = cast_ad_func(
1144 self_tensor, promoteTypes(self_tensor.dtype(), DataType::COMPLEX64));
1145 }
1146 }
1147
1148 // 2. create or get tensor for other_obj
1149 Tensor other_tensor;
1150 if (PyCheckTensor(other_obj)) {
1151 auto& self_tensor_ref_addr = self->tensor;

Callers

nothing calls this directly

Calls 15

SetPythonStackFunction · 0.85
InstanceFunction · 0.85
is_support_complexFunction · 0.85
promoteTypesFunction · 0.85
PyCheckTensorFunction · 0.85
InputsContainDistTensorFunction · 0.85
CastPyArg2ScalarFunction · 0.85
GetExpectedPlaceMethod · 0.80
SetDeviceFunction · 0.70
PyCheckIntegerFunction · 0.70
IsNumpyTypeFunction · 0.70

Tested by

no test coverage detected