Skip to content

Commit 4dbe425

Browse files
committed
Fix
1 parent 025a17e commit 4dbe425

File tree

7 files changed

+24
-50
lines changed

7 files changed

+24
-50
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/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 +

python/paddle/nn/functional/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def embedding(
202202
203203
Args:
204204
x(Tensor): A Tensor with type int32/int64, which contains the id information. The value of the input id should
205-
satisfy :math:`0<= id < weight.shape[0]` .
205+
satisfy :math:`0 <= id < weight.shape[0]` .
206206
weight (Tensor): The weight. A Tensor with shape of lookup table parameter. It should have two elements which
207207
indicates the size of the dictionary of embeddings and the size of each embedding vector respectively.
208208
sparse(bool, optional): The flag indicating whether to use sparse update. This parameter only

python/paddle/nn/functional/loss.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def base_softmax_with_cross_entropy(
294294
# label = paddle.unsqueeze(label, axis)
295295
# ------
296296

297-
# notice : dim of label [-1,2,10] while logits is [-1,1] ,if use unsquezee
297+
# notice : dim of label [-1,2,10] while logits is [-1,1], if use unsqueeze
298298
# logits [-1,1]->[-1,1,1], but input need 1 != 2 so change
299299
# the modified function make logits [-1,1] -> [-1,2] (uncertain)
300300
# another possible modify [-1,1] -> [-1,2,1]
@@ -2971,8 +2971,8 @@ def cross_entropy(
29712971

29722972
if input_dims - 1 != label_dims and input_dims != label_dims:
29732973
raise ValueError(
2974-
f'Expected nput_dims - 1 = label_dims or input_dims == label_dims\
2975-
(got nput_dims{input_dims}, label_dims{label_dims})'
2974+
f'Expected input_dims - 1 = label_dims or input_dims == label_dims\
2975+
(got input_dims{input_dims}, label_dims{label_dims})'
29762976
)
29772977

29782978
if label_smoothing > 0.0:
@@ -3457,7 +3457,7 @@ def multi_label_soft_margin_loss(
34573457
Parameters:
34583458
input (Tensor): Input tensor, the data type is float32 or float64. Shape is (N, C), where C is number of classes, and if shape is more than 2D, this is (N, C, D1, D2,..., Dk), k >= 1.
34593459
label (Tensor): Label tensor, the data type is float32 or float64. The shape of label is the same as the shape of input.
3460-
weight (Tensor,optional): a manual rescaling weight given to each class.
3460+
weight (Tensor, optional): a manual rescaling weight given to each class.
34613461
If given, has to be a Tensor of size C and the data type is float32, float64.
34623462
Default is ``'None'`` .
34633463
reduction (str, optional): Indicate how to average the loss by batch_size,
@@ -3472,7 +3472,7 @@ def multi_label_soft_margin_loss(
34723472
Shape:
34733473
input: N-D Tensor, the shape is [N, \*], N is batch size and `\*` means number of classes, available dtype is float32, float64. The sum operation operates over all the elements.
34743474
label: N-D Tensor, same shape as the input.
3475-
weight:N-D Tensor, the shape is [N,1]
3475+
weight: N-D Tensor, the shape is [N,1]
34763476
output: scalar. If :attr:`reduction` is ``'none'``, then same shape as the input.
34773477
34783478
Returns:
@@ -3513,13 +3513,13 @@ def multi_label_soft_margin_loss(
35133513
input,
35143514
'input',
35153515
['float32', 'float64'],
3516-
'multilabel_soft_margin_loss',
3516+
'multi_label_soft_margin_loss',
35173517
)
35183518
check_variable_and_dtype(
35193519
label,
35203520
'label',
35213521
['float32', 'float64'],
3522-
'multilabel_soft_margin_loss',
3522+
'multi_label_soft_margin_loss',
35233523
)
35243524

35253525
loss = -(
@@ -3533,7 +3533,7 @@ def multi_label_soft_margin_loss(
35333533
weight,
35343534
'weight',
35353535
['float32', 'float64'],
3536-
'multilabel_soft_margin_loss',
3536+
'multi_label_soft_margin_loss',
35373537
)
35383538
loss = loss * weight
35393539

test/legacy_test/test_index_fill.py

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
1615
import unittest
1716
from itertools import combinations
1817

1918
import numpy as np
19+
from op_test import get_places
2020

2121
import paddle
2222
from paddle.base import Program
@@ -44,17 +44,9 @@ def setUp(self):
4444
self.index_type
4545
)
4646

47-
self.place = []
48-
if (
49-
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
50-
in ['1', 'true', 'on']
51-
or not paddle.is_compiled_with_cuda()
52-
):
53-
self.place.append('cpu')
54-
if self.dtype_np == 'float16':
55-
self.place = []
56-
if paddle.is_compiled_with_cuda():
57-
self.place.append('gpu')
47+
self.place = get_places(string_format=True)
48+
if self.dtype_np == 'float16' and 'cpu' in self.place:
49+
self.place.remove('cpu')
5850

5951
def init_setting(self):
6052
self.dtype_np = 'float64'
@@ -158,17 +150,9 @@ def setUp(self):
158150
self.index_type
159151
)
160152

161-
self.place = []
162-
if (
163-
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
164-
in ['1', 'true', 'on']
165-
or not paddle.is_compiled_with_cuda()
166-
):
167-
self.place.append('cpu')
168-
if self.dtype_np == 'float16':
169-
self.place = []
170-
if paddle.is_compiled_with_cuda():
171-
self.place.append('gpu')
153+
self.place = get_places(string_format=True)
154+
if self.dtype_np == 'float16' and 'cpu' in self.place:
155+
self.place.remove('cpu')
172156

173157
def init_setting(self):
174158
self.dtype_np = 'float64'

test/legacy_test/test_multilabelmarginloss.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# limitations under the License.
1414

1515

16-
import os
1716
import unittest
1817

1918
import numpy as np
19+
from op_test import get_places
2020

2121
import paddle
2222

@@ -222,18 +222,8 @@ def test_MultiLabelMarginLoss(self):
222222
)
223223
label[i, :num_valid] = valid_labels
224224

225-
places = []
226-
if (
227-
os.environ.get('FLAGS_CI_both_cpu_and_gpu', 'False').lower()
228-
in ['1', 'true', 'on']
229-
or not paddle.device.is_compiled_with_cuda()
230-
):
231-
places.append(paddle.CPUPlace())
232-
if paddle.device.is_compiled_with_cuda():
233-
places.append(paddle.CUDAPlace(0))
234-
235225
reductions = ['sum', 'mean', 'none']
236-
for place in places:
226+
for place in get_places():
237227
for reduction in reductions:
238228
expected = calc_multi_label_margin_loss(
239229
input=input, label=label, reduction=reduction

0 commit comments

Comments
 (0)