Skip to content

Commit 429e93f

Browse files
committed
Revert "Add fused_dropout wrapper to ease use. (PaddlePaddle#36185) (PaddlePaddle#36640)"
This reverts commit 05d7e2f.
1 parent c57d1e9 commit 429e93f

File tree

3 files changed

+22
-338
lines changed

3 files changed

+22
-338
lines changed

paddle/fluid/operators/dropout_impl.cu.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ limitations under the License. */
3030
#include "paddle/fluid/framework/eigen.h"
3131
#include "paddle/fluid/framework/generator.h"
3232
#include "paddle/fluid/framework/tensor_util.h"
33-
#include "paddle/fluid/operators/dropout_impl_util.h"
3433
#include "paddle/fluid/operators/dropout_op.h"
3534
#include "paddle/fluid/platform/aligned_vector.h"
3635
#include "paddle/fluid/platform/gpu_launch_config.h"
@@ -197,8 +196,28 @@ void DropoutFwGPUKernelDriver(const platform::CUDADeviceContext& dev_ctx,
197196
config.thread_per_block.x * vec_size) +
198197
1) *
199198
vec_size;
200-
GetSeedDataAndIncrement(dev_ctx, seed, is_fix_seed, seed_val, offset,
201-
&seed_data, &increment);
199+
int device_id =
200+
BOOST_GET_CONST(platform::CUDAPlace, dev_ctx.GetPlace()).GetDeviceId();
201+
auto gen_cuda = framework::GetDefaultCUDAGenerator(device_id);
202+
203+
if ((seed) && platform::is_gpu_place(seed->place())) {
204+
framework::Tensor seed_cpu_tensor;
205+
TensorCopySync(*seed, platform::CPUPlace(), &seed_cpu_tensor);
206+
seed_data = static_cast<uint64_t>(seed_cpu_tensor.data<int>()[0]);
207+
increment = offset;
208+
} else if (gen_cuda->GetIsInitPy() && (!is_fix_seed)) {
209+
auto seed_offset = gen_cuda->IncrementOffset(offset);
210+
seed_data = seed_offset.first;
211+
increment = seed_offset.second;
212+
} else {
213+
if (seed) {
214+
seed_data = *(seed->data<int>());
215+
} else {
216+
std::random_device rnd;
217+
seed_data = is_fix_seed ? seed_val : rnd();
218+
}
219+
increment = offset;
220+
}
202221

203222
#ifdef __HIPCC__
204223
if (vec_size == 4 && size % 4 == 0) {

paddle/fluid/operators/dropout_impl_util.h

Lines changed: 0 additions & 53 deletions
This file was deleted.

paddle/fluid/operators/fused/fused_dropout_helper.h

Lines changed: 0 additions & 282 deletions
This file was deleted.

0 commit comments

Comments
 (0)