Skip to content

Commit 15c4687

Browse files
committed
optimize phi::CPUPlace in kernels/impl/
1 parent ea557ba commit 15c4687

17 files changed

+27
-29
lines changed

paddle/phi/kernels/impl/accuracy_check_kernel_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ struct AccuracyCheckFunctor<phi::GPUContext, T> {
251251
in_data, other_data, rtol, atol, equal_nan, num, out_data);
252252

253253
DenseTensor out_cpu;
254-
Copy(dev_ctx, *output, phi::CPUPlace(), true, &out_cpu);
254+
Copy(dev_ctx, *output, CPUPlace(), true, &out_cpu);
255255
auto data_ptr = out_cpu.data<bool>();
256256

257257
PADDLE_ENFORCE_EQ(*data_ptr,

paddle/phi/kernels/impl/average_accumulates_kernel_impl.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,17 @@ void AverageAccumulatesKernel(const Context& dev_ctx,
4848
// int64_t num_accumulates = 0;
4949
// int64_t old_num_accumulates = 0;
5050

51-
auto num_updates_cpu =
52-
phi::memory_utils::Alloc(phi::CPUPlace(), sizeof(int64_t));
51+
auto num_updates_cpu = phi::memory_utils::Alloc(CPUPlace(), sizeof(int64_t));
5352
int64_t* num_updates_cpu_ptr =
5453
reinterpret_cast<int64_t*>(num_updates_cpu->ptr());
5554

5655
auto num_accumulates_cpu =
57-
phi::memory_utils::Alloc(phi::CPUPlace(), sizeof(int64_t));
56+
phi::memory_utils::Alloc(CPUPlace(), sizeof(int64_t));
5857
int64_t* num_accumulates_cpu_ptr =
5958
reinterpret_cast<int64_t*>(num_accumulates_cpu->ptr());
6059

6160
auto old_num_accumulates_cpu =
62-
phi::memory_utils::Alloc(phi::CPUPlace(), sizeof(int64_t));
61+
phi::memory_utils::Alloc(CPUPlace(), sizeof(int64_t));
6362
int64_t* old_num_accumulates_cpu_ptr =
6463
reinterpret_cast<int64_t*>(old_num_accumulates_cpu->ptr());
6564

paddle/phi/kernels/impl/beam_search_decode_kernel_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct BeamSearchDecodeFunctor {
4949
if (tensor_on_gpu_) {
5050
dev_ctx->Wait();
5151
}
52-
Copy(*dev_ctx, step_id, phi::CPUPlace(), false, &out);
52+
Copy(*dev_ctx, step_id, CPUPlace(), false, &out);
5353
dev_ctx->Wait();
5454
}
5555

@@ -72,7 +72,7 @@ struct BeamSearchDecodeFunctor {
7272
if (tensor_on_gpu_) {
7373
dev_ctx->Wait();
7474
}
75-
Copy(*dev_ctx, step_score, phi::CPUPlace(), false, &out);
75+
Copy(*dev_ctx, step_score, CPUPlace(), false, &out);
7676
dev_ctx->Wait();
7777
}
7878

paddle/phi/kernels/impl/clip_by_norm_kernel_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void ClipByNormFunctor(const Context& dev_ctx,
4545
temp + (static_cast<T>(1) - temp) * max_norm / (x_norm + epsilon);
4646
Eigen::array<int, 1> one_dim{{1}};
4747
Eigen::DSizes<int, 1> m_dsize(input->numel());
48-
if (dev_ctx.GetPlace() == phi::CPUPlace()) {
48+
if (dev_ctx.GetPlace() == CPUPlace()) {
4949
out.device(*place) = x * scaling.reshape(one_dim).eval().broadcast(m_dsize);
5050
} else {
5151
out.device(*place) = x * scaling.reshape(one_dim).broadcast(m_dsize);

paddle/phi/kernels/impl/determinant_grad_kernel_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ inline bool CheckMatrixInvertible(const Context& dev_ctx,
9292

9393
// copy to host
9494
DenseTensor cpu_tensor;
95-
Copy<Context>(dev_ctx, dev_tensor, phi::CPUPlace(), false, &cpu_tensor);
95+
Copy<Context>(dev_ctx, dev_tensor, CPUPlace(), false, &cpu_tensor);
9696

9797
// if founded zero, the matrix is not invertible
9898
// else the matrix is invertible

paddle/phi/kernels/impl/fetch_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void FetchKernel(const Context& dev_ctx,
2626
if (!x.IsInitialized()) {
2727
return;
2828
}
29-
Copy(dev_ctx, x, phi::CPUPlace(), true, out);
29+
Copy(dev_ctx, x, CPUPlace(), true, out);
3030
}
3131

3232
template <typename T, typename Context>
@@ -35,7 +35,7 @@ void FetchArrayKernel(const Context& dev_ctx,
3535
TensorArray* out) {
3636
out->resize(x.size());
3737
for (size_t i = 0; i < x.size(); ++i) {
38-
Copy(dev_ctx, x[i], phi::CPUPlace(), true, &(out->at(i)));
38+
Copy(dev_ctx, x[i], CPUPlace(), true, &(out->at(i)));
3939
}
4040
}
4141

paddle/phi/kernels/impl/gru_unit_kernel_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void ActCompute(
3535
} else if (act_type == tanh) {
3636
funcs::TanhFunctor<T>()(d, x, y);
3737
} else if (act_type == relu) {
38-
if (place == phi::CPUPlace())
38+
if (place == CPUPlace())
3939
funcs::ReluCPUFunctor<T>()(d, x, y);
4040
else
4141
funcs::ReluCUDAFunctor<T>()(d, x, y);

paddle/phi/kernels/impl/im2sequence_kernel_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void Im2SequenceKernel(const Context& dev_ctx,
5050
const DenseTensor* img_real_size = y.get_ptr();
5151

5252
DenseTensor cpu_shape_tensor;
53-
Copy(dev_ctx, *img_real_size, phi::CPUPlace(), true, &cpu_shape_tensor);
53+
Copy(dev_ctx, *img_real_size, CPUPlace(), true, &cpu_shape_tensor);
5454
std::vector<int> img_real_h;
5555
std::vector<int> img_real_w;
5656
std::vector<int> output_height;

paddle/phi/kernels/impl/isclose_kernel_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ struct GetTensorValue<phi::GPUContext, T> {
267267
T value;
268268
const auto gpu_place = dev_ctx.GetPlace();
269269
memory_utils::Copy(
270-
phi::CPUPlace(), &value, gpu_place, data, sizeof(T), dev_ctx.stream());
270+
CPUPlace(), &value, gpu_place, data, sizeof(T), dev_ctx.stream());
271271
return value;
272272
}
273273
};

paddle/phi/kernels/impl/lamb_kernel_impl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ void ComputeImpl(const Context& dev_ctx,
186186
// Diff from here
187187

188188
if (dev_ctx.GetPlace().GetType() == AllocationType::GPU &&
189-
beta1_pow.place() == phi::CPUPlace() &&
190-
beta2_pow.place() == phi::CPUPlace()) {
189+
beta1_pow.place() == CPUPlace() && beta2_pow.place() == CPUPlace()) {
191190
LambMomentREGUpdateFunctor<T, IsMultiPrecision> moment_update_functor(
192191
weight_decay,
193192
beta1,

0 commit comments

Comments
 (0)