From 2190da20f7a555afd2356cfc19252c74ac457598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Siwek?= Date: Tue, 11 Oct 2022 15:04:02 +0200 Subject: [PATCH] add seed check (#46858) --- 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 b8259754d0b..abed20b9cb0 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