-
Notifications
You must be signed in to change notification settings - Fork 697
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 pixel_shuffle module #5135
add pixel_shuffle module #5135
Conversation
YongtaoShi
commented
Jun 8, 2021
•
edited
Loading
edited
…shiyongtao/dev_pixel_shuffle
C_{out} = C_{in} \div \text{upscale\_factor}^2 | ||
|
||
.. math:: | ||
H_{out} = H_{in} \times \text{upscale\_factor} |
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.
截图上docs此处有显示问题
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.
已修改
), "The scale factor of height and width must larger than zero" | ||
self.h_upscale_factor = h_upscale_factor | ||
self.w_upscale_factor = w_upscale_factor | ||
self._transpose_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.
不需要在init里构造transpose_op了,forward里可以直接用flow.permute(),等后面的functional接口更新以后,后面都会重构成类似torch那样,直接F.permute(xxx)
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.
已修改
|
||
|
||
def _np_pixel_shuffle(input, factor): | ||
return _np_pixel_shuffle_v2(input, factor, factor) |
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.
这里不需要包一层,直接用_np_pixel_shuffle就行
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.
已修改
return self._pixel_shuffle_v2_op(input) | ||
|
||
|
||
class PixelShufflev2(Module): |
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.
PixelShufflev2这个只是我们lazy op的版本区分,新版nn.Module中直接对齐torch,叫PixelShuffle吧
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.
对,pytorch只有pixelshuffle。
现在问题是,在之前的lazy模式,pixelshuffle是用pixelshufflev2来实现的,我现在采用了和lazy一样的逻辑。然后没有export v2接口,所以在用户看来应该是和pytorch一致的。
这样做的好处是,如果以后有v2需求的话,可以直接复用。也包括上面的numpy代码实现。
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.
如果确实不需要的话,是有些冗余,那我把v2相关的都删了?
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.
已修改