cf8a3fb30547d6e980ecd8182f64a51df8e55c62,python/dgl/backend/pytorch/tensor.py,,pack_padded_tensor,#Any#Any#,248

Before Change


    device = input.device
    index = []
    for i, l in enumerate(lengths):
        index.extend(range(i * max_len, i * max_len + l))
    index = th.tensor(index).to(device)
    return gather_row(input.view(batch_size * max_len, -1), index)

After Change


    index = th.ones(out_len, dtype=th.int64, device=device)
    cum_lengths = th.cumsum(lengths, 0)
    index[cum_lengths[:-1]] += (max_len - lengths[:-1])
    index = th.cumsum(index, 0) - 1
    return input[index]

def boolean_mask(input, mask):
    if "bool" not in str(mask.dtype):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 3

Instances


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


Project Name: brian-team/brian2
Commit Name: a68e6f67ca0c77be2f6071aed9275989ad105205
Time: 2014-10-06
Author: dan.goodman@ens.fr
File Name: examples/compartmental/hodgkin_huxley_1952.py
Class Name:
Method Name:


Project Name: brian-team/brian2
Commit Name: a68e6f67ca0c77be2f6071aed9275989ad105205
Time: 2014-10-06
Author: dan.goodman@ens.fr
File Name: examples/compartmental/lfp.py
Class Name:
Method Name:


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: pad_packed_tensor