in optimum/exporters/onnx/model_configs.py [0:0]
def outputs(self) -> Dict[str, Dict[int, str]]:
if self.task in ["feature-extraction", "text2text-generation"]:
common_outputs = super().outputs
else:
common_outputs = super(OnnxConfigWithPast, self).outputs
if self.use_past:
# When exporting decoder models with use_cache=True, both the decoder without past and with past have the KV cache as an output.
for i in range(
self._normalized_config.encoder_num_layers
if self.task != "text-generation"
else self._normalized_config.decoder_num_layers
):
common_outputs[f"present.{i}.key"] = {0: "batch_size", 2: "past_sequence_length + sequence_length"}
common_outputs[f"present.{i}.value"] = {
0: "batch_size",
2: "past_sequence_length + sequence_length",
}
return common_outputs