Files
rapidocr/python
Tai An 09f4e3b185 fix(nrtr): let generate_square_subsequent_mask take the device it is given (#731)
Transformer.forward_train calls

    tgt_mask = self.generate_square_subsequent_mask(tgt.shape[0], tgt.device)

but the helper only accepts sz, so the training branch of
Transformer.forward raises

    TypeError: Transformer.generate_square_subsequent_mask() takes 2
    positional arguments but 3 were given

The other two call sites (forward_test and forward_beam) pass one
argument and are unaffected.

Accept an optional device and forward it to the two tensor
constructors. It defaults to None, so the one-argument call sites keep
building the mask on the CPU exactly as before, and the call site that
already asks for a device now gets one.
2026-09-03 17:09:26 +08:00
..
2026-06-23 09:54:53 +08:00
2026-02-01 14:36:32 +08:00