faf3aa876462323f2fa721ebd633752d6489808f,sru/modules.py,SRU,forward,#SRU#Any#Any#Any#,536

Before Change


        // unpack packed, if input is packed. packing and then unpacking will be slower than not
        // packing at all, but makes SRU usage compatible with nn.RNN usage
        orig_input = input
        if isinstance(orig_input, PackedSequence):
            input, batch_sizes, sorted_indices, unsorted_indices = input
            length = input.size(0)
            batch_size = input.size(1)
            mask_pad = torch.arange(batch_size,
                                    device=batch_sizes.device).expand(length, batch_size)
            mask_pad = (mask_pad >= batch_sizes.view(length, 1)).contiguous()
        else:
            length = input.size(0)
            batch_size = input.size(1)
            batch_sizes = None
            sorted_indices = None
            unsorted_indices = None

        // The dimensions of `input` should be: `(sequence_length, batch_size, input_size)`.
        if input.dim() != 3:
            raise ValueError("There must be 3 dimensions for (length, batch_size, input_size)")

        if c0 is None:

After Change


        orig_input = input
        if isinstance(orig_input, PackedSequence):
            input, lengths = nn.utils.rnn.pad_packed_sequence(input)
            max_length = lengths.max().item()
            mask_pad = torch.ByteTensor([[0] * l + [1] * (max_length - l) for l in lengths.tolist()])
            mask_pad = mask_pad.to(input.device).transpose(0, 1).contiguous()

        // The dimensions of `input` should be: `(sequence_length, batch_size, input_size)`.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 4

Instances


Project Name: asappresearch/sru
Commit Name: faf3aa876462323f2fa721ebd633752d6489808f
Time: 2020-09-18
Author: taolei@csail.mit.edu
File Name: sru/modules.py
Class Name: SRU
Method Name: forward


Project Name: allenai/allennlp
Commit Name: 87a61ad92a9e0129e5c81c242f0ea96d77e6b0af
Time: 2020-08-19
Author: akshita23bhagia@gmail.com
File Name: allennlp/training/metrics/attachment_scores.py
Class Name: AttachmentScores
Method Name: __call__


Project Name: microsoft/nni
Commit Name: 73b2221b5eb4fd21802e6bf41e21d5df8ef9bf2c
Time: 2019-11-22
Author: v-yugzh@microsoft.com
File Name: src/sdk/pynni/nni/nas/pytorch/darts/trainer.py
Class Name: DartsTrainer
Method Name: _compute_hessian


Project Name: microsoft/nni
Commit Name: 165756cc19a19db0e75c128ccc97eff3579af1c3
Time: 2020-12-05
Author: Yuge.Zhang@microsoft.com
File Name: examples/nas/proxylessnas/ops.py
Class Name: MobileInvertedResidualBlock
Method Name: forward