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

Method IndicateOrPromoteVarDataTypes

paddle/fluid/framework/operator.cc:3030–3046  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

3028 * the kernel data type.
3029 */
3030proto::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
3048phi::KernelKey OperatorWithKernel::GetExpectedKernelType(
3049 const ExecutionContext& ctx) const {

Callers

nothing calls this directly

Calls 3

TransToProtoVarTypeFunction · 0.70
dtypeMethod · 0.45

Tested by

no test coverage detected