diff --git a/optimum/exporters/onnx/config.py b/optimum/exporters/onnx/config.py index 1fa6fa62629..3aca641513c 100644 --- a/optimum/exporters/onnx/config.py +++ b/optimum/exporters/onnx/config.py @@ -164,10 +164,7 @@ def inputs(self) -> Dict[str, Dict[int, str]]: # generating wrong position_ids in the model itself: # https://github.com/huggingface/transformers/blob/v4.33.1/src/transformers/models/gpt2/modeling_gpt2.py#L802 if not self.no_position_ids and self.task == "text-generation": - if self.use_past_in_inputs: - common_inputs["position_ids"] = {0: "batch_size"} - else: - common_inputs["position_ids"] = {0: "batch_size", 1: "sequence_length"} + common_inputs["position_ids"] = {0: "batch_size", 1: "sequence_length"} return common_inputs diff --git a/optimum/onnxruntime/modeling_decoder.py b/optimum/onnxruntime/modeling_decoder.py index bcb8f042279..66190069e5d 100644 --- a/optimum/onnxruntime/modeling_decoder.py +++ b/optimum/onnxruntime/modeling_decoder.py @@ -699,8 +699,8 @@ def forward( self, input_ids: torch.LongTensor, attention_mask: Optional[torch.FloatTensor] = None, - past_key_values: Optional[Tuple[Tuple[torch.Tensor]]] = None, position_ids: Optional[torch.LongTensor] = None, + past_key_values: Optional[Tuple[Tuple[torch.Tensor]]] = None, labels: Optional[torch.LongTensor] = None, use_cache_branch: None = None, **kwargs,