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

Refactor the baseclass related to transformer #978

Merged
merged 47 commits into from
Jun 11, 2021

Conversation

jshilong
Copy link
Collaborator

@jshilong jshilong commented Apr 23, 2021

PR Message

This pr refactor the FFN and BaseTransformerLayer.

  1. Add registry named DROPOUT_LAYERS and support to specify the DropPath or Dropout when adding the residue in the Attention or FFN.
  2. Add registry named FEEDFORWARD_NETWORK.
  3. Support to specify different probability for MultiheadAttention . with attn_drop and proj_drop
  4. Move all FFN related arguments to a list of Dict named ffn_cfgs so that we can build the FFN more flexibly.
  5. Change all nn.ModuleList to Moduleist.
  6. Support batch_first arguments for MultiheadAttention.
  7. Move MultiScaleDeformableAttention to mmcv/ops/multi_scale_deform_attn.py so that mmcv can be used without compiling ops.

BC-breaking

from mmcv.cnn.bricks.transformer import MultiScaleDeformableAttention should be changed to from mmcv.ops.multi_scale_deform_attn import MultiScaleDeformableAttention

@jshilong jshilong added the WIP label Apr 23, 2021
@jshilong jshilong changed the title change to modulist Refactor the baseclass releated to transformer Apr 23, 2021
@codecov
Copy link

codecov bot commented Apr 23, 2021

Codecov Report

Merging #978 (65bcd3f) into master (4d42365) will increase coverage by 2.29%.
The diff coverage is 74.86%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #978      +/-   ##
==========================================
+ Coverage   65.20%   67.50%   +2.29%     
==========================================
  Files         156      159       +3     
  Lines       10034    10186     +152     
  Branches     1816     1847      +31     
==========================================
+ Hits         6543     6876     +333     
+ Misses       3154     2948     -206     
- Partials      337      362      +25     
Flag Coverage Δ
unittests 67.50% <74.86%> (+2.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmcv/ops/multi_scale_deform_attn.py 58.40% <53.75%> (-11.29%) ⬇️
mmcv/cnn/bricks/transformer.py 81.62% <86.48%> (+81.62%) ⬆️
mmcv/cnn/bricks/__init__.py 100.00% <100.00%> (ø)
mmcv/cnn/bricks/drop.py 100.00% <100.00%> (ø)
mmcv/cnn/bricks/registry.py 100.00% <100.00%> (ø)
mmcv/ops/__init__.py 100.00% <100.00%> (ø)
mmcv/onnx/info.py 68.75% <0.00%> (-6.25%) ⬇️
mmcv/tensorrt/tensorrt_utils.py 0.00% <0.00%> (-2.39%) ⬇️
mmcv/fileio/parse.py 100.00% <0.00%> (ø)
mmcv/runner/hooks/evaluation.py 88.15% <0.00%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d42365...65bcd3f. Read the comment docs.

zhangshilong and others added 2 commits April 26, 2021 16:13
[Feature]Replace dropout with attn_drop and proj_drop in MultiheadAttention
@CLAassistant
Copy link

CLAassistant commented Apr 26, 2021

CLA assistant check
All committers have signed the CLA.

@ZwwWayne ZwwWayne mentioned this pull request May 14, 2021
9 tasks
mmcv/cnn/bricks/drop.py Outdated Show resolved Hide resolved
mmcv/cnn/bricks/drop.py Outdated Show resolved Hide resolved
mmcv/cnn/bricks/transformer.py Outdated Show resolved Hide resolved
mmcv/cnn/bricks/transformer.py Show resolved Hide resolved
Copy link
Contributor

@nbei nbei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just suggestions.

mmcv/cnn/bricks/drop.py Outdated Show resolved Hide resolved
mmcv/cnn/bricks/registry.py Outdated Show resolved Hide resolved
mmcv/cnn/bricks/registry.py Outdated Show resolved Hide resolved
mmcv/ops/multi_scale_deform_attn.py Show resolved Hide resolved
mmcv/ops/multi_scale_deform_attn.py Outdated Show resolved Hide resolved
mmcv/ops/multi_scale_deform_attn.py Outdated Show resolved Hide resolved
mmcv/ops/multi_scale_deform_attn.py Show resolved Hide resolved
mmcv/ops/multi_scale_deform_attn.py Outdated Show resolved Hide resolved
mmcv/ops/multi_scale_deform_attn.py Outdated Show resolved Hide resolved
mmcv/ops/multi_scale_deform_attn.py Outdated Show resolved Hide resolved
@nbei nbei assigned nbei and unassigned nbei Jun 10, 2021
@jshilong jshilong requested review from ZwwWayne and nbei June 11, 2021 04:04
@ZwwWayne ZwwWayne merged commit e05fb56 into open-mmlab:master Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants