Skip to content

Commit

Permalink
add seed check (#46747)
Browse files Browse the repository at this point in the history
  • Loading branch information
Silv3S authored Oct 9, 2022
1 parent ff0171e commit 97ec57f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions paddle/phi/kernels/onednn/gaussian_random_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ void GaussianRandomKernel(const Context& ctx,
DataType dtype,
DenseTensor* out) {
std::normal_distribution<T> dist(mean, std);
auto engine = std::make_shared<std::mt19937_64>();
engine->seed(seed);
std::shared_ptr<std::mt19937_64> engine;
if (seed) {
engine = std::make_shared<std::mt19937_64>();
engine->seed(seed);
} else {
engine = ctx.GetGenerator()->GetCPUEngine();
}

T* data = ctx.template Alloc<T>(out);
for (int64_t i = 0; i < out->numel(); ++i) {
Expand Down

0 comments on commit 97ec57f

Please # to comment.