Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fx tracer to support alpha in RepVGGBlock #863

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

twmht
Copy link

@twmht twmht commented Aug 29, 2023

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Can't fx.trace with PPYOLOECSPResNet when use_alpha=True

minimal reproducible script.

from mmrazor.models.task_modules.tracer.channel_analyzer import ChannelAnalyzer
from mmrazor.implementations.pruning.group_fisher import GroupFisherChannelMutator
from mmyolo.models.backbones import PPYOLOECSPResNet
from torch.fx import symbolic_trace

normalization_type='act'
analyzer=ChannelAnalyzer(tracer_type='FxTracer')
mutator=GroupFisherChannelMutator(channel_unit_cfg=dict(type='GroupFisherChannelUnit', default_args=dict(normalization_type=normalization_type)), parse_cfg=dict(type='ChannelAnalyzer', tracer_type='FxTracer'))
#  model=ResNet(depth=18)
deepen_factor = 0.33
widen_factor = 0.5
model=PPYOLOECSPResNet(
        deepen_factor=deepen_factor,
        widen_factor=widen_factor,
        block_cfg=dict(
            type='PPYOLOEBasicBlock', shortcut=True, use_alpha=True),
        norm_cfg=dict(type='BN', momentum=0.1, eps=1e-5),
        act_cfg=dict(type='SiLU', inplace=True),
        attention_cfg=dict(
            type='EffectiveSELayer', act_cfg=dict(type='HSigmoid')),
        use_large_stem=True)
print(model)
module=symbolic_trace(model)

Modification

don't use traced tensor in the control flow

BC-breaking (Optional)

Does the modification introduce changes that break the backward compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness.
  3. If the modification has a potential influence on downstream projects, this PR should be tested with downstream projects, like MMDetection or MMClassification.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants