Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/winml/modelkit/models/winml/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@ def forward(self, **kwargs: Any) -> ModelOutput:
pooling handles 1-D and 2-D after raw[0].
"""
outputs = self._run_inference(self._format_inputs(**kwargs))
# WinMLEncoderDecoderModel expects its encoder sub-component to expose
# hidden states as "last_hidden_state". Alias the primary output when an
# encoder ONNX graph named it otherwise (e.g. "encoder_hidden_states").
# Appended last to preserve output[0] and the real ONNX output names.
if outputs and "last_hidden_state" not in outputs:
outputs["last_hidden_state"] = next(iter(outputs.values()))
return FeatureExtractionModelOutput(outputs)
Loading