deepspeedai / deepspeedai/DeepSpeed
[BUG] FlopsProfiler upsample flops compute bug
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
Describe the bug
the upsample flops compute code :
`def _upsample_flops_compute(*args, **kwargs):
scale_factor = kwargs.get('scale_factor', None)
if scale_factor is None and len(args) > 2:
scale_factor = args[2]
assert scale_factor is not None, "either size or scale_factor should be defined"
flops = input.numel()
if isinstance(scale_factor, tuple) and len(scale_factor) == len(input):
flops *= int(_prod(scale_factor))
else:
flops *= scale_factor**len(input)
return flops, 0`
len(scale_factor) == len(input) -> len(scale_factor) == len(input.size())
flops *= scale_factor ** len(input) -> flops *= scale_factor ** (len(input.size())-1)
upsample flops compute in torchstat: https://github.com/Swall0w/torchstat/blob/master/torchstat/compute_flops.py#L83
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the _upsample_flops_compute entry point used by FlopsProfiler, then compare its argument and dimensionality handling with torchstat's torchstat/compute_flops.py at the referenced section. Verify the calculation for tuple and scalar scale_factor cases, including spatial dimensions, and add or run the relevant profiler checks if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100