From 97ec57fe34bed646501aa17d57b7863ec39175f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Siwek?= Date: Sun, 9 Oct 2022 05:39:47 +0200 Subject: [PATCH] add seed check (#46747) --- paddle/phi/kernels/onednn/gaussian_random_kernel.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/paddle/phi/kernels/onednn/gaussian_random_kernel.cc b/paddle/phi/kernels/onednn/gaussian_random_kernel.cc index 853cbfaa8a3..77331e5c32e 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) { -- GitLab