paddlenlp/transformers/distill_utils.py
def minilm_pretraining_forward(self,
                               input_ids,
                               token_type_ids=None,
                               attention_mask=None):
    """
    Replaces `forward` function while using multi gpus to train. If training on
    single GPU, this `forward` could not be replaced.
    The type of `self` should inherit from base class of pretrained LMs, such as
    `TinyBertForPretraining`.
    Strategy MINILM only needs q, k and v of transformers.
    """
    assert hasattr(self, self.base_model_prefix), \
        "Student class should inherit from %s" % (self.base_model_class)
    model = getattr(self, self.base_model_prefix)
    encoder = model.encoder

    sequence_output, pooled_output = model(input_ids, token_type_ids,
                                           attention_mask)
    return encoder.q, encoder.k, encoder.v

    Replaces `forward` function while using multi gpus to train. If training on
    single GPU, this `forward` could not be replaced.
    The type of `self` should inherit from base class of pretrained LMs, such as
    `TinyBertForPretraining`.
    Strategy MINILM only needs q, k and v of transformers.
    
Replaces `forward` function while using multi gpus to train. If training on
single GPU, this `forward` could not be replaced.
The type of `self` should inherit from base class of pretrained LMs, such as
`TinyBertForPretraining`.
Strategy MINILM only needs q, k and v of transformers.
Replaces ` forward ` function while using multi gpus to train . If training on single GPU this ` forward ` could not be replaced . The type of ` self ` should inherit from base class of pretrained LMs such as ` TinyBertForPretraining ` . Strategy MINILM only needs q k and v of transformers .
def minilm_pretraining_forward(self,
                               input_ids,
                               token_type_ids=None,
                               attention_mask=None):
    assert hasattr(self, self.base_model_prefix), \
        "Student class should inherit from %s" % (self.base_model_class)
    model = getattr(self, self.base_model_prefix)
    encoder = model.encoder
    sequence_output, pooled_output = model(input_ids, token_type_ids,
                                           attention_mask)
    return encoder.q, encoder.k, encoder.v
def minilm_pretraining_forward ( self , input_ids , token_type_ids = None , attention_mask = None ) : assert hasattr ( self , self . base_model_prefix ) , "Student class should inherit from %s" % ( self . base_model_class ) model = getattr ( self , self . base_model_prefix ) encoder = model . encoder sequence_output , pooled_output = model ( input_ids , token_type_ids , attention_mask ) return encoder . q , encoder . k , encoder . v
Replaces `forward` function while using multi gpus to train.
Replaces ` forward ` function while using multi gpus to train .
"""
    Replaces `forward` function while using multi gpus to train. If training on
    single GPU, this `forward` could not be replaced.
    The type of `self` should inherit from base class of pretrained LMs, such as
    `TinyBertForPretraining`.
    Strategy MINILM only needs q, k and v of transformers.
    """
self
input_ids
token_type_ids
attention_mask