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

Function set_constant

paddle/phi/kernels/funcs/math_function.cc:277–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275};
276
277void set_constant(const DeviceContext& dev_ctx,
278 DenseTensor* tensor,
279 float value) {
280 TensorSetConstantWithPlace func(dev_ctx, tensor, value);
281#ifdef PADDLE_WITH_CUSTOM_DEVICE
282 if (dev_ctx.GetPlace().GetType() == AllocationType::CUSTOM) {
283 func(CustomPlace());
284 return;
285 }
286#endif
287#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
288 // tensor->place().apply_visitor(func);
289 phi::VisitPlace(tensor->place(), func);
290#elif defined(PADDLE_WITH_XPU)
291 if (dev_ctx.GetPlace().GetType() == AllocationType::XPU) {
292 func(phi::XPUPlace());
293 return;
294 } else {
295 func(CPUPlace());
296 }
297#else
298 func(CPUPlace());
299#endif
300}
301
302template struct ColwiseSum<CPUContext, float>;
303template struct ColwiseSum<CPUContext, double>;

Callers 15

applyMethod · 0.85
SumCooGradCPUKernelFunction · 0.85
SumCsrGradKernelFunction · 0.85
ArgsortKernelFunction · 0.85
TopkKernelFunction · 0.85
LogSoftmaxGradKernelFunction · 0.85
SoftmaxKernelFunction · 0.85
SoftmaxGradKernelFunction · 0.85
LogSoftmaxKernelFunction · 0.85
applyMethod · 0.85
NormDoubleGradFunctorFunction · 0.85

Calls 8

CustomPlaceClass · 0.85
VisitPlaceFunction · 0.85
funcFunction · 0.50
XPUPlaceClass · 0.50
CPUPlaceClass · 0.50
GetTypeMethod · 0.45
GetPlaceMethod · 0.45
placeMethod · 0.45

Tested by 2

TESTFunction · 0.68
PrepareInputsFunction · 0.68