fairseq/criterions/sentence_prediction.py

Killed 0 out of 6 mutants

Survived

Survived mutation testing. These mutants show holes in your test suite.

Mutant 3192

--- fairseq/criterions/sentence_prediction.py
+++ fairseq/criterions/sentence_prediction.py
@@ -12,7 +12,7 @@
 from fairseq.criterions import FairseqCriterion, register_criterion
 
 
-@register_criterion('sentence_prediction')
+@register_criterion('XXsentence_predictionXX')
 class SentencePredictionCriterion(FairseqCriterion):
 
     def __init__(self, task, classification_head_name, regression_target):

Mutant 3193

--- fairseq/criterions/sentence_prediction.py
+++ fairseq/criterions/sentence_prediction.py
@@ -11,8 +11,6 @@
 from fairseq import metrics, utils
 from fairseq.criterions import FairseqCriterion, register_criterion
 
-
-@register_criterion('sentence_prediction')
 class SentencePredictionCriterion(FairseqCriterion):
 
     def __init__(self, task, classification_head_name, regression_target):

Mutant 3194

--- fairseq/criterions/sentence_prediction.py
+++ fairseq/criterions/sentence_prediction.py
@@ -20,7 +20,6 @@
         self.classification_head_name = classification_head_name
         self.regression_target = regression_target
 
-    @staticmethod
     def add_args(parser):
         # fmt: off
         parser.add_argument('--classification-head-name',

Mutant 3195

--- fairseq/criterions/sentence_prediction.py
+++ fairseq/criterions/sentence_prediction.py
@@ -28,7 +28,7 @@
                             help='name of the classification head to use')
         # fmt: on
 
-    def forward(self, model, sample, reduce=True):
+    def forward(self, model, sample, reduce=False):
         """Compute the loss for the given sample.
 
         Returns a tuple with three elements:

Mutant 3196

--- fairseq/criterions/sentence_prediction.py
+++ fairseq/criterions/sentence_prediction.py
@@ -69,7 +69,6 @@
 
         return loss, sample_size, logging_output
 
-    @staticmethod
     def reduce_metrics(logging_outputs) -> None:
         """Aggregate logging outputs from data parallel training."""
         loss_sum = sum(log.get('loss', 0) for log in logging_outputs)

Mutant 3197

--- fairseq/criterions/sentence_prediction.py
+++ fairseq/criterions/sentence_prediction.py
@@ -85,7 +85,6 @@
             ncorrect = sum(log.get('ncorrect', 0) for log in logging_outputs)
             metrics.log_scalar('accuracy', 100.0 * ncorrect / nsentences, nsentences, round=1)
 
-    @staticmethod
     def logging_outputs_can_be_summed() -> bool:
         """
         Whether the logging outputs returned by `forward` can be summed