57c71199259bc937e5a58770cd3733fd65e0ef84,torch_geometric/utils/to_dense_batch.py,,to_dense_batch,#Any#Any#Any#,5

Before Change


    index = torch.arange(batch.size(0), dtype=torch.long, device=x.device)
    index = (index - cum_nodes[batch]) + (batch * max_num_nodes)

    size = [batch_size * max_num_nodes] + list(x.size())[1:]
    batch_x = x.new_full(size, fill_value)
    batch_x[index] = x
    size = [batch_size, max_num_nodes] + list(x.size())[1:]
    batch_x = batch_x.view(size)

After Change



    :rtype: (:class:`Tensor`, :class:`LongTensor`)
    
    batch_size = batch[-1].item() + 1
    num_nodes = scatter_("add", batch.new_ones(x.size(0)), batch, batch_size)
    cum_nodes = torch.cat([batch.new_zeros(1), num_nodes.cumsum(dim=0)])
    max_num_nodes = num_nodes.max().item()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: rusty1s/pytorch_geometric
Commit Name: 57c71199259bc937e5a58770cd3733fd65e0ef84
Time: 2019-06-07
Author: matthias.fey@tu-dortmund.de
File Name: torch_geometric/utils/to_dense_batch.py
Class Name:
Method Name: to_dense_batch


Project Name: facebookresearch/pytext
Commit Name: f5278f68882ebf89a013611c86eb20345e723df2
Time: 2020-04-15
Author: twild@fb.com
File Name: pytext/models/seq_models/seq2seq_model.py
Class Name: Seq2SeqModel
Method Name: forward


Project Name: dmlc/dgl
Commit Name: cf8a3fb30547d6e980ecd8182f64a51df8e55c62
Time: 2021-02-10
Author: expye@outlook.com
File Name: python/dgl/backend/pytorch/tensor.py
Class Name:
Method Name: pack_padded_tensor