From fe8acb674e34e53718939746527ea77ec01d5fa1 Mon Sep 17 00:00:00 2001 From: From00 Date: Tue, 29 Mar 2022 10:39:00 +0800 Subject: [PATCH] Determine execution sequence of random OPs in new executor (#41012) --- .../new_executor/interpretercore_util.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/paddle/fluid/framework/new_executor/interpretercore_util.cc b/paddle/fluid/framework/new_executor/interpretercore_util.cc index 07fb60bd21..08f2dd3dc2 100644 --- a/paddle/fluid/framework/new_executor/interpretercore_util.cc +++ b/paddle/fluid/framework/new_executor/interpretercore_util.cc @@ -685,6 +685,22 @@ std::map> build_op_downstream_map( } } } + + // add dependences for random op, make sure that the random op is scheduled + // sequentially + const std::set random_op_set = { + "bernoulli", "poisson", "multinomial", "gaussian_random", + "uniform_random", "randint", "randperm", "exponential"}; + int dependence_op_idx = -1; + for (size_t op_idx = 0; op_idx < vec_instruction.size(); ++op_idx) { + if (random_op_set.count(vec_instruction[op_idx].OpBase()->Type())) { + if (dependence_op_idx != -1) { + op2dependences[op_idx].insert(dependence_op_idx); + } + dependence_op_idx = op_idx; + } + } + return std::move(get_downstream_map(op2dependences)); } -- GitLab