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

Before Change


    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)

def boolean_mask(input, mask):

After Change


    if not is_tensor(lengths):
        lengths = th.tensor(lengths, dtype=th.int64, device=device)
    else:
        lengths = lengths.to(device)
    input = input.view(-1, *input.shape[2:])
    out_len = lengths.sum().item()
    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: xinntao/BasicSR
Commit Name: cbc51f8495a8d5e314cd1ae0704f32a4e3dc28b1
Time: 2018-06-16
Author: wxt1994@126.com
File Name: codes/models/modules/loss.py
Class Name: GradientPenaltyLoss
Method Name: __init__


Project Name: ClementPinard/FlowNetPytorch
Commit Name: 678ac413ce55cb3db09d1f24532920582af54f43
Time: 2018-11-12
Author: clement.pinard@parrot.com
File Name: run_inference.py
Class Name:
Method Name: main


Project Name: PIQuIL/QuCumber
Commit Name: c8a8664f8b6b430a2ce37834ccc7460f5c552a87
Time: 2018-12-29
Author: emerali@users.noreply.github.com
File Name: tests/grads_utils.py
Class Name: ComplexGradsUtils
Method Name: load_target_psi