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

add pixel_shuffle module #5135

Merged
merged 7 commits into from
Jun 9, 2021
Merged

Conversation

YongtaoShi
Copy link
Contributor

@YongtaoShi YongtaoShi commented Jun 8, 2021

image

@YongtaoShi YongtaoShi marked this pull request as ready for review June 8, 2021 09:38
@YongtaoShi YongtaoShi marked this pull request as draft June 8, 2021 09:40
@YongtaoShi YongtaoShi marked this pull request as ready for review June 9, 2021 01:30
C_{out} = C_{in} \div \text{upscale\_factor}^2

.. math::
H_{out} = H_{in} \times \text{upscale\_factor}
Copy link
Contributor

Choose a reason for hiding this comment

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

截图上docs此处有显示问题

Copy link
Contributor Author

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 = (
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里不需要包一层,直接用_np_pixel_shuffle就行

Copy link
Contributor Author

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):
Copy link
Contributor

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吧

Copy link
Contributor Author

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代码实现。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

如果确实不需要的话,是有些冗余,那我把v2相关的都删了?

Copy link
Contributor

Choose a reason for hiding this comment

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

好的

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@oneflow-ci-bot oneflow-ci-bot self-requested a review June 9, 2021 03:47
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot June 9, 2021 04:24
@oneflow-ci-bot oneflow-ci-bot merged commit 1af27df into master Jun 9, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the shiyongtao/dev_pixel_shuffle branch June 9, 2021 09:32
@YongtaoShi YongtaoShi restored the shiyongtao/dev_pixel_shuffle branch July 5, 2021 01:24
@YongtaoShi YongtaoShi deleted the shiyongtao/dev_pixel_shuffle branch July 5, 2021 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants