Repository navigation
Handle scalar outputs in parameter MAC calculations - #431
Open
linjiaye929 wants to merge 1 commit into
Open
linjiaye929 wants to merge 1 commit into
linjiaye929 wants to merge 1 commit into
Conversation
linjiaye929
marked this pull request as ready for review
November 7, 2026 19:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A scalar
nn.PReLUforward succeeds, butsummary(model, input_data=torch.tensor(-1.0))fails incalculate_macs()because the generic weight/bias fallback indexes the empty output shape.Use the product of the first output dimension instead. For scalar outputs the empty product is one; every non-scalar multiplier stays unchanged. Add seven public-API cases covering scalar PReLU through both input routes, vector/batched controls, and a scalar affine reduction, including parameter and memory accounting.
Validation on Linux, Python 3.12.14, PyTorch 2.11.0+cpu:
--no-outputwas not used.The two deselected tests download pretrained weights (
test_eval_order_doesnt_matterandtest_flan_t5_small). Skips cover ten CUDA tests and the existing nondeterministic Faster R-CNN test. Python 3.13/3.14, coverage collection, and the pre-commit wrapper were not run. Earlier runs under unsupported PyTorch 2.8 had the same 50 storage-size snapshot errors on both baseline and fix; all disappear under PyTorch 2.11.This is separate from #390's scalar input generation and #37's scalar shape handling. Prepared with AI assistance; no human review is claimed.