diff --git a/paddle/phi/kernels/onednn/gaussian_random_kernel.cc b/paddle/phi/kernels/onednn/gaussian_random_kernel.cc index b8259754d0b84eb035487c5412cf1a58b1d9834a..abed20b9cb0653556d8f3f607f9606c96ce2204c 100644 --- a/paddle/phi/kernels/onednn/gaussian_random_kernel.cc +++ b/paddle/phi/kernels/onednn/gaussian_random_kernel.cc @@ -28,8 +28,13 @@ void GaussianRandomKernel(const Context& ctx, DataType dtype, DenseTensor* out) { std::normal_distribution dist(mean, std); - auto engine = std::make_shared(); - engine->seed(seed); + std::shared_ptr engine; + if (seed) { + engine = std::make_shared(); + engine->seed(seed); + } else { + engine = ctx.GetGenerator()->GetCPUEngine(); + } T* data = ctx.template Alloc(out); for (int64_t i = 0; i < out->numel(); ++i) {