-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[dygraph qat] Refine saving output scale to infer program #31784
[dygraph qat] Refine saving output scale to infer program #31784
Conversation
Thanks for your contribution! |
|
||
# Note that, the items have priority in corresponding_dict | ||
corresponding_dict = { | ||
'conv2d_tranpose': [['conv2d_tranpose'], None], |
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.
conv2d_transpose 对应是两个Op:conv2d_transpose / depthwise_ conv2d_transpose
另外:应该是conv2d_transpose,而不是conv2d_tranpose
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
for key, value in corresponding_dict.items(): | ||
if key in scale_name: | ||
return (op.type in value[0]) and \ | ||
(len(value) == 1 or value[1] is None or value[1](op)) |
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.
为什么要添加判断value[1] is None or value[1](op)
呢?
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.
如果有必要,可以新增lambda函数来判断静态图op是否满足特定条件,目前这里仅仅使用了op的名字,所以默认都是None
'BatchNorm': paddle.nn.BatchNorm, | ||
'BatchNorm2D': paddle.nn.BatchNorm2D, | ||
'GroupNorm': paddle.nn.GroupNorm, | ||
'InstanceNorm2D': paddle.nn.InstanceNorm2D, |
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.
静态图量化中并不支持Instance_norm等Op,那动态图中新增了对于这些Op的支持,静态图量化中也请一并加上
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
if not self._is_scale_op_matched(scale_name, op, global_block): | ||
op_idx += 1 | ||
else: | ||
weight_ops = ["conv2d", "depthwise_conv2d", "matmul"] |
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.
weight_ops中还需添加conv2d_transpose
和depthwise_conv2d_transpose
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
… refine_calc_output_scale2
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 tks
if not self._is_scale_op_matched(scale_name, op, global_block): | ||
op_idx += 1 | ||
else: | ||
weight_ops = ["conv2d", "depthwise_conv2d", "matmul"] |
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
|
||
# Note that, the items have priority in corresponding_dict | ||
corresponding_dict = { | ||
'conv2d_tranpose': [['conv2d_tranpose'], None], |
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
for key, value in corresponding_dict.items(): | ||
if key in scale_name: | ||
return (op.type in value[0]) and \ | ||
(len(value) == 1 or value[1] is None or value[1](op)) |
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.
如果有必要,可以新增lambda函数来判断静态图op是否满足特定条件,目前这里仅仅使用了op的名字,所以默认都是None
'BatchNorm': paddle.nn.BatchNorm, | ||
'BatchNorm2D': paddle.nn.BatchNorm2D, | ||
'GroupNorm': paddle.nn.GroupNorm, | ||
'InstanceNorm2D': paddle.nn.InstanceNorm2D, |
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
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
2d9bced
to
85f18ef
Compare
PR types
Others
PR changes
Others
Describe
Refine saving output scale to infer program