Skip to content

Commit

Permalink
Update optimum/onnxruntime/modeling_seq2seq.py
Browse files Browse the repository at this point in the history
Co-authored-by: fxmarty <[email protected]>
  • Loading branch information
krathul and fxmarty authored Aug 21, 2023
1 parent 5e33c05 commit 28b1c0e
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions optimum/onnxruntime/modeling_seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,14 +1477,9 @@ def _shift_right(self, input_ids):
)

# shift inputs to the right
if is_torch_fx_proxy(input_ids):
# Item assignment is not supported natively for proxies.
shifted_input_ids = torch.full(input_ids.shape[:-1] + (1,), decoder_start_token_id)
shifted_input_ids = torch.cat([shifted_input_ids, input_ids[..., :-1]], dim=-1)
else:
shifted_input_ids = input_ids.new_zeros(input_ids.shape)
shifted_input_ids[..., 1:] = input_ids[..., :-1].clone()
shifted_input_ids[..., 0] = decoder_start_token_id
shifted_input_ids = input_ids.new_zeros(input_ids.shape)
shifted_input_ids[..., 1:] = input_ids[..., :-1].clone()
shifted_input_ids[..., 0] = decoder_start_token_id

if pad_token_id is None:
raise ValueError("self.model.config.pad_token_id has to be defined.")
Expand Down

0 comments on commit 28b1c0e

Please sign in to comment.