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

Method SupportCustomDevice

paddle/fluid/framework/operator.cc:1404–1437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1402}
1403
1404bool OperatorWithKernel::SupportCustomDevice() const {
1405#ifdef PADDLE_WITH_CUSTOM_DEVICE
1406 auto phi_kernels = phi::KernelFactory::Instance().SelectKernelMap(
1407 phi::TransToPhiKernelName(type_));
1408 auto has_phi_kernel =
1409 std::any_of(phi_kernels.begin(),
1410 phi_kernels.end(),
1411 [](phi::KernelKeyMap::const_reference kern_pair) {
1412 return phi::is_custom_place(
1413 phi::TransToPhiPlace(kern_pair.first.backend()));
1414 });
1415 if (has_phi_kernel) {
1416 return true;
1417 } else {
1418 auto kernel_iter = OperatorWithKernel::AllOpKernels().find(type_);
1419 if (kernel_iter == OperatorWithKernel::AllOpKernels().end()) {
1420 return false;
1421 } else {
1422 auto& op_kernels = kernel_iter->second;
1423 return std::any_of(op_kernels.begin(),
1424 op_kernels.end(),
1425 [this](OpKernelMap::const_reference kern_pair) {
1426 return phi::is_custom_place(kern_pair.first.place_);
1427 });
1428 }
1429 }
1430#else
1431 PADDLE_THROW(common::errors::PreconditionNotMet(
1432 "should not call OperatorWithKernel::SupportCustomDevice() when not "
1433 "compiled with "
1434 "CustomDevice support."));
1435 return false;
1436#endif
1437}
1438
1439bool OperatorWithKernel::SupportsONEDNN(const phi::DataType data_type) const {
1440 auto phi_kernels = phi::KernelFactory::Instance().SelectKernelMap(

Callers 1

ApplyDeviceGuardFunction · 0.80

Calls 8

InstanceFunction · 0.85
is_custom_placeFunction · 0.85
TransToPhiPlaceFunction · 0.85
SelectKernelMapMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
backendMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected