2eef369b7ac92e38f81819307a4af4238fd953ee,thinc/backends/jax_ops.py,JaxOps,pad,#JaxOps#,174

Before Change


        if len(set(seq.shape[1:] for seq in seqs)) != 1:
            raise ValueError("Cannot pad sequences that differ on other dimensions")
        // Find the maximum dimension along each axis. That"s what we"ll pad to.
        shapes = [tuple(s.shape) for s in seqs]
        dim_sizes = zip(*[shape for shape in shapes])
        max_dims = [max(sizes) for sizes in dim_sizes]
        final_shape = (len(seqs),) + tuple(max_dims)
        output = self.alloc(final_shape, dtype=seqs[0].dtype)
        for i, arr in enumerate(seqs):
            region = [i] + [slice(0, dim) for dim in arr.shape]
            output = index_update(output, index[region], arr)
        return output

    def list2padded(self, seqs: List[Array2d]) -> Padded:
        Pack a sequence of 2d arrays into a Padded datatype.

After Change


        length = max(len(seq) for seq in seqs)
        // Round the length
        length = (length + (round_to-1)) // round_to * round_to
        final_shape = (len(seqs), length) + seqs[0].shape[1:]
        output = self.alloc(final_shape, dtype=seqs[0].dtype)
        for i, arr in enumerate(seqs):
            output[i, :arr.shape[0]] = arr
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 10

Instances


Project Name: explosion/thinc
Commit Name: 2eef369b7ac92e38f81819307a4af4238fd953ee
Time: 2020-01-19
Author: honnibal+gh@gmail.com
File Name: thinc/backends/jax_ops.py
Class Name: JaxOps
Method Name: pad


Project Name: Pinafore/qb
Commit Name: e79449afe45f4da6f1756a7d92bdd3cd6618c638
Time: 2018-04-25
Author: sjtufs@gmail.com
File Name: qanta/guesser/dan.py
Class Name: DanGuesser
Method Name: _guess_batch


Project Name: kevinzakka/recurrent-visual-attention
Commit Name: 520e8fb57b890a7249334d9e90c9ad209d0b849f
Time: 2018-02-10
Author: kevinarmandzakka@gmail.com
File Name: modules.py
Class Name: retina
Method Name: foveate


Project Name: explosion/thinc
Commit Name: 6799144620411f23c3a15abae1f78c5bc2a4f7c0
Time: 2020-01-19
Author: honnibal+gh@gmail.com
File Name: thinc/backends/ops.py
Class Name: Ops
Method Name: pad