| 1223 | } |
| 1224 | |
| 1225 | bool 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 | |
| 1260 | struct OperatorWithKernel::CacheImpl { |
| 1261 | static const char kNotAllowInferShapeCache[]; // NOLINT |
nothing calls this directly
no test coverage detected