Fix(informer): Correct tensor shape for input_size=1 #38856
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @Rocketknight1, thanks for the great guidance on the previous PR!
This new pull request follows your suggestion to fix the bug at its source. It resolves a
RuntimeError
that occurs in time series models inheriting fromTimeSeriesTransformerModel
(such asInformerModel
) whenconfig.input_size
is set to 1.The root cause was that when
input_size=1
, theloc
andscale
tensors calculated by the scaler retained an extra dimension (e.g., shape[B, 1, 1]
instead of[B, 1]
). This incorrect shape caused a dimension mismatch error during a laterexpand()
operation.Instead of overriding the method in the child class, this PR applies a minimal and robust fix directly to the
create_network_inputs
method in the parentTimeSeriesTransformerModel
. It refactors the logic to unconditionally apply.squeeze(1)
to both theloc
andscale
tensors. This approach handles allinput_size
cases correctly and avoids code duplication.Fixes #38745