| 707 | return ToPyObject(ret); |
| 708 | |
| 709 | EAGER_CATCH_AND_THROW_RETURN_NULL |
| 710 | } |
| 711 | |
| 712 | static PyObject* tensor__div__method(TensorObject* self, |
| 713 | PyObject* args, |
| 714 | PyObject* kwargs) { |
| 715 | phi::RecordEvent pythonc_record_event( |
| 716 | "__div__ pybind_patch_func", phi::TracerEventType::UserDefined, 1); |
| 717 | |
| 718 | EAGER_TRY |
| 719 | |
| 720 | VLOG(6) << "Running Eager tensor__div__method"; |
| 721 | |
| 722 | SetPythonStack(); |
| 723 | |
| 724 | // Set Device ID |
| 725 | auto place = egr::Controller::Instance().GetExpectedPlace(); |
| 726 | SetDevice(place); |
| 727 | |
| 728 | Tensor ret; |
| 729 | |
| 730 | Tensor self_tensor = self->tensor; |
| 731 | PyObject* other_obj = PyTuple_GET_ITEM(args, 0); |
| 732 | |
| 733 | // 1. scalar exists cases |
| 734 | if (PyFloat_Check(other_obj) || PyCheckInteger(other_obj) || |
| 735 | IsNumpyType(other_obj)) { |
| 736 | if (_supported_int_dtype_.find(self_tensor.dtype()) != |
| 737 | _supported_int_dtype_.end()) { |
| 738 | eager_gil_scoped_release guard; |
| 739 | self_tensor = cast_ad_func(self_tensor, DataType::FLOAT32); |
| 740 | } |
| 741 | |
| 742 | double other = CastPyArg2Double(other_obj, "__div__", 0); |
| 743 | { |
| 744 | eager_gil_scoped_release guard; |
| 745 | ret = CallScalarFunction(self_tensor, other, "div"); |
| 746 | } |
| 747 | return ToPyObject(ret); |
| 748 | } else if (PyComplex_Check(other_obj)) { |
| 749 | if (is_support_complex(self_tensor.dtype()) == false) { |
| 750 | eager_gil_scoped_release guard; |
| 751 | self_tensor = cast_ad_func( |
| 752 | self_tensor, promoteTypes(self_tensor.dtype(), DataType::COMPLEX64)); |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | // 2. create or get tensor for other_obj |
| 757 | Tensor other_tensor; |
| 758 | if (PyCheckTensor(other_obj)) { |
| 759 | auto& self_tensor_ref_addr = self->tensor; |
| 760 | auto& other_tensor_ref_addr = CastPyArg2Tensor(other_obj, 0); |
| 761 | const phi::distributed::ProcessMesh* mesh = nullptr; |
| 762 | if (InputsContainDistTensor( |
| 763 | &mesh, self_tensor_ref_addr, other_tensor_ref_addr)) { |
| 764 | ConvertAllInputsToDistTensor( |
| 765 | mesh, self_tensor_ref_addr, other_tensor_ref_addr); |
| 766 | } |
nothing calls this directly
no test coverage detected