6799144620411f23c3a15abae1f78c5bc2a4f7c0,thinc/backends/ops.py,Ops,pad,#Ops#,115

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[region] = arr

After 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.
        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: 3

Non-data size: 9

Instances


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


Project Name: Calamari-OCR/calamari
Commit Name: de52463f855369ad17148054fa5a0a634c6b99a1
Time: 2021-01-19
Author: christoph.wick@planet-ai.de
File Name: calamari_ocr/ocr/dataset/datareader/pagexml/reader.py
Class Name: PageXMLReader
Method Name: cutout


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