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

Method RegisterCustomKernels

paddle/phi/core/custom_kernel.cc:40–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void CustomKernelMap::RegisterCustomKernels() {
41 VLOG(3) << "Size of custom_kernel_map: " << kernels_.size();
42
43 if (kernels_.empty()) {
44 LOG(INFO) << "No custom kernel info found in loaded lib(s).";
45 return;
46 }
47 auto& kernels = KernelFactory::Instance().kernels();
48 for (auto& pair : kernels_) {
49 for (auto& info_pair : pair.second) {
50 PADDLE_ENFORCE_EQ(
51 kernels[pair.first].find(info_pair.first),
52 kernels[pair.first].end(),
53 common::errors::AlreadyExists(
54 "The kernel [%s:%s] has been already existed "
55 "in Paddle, please contribute PR if it is necessary "
56 "to optimize the kernel code. Custom kernel does NOT support "
57 "to replace existing kernel in Paddle.",
58 pair.first,
59 info_pair.first));
60
61 kernels[pair.first][info_pair.first] = info_pair.second;
62
63 VLOG(3) << "Succeed in registering kernel [" << pair.first << ":"
64 << info_pair.first
65 << "] to Paddle. It will be used like native ones.";
66 }
67 }
68 LOG(INFO) << "Succeed in loading " << kernels_.size()
69 << " custom kernel(s) from loaded lib(s), will be "
70 << "used like native ones.";
71 kernels_.clear();
72}
73
74} // namespace phi

Callers 2

LoadCustomDeviceFunction · 0.80
TESTFunction · 0.80

Calls 6

InstanceFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
clearMethod · 0.45

Tested by 1

TESTFunction · 0.64