Skip to content

Commit

Permalink
fix: create position ids for text only input (#2714)
Browse files Browse the repository at this point in the history
* fix: create position ids for text only input

* fix: prefer repeat over expand to avoid clone
  • Loading branch information
drbh authored Nov 2, 2024
1 parent 01dacf8 commit 6e32205
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,12 @@ def get_position_ids(

llm_positions = torch.cat(llm_pos_ids_list, dim=1).reshape(3, -1)
position_ids[:, i, :] = llm_positions.to(position_ids.device)

else:
position_ids = (
torch.arange(batch_input_ids.shape[1], device=batch_input_ids.device)
.view(1, 1, -1)
.repeat(3, batch_input_ids.shape[0], 1)
)
return position_ids

def forward(
Expand Down

0 comments on commit 6e32205

Please sign in to comment.