-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add Support Layer List to ASP #40253
Add Support Layer List to ASP #40253
Conversation
1. Added a function to allow user to add their own layer and correspond pruning way to ASP support. 2. Changed naming rule to asp masks.
Thanks for your contribution! |
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. | ||
# Copyright (c) 2021 NVIDIA Corporation. All rights reserved. | ||
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. | ||
# Copyright (c) 2022 NVIDIA Corporation. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
该文件不是本PR新增,不用修改CopyRight年份,下同。这是误改?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, 2022 -> 2021
|
||
__all__ = [ | ||
'calculate_density', 'check_mask_1d', 'get_mask_1d', 'check_mask_2d', | ||
'get_mask_2d_greedy', 'get_mask_2d_best', 'create_mask', 'check_sparsity', | ||
'MaskAlgo', 'CheckMethod', 'decorate', 'prune_model', 'set_excluded_layers', | ||
'reset_excluded_layers' | ||
'reset_excluded_layers', 'add_supported_layer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_supported_layer
、set_excluded_layers
、reset_excluded_layers
,这三个接口有点令人迷惑了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這三個接口功能分別如下
add_supported_layer: 讓使用者增加自己客製化的nn.Layer的參數到ASP的支援清單,預設只會支援FC, Conv2D, Linear.
set_excluded_layers: 在支援的nn.Layer的參數中,針對特定的幾層不執行ASP, 比如 一個網絡有三層FC, 但其中一層不需要ASP,怎可以使用此API來將該層排除
reset_excluded_layers: 將 set_excluded_layers
所添加的Layer全部清空。
|
||
__all__ = [ | ||
'calculate_density', 'check_mask_1d', 'get_mask_1d', 'check_mask_2d', | ||
'get_mask_2d_greedy', 'get_mask_2d_best', 'create_mask', 'check_sparsity', | ||
'MaskAlgo', 'CheckMethod', 'decorate', 'prune_model', 'set_excluded_layers', | ||
'reset_excluded_layers' | ||
'reset_excluded_layers', 'add_supported_layer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_supported_layer
、set_excluded_layers
、reset_excluded_layers
,这三个接口有点令人迷惑了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -293,7 +295,7 @@ class ASPHelper(object): | |||
""" | |||
|
|||
MASK_APPENDDED_NAME = '_asp_mask' | |||
SUPPORTED_LAYERS = {'fc': 'w_0', 'linear': 'w_0', 'conv2d': 'w_0'} | |||
PADDLE_WEIGHT_SUFFIX = "w_" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样改的好处,是可以支持更多的layer,不限定于fc
、linear
、conv2d
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,此次改動將支援的Layer改為統一由supported_layer_list來管理
@@ -293,7 +295,7 @@ class ASPHelper(object): | |||
""" | |||
|
|||
MASK_APPENDDED_NAME = '_asp_mask' | |||
SUPPORTED_LAYERS = {'fc': 'w_0', 'linear': 'w_0', 'conv2d': 'w_0'} | |||
PADDLE_WEIGHT_SUFFIX = "w_" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样改的好处,是可以支持更多的layer,不限定于fc
、linear
、conv2d
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -384,7 +379,7 @@ def _get_mask_name(param_name): | |||
Returns: | |||
string: The mask name of :attr:`param_name`. | |||
""" | |||
return param_name + ASPHelper.MASK_APPENDDED_NAME | |||
return param_name + "." + ASPHelper.MASK_APPENDDED_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里加了.
,还需要保留_
吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, remoe _
.
@@ -384,7 +379,7 @@ def _get_mask_name(param_name): | |||
Returns: | |||
string: The mask name of :attr:`param_name`. | |||
""" | |||
return param_name + ASPHelper.MASK_APPENDDED_NAME | |||
return param_name + "." + ASPHelper.MASK_APPENDDED_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里加了.
,还需要保留_
吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
|
||
__all__ = [ #noqa | ||
'calculate_density', | ||
'decorate', | ||
'prune_model', | ||
'set_excluded_layers', | ||
'reset_excluded_layers' | ||
'reset_excluded_layers', | ||
'add_supported_layer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里后续PR再加?add_supported_layer
、set_excluded_layers
、reset_excluded_layers
,这三个接口有点令人迷惑了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上解釋後,是否還是要暫緩對外公開呢?
|
||
__all__ = [ #noqa | ||
'calculate_density', | ||
'decorate', | ||
'prune_model', | ||
'set_excluded_layers', | ||
'reset_excluded_layers' | ||
'reset_excluded_layers', | ||
'add_supported_layer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里后续PR再加?add_supported_layer
、set_excluded_layers
、reset_excluded_layers
,这三个接口有点令人迷惑了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上解釋後,是否還是要暫緩對外公開呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如線下討論,暫緩公開
1. Modified year of copyright. 2. Changed asp mask name from _asp_mask to asp_mask.
1. Hide add_support_layer and wait API confirmation to release. 2. Changed year of copyright.
44d0b07
to
920111e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
New features
PR changes
APIs
Describe