[Perf] Optimize clamp to clamp_ (#48143)
Signed-off-by: yewentao256 <zhyanwentao@126.com> Signed-off-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
2cab53ddee
commit
f17be06fbe
@@ -107,7 +107,9 @@ class Step3p5MTPProposer(EagleProposer):
|
||||
if block_table is None:
|
||||
continue
|
||||
n_blocks = block_table.shape[1]
|
||||
bn = (new_positions_1d // block_size).clamp(max=n_blocks - 1).to(torch.long)
|
||||
bn = new_positions_1d // block_size
|
||||
bn.clamp_(max=n_blocks - 1)
|
||||
bn = bn.to(torch.long)
|
||||
block_ids = block_table[:batch_size].gather(1, bn.unsqueeze(1)).squeeze(1)
|
||||
sm = block_ids * block_size + (new_positions_1d % block_size)
|
||||
sm.masked_fill_(exceeds, PADDING_SLOT_ID)
|
||||
|
||||
Reference in New Issue
Block a user