Skip to content

Commit 5bf082b

Browse files
committed
Merge branch 'develop' into e11
2 parents 02268b1 + 5d39519 commit 5bf082b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+627
-530
lines changed

paddle/fluid/primitive/decomp_rule/decomp_vjp/details.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,12 @@ void index_put_grad(const Tensor& x,
485485
indices.cend(),
486486
[](const Tensor& t) { return has_dynamic_shape(t.shape()); }) ||
487487
has_dynamic_shape(out_grad.shape())) {
488-
for (int i = 0; i < indices.size(); ++i) {
488+
for (size_t i = 0; i < indices.size(); ++i) {
489489
indices_vec.push_back(backend::unsqueeze<T>(
490490
indices[i], full<T>({1}, -1, DataType::INT64, indices[i].place())));
491491
}
492492
} else {
493-
for (int i = 0; i < indices.size(); ++i) {
493+
for (size_t i = 0; i < indices.size(); ++i) {
494494
indices_vec.push_back(unsqueeze<T>(indices[i], {-1}));
495495
}
496496
}
@@ -617,7 +617,7 @@ void index_add_grad(const Tensor& index,
617617
auto index_expand_shape = std::vector<int64_t>(out_grad_shape.size(), 1);
618618
auto index_unsqueeze_shape =
619619
std::vector<int64_t>(out_grad_shape.size(), 1);
620-
for (int i = 0; i < out_grad_shape.size(); ++i) {
620+
for (int i = 0; i < static_cast<int>(out_grad_shape.size()); ++i) {
621621
if (i != axis) {
622622
index_expand_shape.at(i) = out_grad_shape.at(i);
623623
} else {

paddle/phi/backends/xpu/xpu_context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ struct XPUContext::Impl {
169169
errors::PreconditionNotMet(
170170
"No ctx_guard when overload_free is called"));
171171
allocations_to_free_.pop_back();
172-
VLOG(3) << "XHPC ctx_guard destropyed, " << GetStackLevel()
172+
VLOG(3) << "XHPC ctx_guard destroyed, " << GetStackLevel()
173173
<< " are in use now.";
174174
}
175175

paddle/phi/infermeta/multiary.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,13 +2625,13 @@ void FusedLayerNormInferMeta(const MetaTensor& x,
26252625
auto x_dims_size = x_dims_vec.size();
26262626

26272627
int64_t normalized_dims = 1;
2628-
for (int i = begin_norm_axis; i < x_dims_size; ++i) {
2628+
for (size_t i = begin_norm_axis; i < x_dims_size; ++i) {
26292629
normalized_dims *= x_dims_vec[i];
26302630
}
26312631

26322632
if (residual) {
26332633
std::vector<int64_t> residual_dims_vec = common::vectorize(residual.dims());
2634-
for (int i = 0; i < x_dims_vec.size(); ++i) {
2634+
for (size_t i = 0; i < x_dims_vec.size(); ++i) {
26352635
if (x_dims_vec[i] == -1 || residual_dims_vec[i] == -1) continue;
26362636

26372637
PADDLE_ENFORCE_EQ(x_dims_vec[i],

paddle/phi/kernels/cpu/grid_sample_kernel.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static void BilinearInter(const CPUContext& dev_ctx,
209209
auto v_ws_t = EigenTensor<T, 4>::From(v_ws);
210210
auto v_es_t = EigenTensor<T, 4>::From(v_es);
211211
auto output_t = EigenTensor<T, 4>::From(*out);
212-
// bilinear interpolaetion by 4 corner points
212+
// bilinear interpolation by 4 corner points
213213
output_t.device(place) = v_wn_t * d_e_scaled_t * d_s_scaled_t +
214214
v_en_t * d_w_scaled_t * d_s_scaled_t +
215215
v_ws_t * d_e_scaled_t * d_n_scaled_t +
@@ -292,7 +292,7 @@ static void Bilinear3DInter(const CPUContext& dev_ctx,
292292
auto v_bws_t = EigenTensor<T, 5>::From(v_bws);
293293
auto v_bes_t = EigenTensor<T, 5>::From(v_bes);
294294
auto output_t = EigenTensor<T, 5>::From(*out);
295-
// bilinear interpolaetion by 4 corner points
295+
// bilinear interpolation by 4 corner points
296296
output_t.device(place) =
297297
v_twn_t * d_e_scaled_t * d_s_scaled_t * d_b_scaled_t +
298298
v_ten_t * d_w_scaled_t * d_s_scaled_t * d_b_scaled_t +

paddle/phi/kernels/funcs/batch_norm_utils.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace phi {
2323
using Tensor = DenseTensor;
2424

2525
template <typename DeviceContext, typename T>
26-
inline void ResizeToChannelFirst(const DeviceContext& context,
26+
inline void ResizeToChannelFirst(const DeviceContext& dev_ctx,
2727
const Tensor* input,
2828
Tensor* transformed_input) {
2929
int dim = input->dims().size() - 2;
@@ -37,7 +37,7 @@ inline void ResizeToChannelFirst(const DeviceContext& context,
3737
in_dims_vec[3] = input->dims()[2];
3838
in_dims_vec[4] = input->dims()[3];
3939
transformed_input->Resize(common::make_ddim(in_dims_vec));
40-
context.template Alloc<T>(transformed_input);
40+
dev_ctx.template Alloc<T>(transformed_input);
4141
} else if (dim == 2) {
4242
// input
4343
transformed_input->Resize(input->dims());
@@ -47,20 +47,20 @@ inline void ResizeToChannelFirst(const DeviceContext& context,
4747
in_dims_vec[2] = input->dims()[1];
4848
in_dims_vec[3] = input->dims()[2];
4949
transformed_input->Resize(common::make_ddim(in_dims_vec));
50-
context.template Alloc<T>(transformed_input);
50+
dev_ctx.template Alloc<T>(transformed_input);
5151
} else if (dim == 1) {
5252
transformed_input->Resize(input->dims());
5353

5454
auto in_dims_vec = common::vectorize(input->dims());
5555
in_dims_vec[1] = input->dims()[2];
5656
in_dims_vec[2] = input->dims()[1];
5757
transformed_input->Resize(common::make_ddim(in_dims_vec));
58-
context.template Alloc<T>(transformed_input);
58+
dev_ctx.template Alloc<T>(transformed_input);
5959
}
6060
}
6161

6262
template <typename DeviceContext, typename T>
63-
inline void ResizeToChannelLast(const DeviceContext& context,
63+
inline void ResizeToChannelLast(const DeviceContext& dev_ctx,
6464
const Tensor* input,
6565
Tensor* transformed_input) {
6666
int dim = input->dims().size() - 2;
@@ -74,7 +74,7 @@ inline void ResizeToChannelLast(const DeviceContext& context,
7474
in_dims_vec[3] = input->dims()[4];
7575
in_dims_vec[4] = input->dims()[1];
7676
transformed_input->Resize(common::make_ddim(in_dims_vec));
77-
context.template Alloc<T>(transformed_input);
77+
dev_ctx.template Alloc<T>(transformed_input);
7878

7979
} else if (dim == 2) {
8080
// input
@@ -85,58 +85,58 @@ inline void ResizeToChannelLast(const DeviceContext& context,
8585
in_dims_vec[2] = input->dims()[3];
8686
in_dims_vec[3] = input->dims()[1];
8787
transformed_input->Resize(common::make_ddim(in_dims_vec));
88-
context.template Alloc<T>(transformed_input);
88+
dev_ctx.template Alloc<T>(transformed_input);
8989
} else if (dim == 1) {
9090
transformed_input->Resize(input->dims());
9191

9292
auto in_dims_vec = common::vectorize(input->dims());
9393
in_dims_vec[1] = input->dims()[2];
9494
in_dims_vec[2] = input->dims()[1];
9595
transformed_input->Resize(common::make_ddim(in_dims_vec));
96-
context.template Alloc<T>(transformed_input);
96+
dev_ctx.template Alloc<T>(transformed_input);
9797
}
9898
}
9999

100100
template <typename DeviceContext, typename T>
101-
inline void TransToChannelFirst(const DeviceContext& context,
101+
inline void TransToChannelFirst(const DeviceContext& dev_ctx,
102102
const Tensor* input,
103103
Tensor* transformed_input) {
104104
VLOG(5) << "Why am I called?";
105105
int dim = input->dims().size() - 2;
106106
if (dim == 3) {
107107
std::vector<int> axis{0, 4, 1, 2, 3};
108108
phi::funcs::Transpose<DeviceContext, T, 5> trans5;
109-
trans5(context, *input, transformed_input, axis);
109+
trans5(dev_ctx, *input, transformed_input, axis);
110110

111111
} else if (dim == 2) {
112112
std::vector<int> axis{0, 3, 1, 2};
113113
phi::funcs::Transpose<DeviceContext, T, 4> trans4;
114-
trans4(context, *input, transformed_input, axis);
114+
trans4(dev_ctx, *input, transformed_input, axis);
115115
} else if (dim == 1) {
116116
std::vector<int> axis{0, 2, 1};
117117
phi::funcs::Transpose<DeviceContext, T, 3> trans3;
118-
trans3(context, *input, transformed_input, axis);
118+
trans3(dev_ctx, *input, transformed_input, axis);
119119
}
120120
}
121121

122122
template <typename DeviceContext, typename T>
123-
inline void TransToChannelLast(const DeviceContext& context,
123+
inline void TransToChannelLast(const DeviceContext& dev_ctx,
124124
const Tensor* input,
125125
Tensor* transformed_input) {
126126
int dim = input->dims().size() - 2;
127127
if (dim == 3) {
128128
std::vector<int> axis{0, 2, 3, 4, 1};
129129
phi::funcs::Transpose<DeviceContext, T, 5> trans5;
130-
trans5(context, *input, transformed_input, axis);
130+
trans5(dev_ctx, *input, transformed_input, axis);
131131

132132
} else if (dim == 2) {
133133
std::vector<int> axis{0, 2, 3, 1};
134134
phi::funcs::Transpose<DeviceContext, T, 4> trans4;
135-
trans4(context, *input, transformed_input, axis);
135+
trans4(dev_ctx, *input, transformed_input, axis);
136136
} else if (dim == 1) {
137137
std::vector<int> axis{0, 2, 1};
138138
phi::funcs::Transpose<DeviceContext, T, 3> trans3;
139-
trans3(context, *input, transformed_input, axis);
139+
trans3(dev_ctx, *input, transformed_input, axis);
140140
}
141141
}
142142

paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@ void hl_avx_gru_forward_final_output(OpFinalOutput op_final_output,
285285
}
286286

287287
template <typename T, typename Context>
288-
inline void forward_reset_outputV2(const Context &context,
288+
inline void forward_reset_outputV2(const Context &dev_ctx,
289289
phi::funcs::GRUMetaValue<T> value,
290290
int frame_size) {
291-
auto &place = *context.eigen_device();
291+
auto &place = *dev_ctx.eigen_device();
292292
auto value_reset_gate =
293293
typename EigenVector<T>::Type(value.gate_value, Array1(frame_size));
294294
auto value_update_gate = typename EigenVector<T>::Type(
@@ -310,11 +310,11 @@ inline void forward_reset_output(OpResetOutput op_reset_output,
310310
int batch_size,
311311
ActivationType active_gate,
312312
bool old_version = true,
313-
const Context *context = nullptr) {
313+
const Context *dev_ctx = nullptr) {
314314
for (int b = 0; b < batch_size; b++) {
315315
if (!old_version) {
316316
// use eigen
317-
forward_reset_outputV2(*context, value, frame_size);
317+
forward_reset_outputV2(*dev_ctx, value, frame_size);
318318
} else {
319319
if (OpResetOutput::avx && (frame_size > static_cast<int>(8 - 1)) &&
320320
(sizeof(T) == 4)) {
@@ -346,10 +346,10 @@ inline void forward_reset_output(OpResetOutput op_reset_output,
346346
}
347347

348348
template <typename T, typename Context>
349-
inline void forward_final_outputV2(const Context &context,
349+
inline void forward_final_outputV2(const Context &dev_ctx,
350350
phi::funcs::GRUMetaValue<T> value,
351351
int frame_size) {
352-
auto &place = *context.eigen_device();
352+
auto &place = *dev_ctx.eigen_device();
353353
auto value_update_gate = typename EigenVector<T>::Type(
354354
value.gate_value + frame_size, Array1(frame_size));
355355
auto value_frame_state = typename EigenVector<T>::Type(
@@ -375,11 +375,11 @@ inline void forward_final_output(OpFinalOutput op_final_output,
375375
ActivationType active_node,
376376
bool origin_mode,
377377
bool old_version = true,
378-
const Context *context = nullptr) {
378+
const Context *dev_ctx = nullptr) {
379379
for (int b = 0; b < batch_size; b++) {
380380
if (!old_version) {
381381
// eigen
382-
forward_final_outputV2(*context, value, frame_size);
382+
forward_final_outputV2(*dev_ctx, value, frame_size);
383383
} else {
384384
if (OpFinalOutput::avx && (frame_size > static_cast<int>(8 - 1)) &&
385385
(sizeof(T) == 4)) {
@@ -866,11 +866,11 @@ inline void backward_reset_grad(OpResetGrad op_reset_grad,
866866
}
867867

868868
template <typename T, typename Context>
869-
inline void gru_backward(const Context &context,
869+
inline void gru_backward(const Context &dev_ctx,
870870
phi::funcs::GRUMetaValue<T> value,
871871
phi::funcs::GRUMetaGrad<T> grad,
872872
int frame_size) {
873-
auto &place = *context.eigen_device();
873+
auto &place = *dev_ctx.eigen_device();
874874

875875
auto value_reset_gate =
876876
typename EigenVector<T>::Type(value.gate_value, Array1(frame_size));
@@ -931,7 +931,7 @@ inline void gru_backward(const Context &context,
931931
}
932932

933933
template <class OpGruGrad, typename T, typename Context>
934-
inline void cpu_gru_backward(const Context &context,
934+
inline void cpu_gru_backward(const Context &dev_ctx,
935935
OpGruGrad op_gru_grad UNUSED,
936936
phi::funcs::GRUMetaValue<T> value,
937937
phi::funcs::GRUMetaGrad<T> grad,
@@ -941,7 +941,7 @@ inline void cpu_gru_backward(const Context &context,
941941
ActivationType active_gate UNUSED) {
942942
for (int b = 0; b < batch_size; ++b) {
943943
// eigen
944-
gru_backward(context, value, grad, frame_size);
944+
gru_backward(dev_ctx, value, grad, frame_size);
945945

946946
value.gate_value += frame_size * 3;
947947
value.reset_output_value += frame_size;

paddle/phi/kernels/funcs/detail/lstm_cpu_kernel.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ void avx_lstm_backward_one_sequence(Op op,
411411
}
412412

413413
template <class T, class Context>
414-
void eigen_lstm_forward_one_sequence(const Context &context,
414+
void eigen_lstm_forward_one_sequence(const Context &dev_ctx,
415415
phi::funcs::LstmMetaValue<T> value,
416416
int frame_size) {
417417
auto eigen_value_ig =
@@ -429,7 +429,7 @@ void eigen_lstm_forward_one_sequence(const Context &context,
429429
auto eigen_output =
430430
typename EigenVector<T>::Type(value.output_value, Array1(frame_size));
431431

432-
auto &place = *context.eigen_device();
432+
auto &place = *dev_ctx.eigen_device();
433433
TanhFunctor<T>()(place, eigen_value_in, eigen_value_in);
434434
SigmoidFunctor<T>()(place, eigen_value_ig, eigen_value_ig);
435435
SigmoidFunctor<T>()(place, eigen_value_fg, eigen_value_fg);
@@ -447,7 +447,7 @@ void eigen_lstm_forward_one_sequence(const Context &context,
447447
}
448448

449449
template <class T, class Context>
450-
void eigen_lstm_backward_one_sequence(const Context &context,
450+
void eigen_lstm_backward_one_sequence(const Context &dev_ctx,
451451
phi::funcs::LstmMetaValue<T> value,
452452
phi::funcs::LstmMetaGrad<T> grad,
453453
int frame_size) {
@@ -475,7 +475,7 @@ void eigen_lstm_backward_one_sequence(const Context &context,
475475
auto eigen_grad_state =
476476
typename EigenVector<T>::Type(grad.state_grad, Array1(frame_size));
477477

478-
auto &place = *context.eigen_device();
478+
auto &place = *dev_ctx.eigen_device();
479479
SigmoidGradFunctor<T>()(place,
480480
1 /*useless*/,
481481
eigen_value_og,
@@ -514,7 +514,7 @@ void eigen_lstm_backward_one_sequence(const Context &context,
514514
}
515515

516516
template <class T, class Op, class Context>
517-
void cpu_lstm_forward(const Context &context,
517+
void cpu_lstm_forward(const Context &dev_ctx,
518518
Op op,
519519
phi::funcs::LstmMetaValue<T> value,
520520
int frame_size,
@@ -524,7 +524,7 @@ void cpu_lstm_forward(const Context &context,
524524
ActivationType active_state,
525525
bool old_api_version) {
526526
if (!old_api_version) {
527-
eigen_lstm_forward_one_sequence<T>(context, value, frame_size);
527+
eigen_lstm_forward_one_sequence<T>(dev_ctx, value, frame_size);
528528
} else {
529529
if (Op::avx && !(frame_size & (8 - 1)) && (std::is_same<T, float>::value)) {
530530
avx_lstm_forward_one_sequence<T>(op,
@@ -549,7 +549,7 @@ void cpu_lstm_forward(const Context &context,
549549
}
550550

551551
template <class T, class Op, class Context>
552-
void cpu_lstm_backward(const Context &context,
552+
void cpu_lstm_backward(const Context &dev_ctx,
553553
Op op,
554554
phi::funcs::LstmMetaValue<T> value,
555555
phi::funcs::LstmMetaGrad<T> grad,
@@ -560,7 +560,7 @@ void cpu_lstm_backward(const Context &context,
560560
ActivationType active_state,
561561
bool old_api_version) {
562562
if (!old_api_version) {
563-
eigen_lstm_backward_one_sequence<T>(context, value, grad, frame_size);
563+
eigen_lstm_backward_one_sequence<T>(dev_ctx, value, grad, frame_size);
564564
} else {
565565
if (Op::avx && !(frame_size & (8 - 1)) && (std::is_same<T, float>::value)) {
566566
avx_lstm_backward_one_sequence<T>(op,

paddle/phi/kernels/funcs/detail/lstm_gpu_kernel.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ __global__ void KeLstmBackward(Op op,
218218
}
219219

220220
template <class T, class Op>
221-
void gpu_lstm_forward(const phi::DeviceContext& context,
221+
void gpu_lstm_forward(const phi::DeviceContext& dev_ctx,
222222
Op op,
223223
phi::funcs::LstmMetaValue<T> value,
224224
int frame_size,
@@ -240,7 +240,7 @@ void gpu_lstm_forward(const phi::DeviceContext& context,
240240
grid = dim3((frame_size + 32 - 1) / 32, (batch_size + 16 - 1) / 16);
241241
}
242242

243-
auto stream = reinterpret_cast<const phi::GPUContext&>(context).stream();
243+
auto stream = reinterpret_cast<const phi::GPUContext&>(dev_ctx).stream();
244244
if (batch_size == 1) {
245245
KeLstmForward<T,
246246
Op,
@@ -269,7 +269,7 @@ void gpu_lstm_forward(const phi::DeviceContext& context,
269269
}
270270

271271
template <class T, class Op>
272-
void gpu_lstm_backward(const phi::DeviceContext& context,
272+
void gpu_lstm_backward(const phi::DeviceContext& dev_ctx,
273273
Op op,
274274
phi::funcs::LstmMetaValue<T> value,
275275
phi::funcs::LstmMetaGrad<T> grad,
@@ -292,7 +292,7 @@ void gpu_lstm_backward(const phi::DeviceContext& context,
292292
grid = dim3((frame_size + 32 - 1) / 32, (batch_size + 16 - 1) / 16);
293293
}
294294

295-
auto stream = reinterpret_cast<const phi::GPUContext&>(context).stream();
295+
auto stream = reinterpret_cast<const phi::GPUContext&>(dev_ctx).stream();
296296
if (batch_size == 1) {
297297
KeLstmBackward<T,
298298
Op,

0 commit comments

Comments
 (0)