NOTE(chenweihang): For safety reasons, we now only * perform type promotes for binary operations with * complex type inputs, which is used to support the * paddle quantum function. * In other cases, the first input data type is used as * the kernel data type. */
| 3028 | * the kernel data type. |
| 3029 | */ |
| 3030 | proto::VarType::Type OperatorWithKernel::IndicateOrPromoteVarDataTypes( |
| 3031 | const ExecutionContext& ctx, |
| 3032 | const std::string& name1, |
| 3033 | const std::string& name2) const { |
| 3034 | // 1. Get tensor |
| 3035 | auto* tensor_a = GetTensorFormInputSafely(ctx, name1); |
| 3036 | auto* tensor_b = GetTensorFormInputSafely(ctx, name2); |
| 3037 | |
| 3038 | // 2. Get two input types |
| 3039 | auto type_a = framework::TransToProtoVarType(tensor_a->dtype()); |
| 3040 | auto type_b = framework::TransToProtoVarType(tensor_b->dtype()); |
| 3041 | |
| 3042 | // 3. Get first input type or promote complex types |
| 3043 | auto target_type = PromoteTypesIfComplexExists(type_a, type_b); |
| 3044 | |
| 3045 | return target_type; |
| 3046 | } |
| 3047 | |
| 3048 | phi::KernelKey OperatorWithKernel::GetExpectedKernelType( |
| 3049 | const ExecutionContext& ctx) const { |
nothing calls this directly
no test coverage detected