@@ -1367,8 +1367,6 @@ def assert_empty_loss(iou_fn, dtype, device):
1367
1367
loss = iou_fn (box1 , box2 , reduction = "none" )
1368
1368
assert loss .numel () == 0 , f"{ str (iou_fn )} for two empty box should be empty"
1369
1369
1370
- def assert_reduction_mode (iou_fn , box1 , box2 , reduction ):
1371
- assert iou_fn (box1 , box2 , reduction ) == ValueError
1372
1370
1373
1371
class TestGeneralizedBoxIouLoss :
1374
1372
# We refer to original test: https://github.com/facebookresearch/fvcore/blob/main/tests/test_giou_loss.py
@@ -1399,7 +1397,8 @@ def test_giou_loss(self, dtype, device):
1399
1397
# Test reduction value
1400
1398
# reduction value other than ["none", "mean", "sum"] should raise a ValueError
1401
1399
with pytest .raises (ValueError , match = "Invalid" ):
1402
- assert_reduction_mode (ops .generalized_box_iou_loss , box1s , box2s , reduction = "xyz" )
1400
+ ops .generalized_box_iou_loss (box1s , box2s , reduction = "xyz" )
1401
+
1403
1402
1404
1403
@pytest .mark .parametrize ("device" , cpu_and_gpu ())
1405
1404
@pytest .mark .parametrize ("dtype" , [torch .float32 , torch .half ])
@@ -1421,7 +1420,7 @@ def test_ciou_loss(self, dtype, device):
1421
1420
assert_iou_loss (ops .complete_box_iou_loss , box1s , box2s , 2.4500 , device = device , reduction = "sum" )
1422
1421
1423
1422
with pytest .raises (ValueError , match = "Invalid" ):
1424
- assert_reduction_mode ( ops .complete_box_iou_loss , box1s , box2s , reduction = "xyz" )
1423
+ ops .complete_box_iou_loss ( box1s , box2s , reduction = "xyz" )
1425
1424
1426
1425
@pytest .mark .parametrize ("device" , cpu_and_gpu ())
1427
1426
@pytest .mark .parametrize ("dtype" , [torch .float32 , torch .half ])
@@ -1443,7 +1442,7 @@ def test_distance_iou_loss(self, dtype, device):
1443
1442
assert_iou_loss (ops .distance_box_iou_loss , box1s , box2s , 2.4500 , device = device , reduction = "sum" )
1444
1443
1445
1444
with pytest .raises (ValueError , match = "Invalid" ):
1446
- assert_reduction_mode ( ops .distance_box_iou_loss , box1s , box2s , reduction = "xyz" )
1445
+ ops .distance_box_iou_loss ( box1s , box2s , reduction = "xyz" )
1447
1446
1448
1447
@pytest .mark .parametrize ("device" , cpu_and_gpu ())
1449
1448
@pytest .mark .parametrize ("dtype" , [torch .float32 , torch .half ])
@@ -1576,7 +1575,7 @@ def test_reduction_mode(self, device, dtype, reduction="xyz"):
1576
1575
torch .random .manual_seed (0 )
1577
1576
inputs , targets = self ._generate_diverse_input_target_pair (device = device , dtype = dtype )
1578
1577
with pytest .raises (ValueError , match = "Invalid" ):
1579
- ops .sigmoid_focal_loss (inputs , targets , 0.25 , 2 , reduction ) == ValueError
1578
+ ops .sigmoid_focal_loss (inputs , targets , 0.25 , 2 , reduction )
1580
1579
1581
1580
1582
1581
0 commit comments