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

Function OpSupportGPU

paddle/fluid/framework/operator.cc:1225–1258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1223}
1224
1225bool OpSupportGPU(const std::string& op_type) {
1226 // check in new Function kernel first
1227 bool has_phi_kernel = false;
1228 auto& kernel_factory = phi::KernelFactory::Instance();
1229 auto kernel_key_map =
1230 kernel_factory.SelectKernelMap(phi::TransToPhiKernelName(op_type));
1231 for (auto& kernel : kernel_key_map) {
1232 has_phi_kernel = true;
1233 if (phi::is_gpu_place(phi::TransToPhiPlace(kernel.first.backend()))) {
1234 return true;
1235 }
1236 }
1237
1238 auto& all_kernels = OperatorWithKernel::AllOpKernels();
1239 auto it = all_kernels.find(op_type);
1240 if (it != all_kernels.end()) {
1241 for (auto& kern_pair : it->second) {
1242 if (phi::is_gpu_place(kern_pair.first.place_)) {
1243 return true;
1244 }
1245 }
1246 } else {
1247 if (has_phi_kernel) {
1248 // if has phi kernel, but not find phi gpu kernel and fluid gpu kernel,
1249 // this op doesn't support GPU
1250 return false;
1251 } else {
1252 // All control operator must support GPU
1253 return true;
1254 }
1255 }
1256
1257 return false;
1258}
1259
1260struct OperatorWithKernel::CacheImpl {
1261 static const char kNotAllowInferShapeCache[]; // NOLINT

Callers

nothing calls this directly

Calls 7

InstanceFunction · 0.85
is_gpu_placeFunction · 0.85
TransToPhiPlaceFunction · 0.85
SelectKernelMapMethod · 0.80
backendMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected