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 deconv cpu impl #5224

Merged
merged 57 commits into from
Jun 17, 2021
Merged

Add deconv cpu impl #5224

merged 57 commits into from
Jun 17, 2021

Conversation

BBuf
Copy link
Contributor

@BBuf BBuf commented Jun 17, 2021

添加反卷积的cpu实现。

图片

BBuf added 30 commits May 25, 2021 11:01
namespace {

template<typename T>
using Im2ColFunc = void (*)(const T* in_dptr, const ShapeView& in_shape,
Copy link
Contributor

Choose a reason for hiding this comment

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

im2col 没用到

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的。

const int32_t* padding_before, T* in_diff_ptr);

template<typename T>
using GemmFunc = void (*)(enum CBLAS_TRANSPOSE trans_a, enum CBLAS_TRANSPOSE trans_b, const int m,
Copy link
Contributor

Choose a reason for hiding this comment

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

这个也没用到,我们是直接调用的 ofgemm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的。

template<typename T>
struct ConvKernelUtil final {
public:
static void NCDHWIm2Col(const T* in_dptr, const ShapeView& in_shape,
Copy link
Contributor

Choose a reason for hiding this comment

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

im2col 相关的感觉都可以删了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的。

struct ConvOpKernelState final : public user_op::OpKernelState {
Im2ColFunc<T> im2col_func_;
Col2ImFunc<T> col2im_func_;
GemmFunc<T> forward_func_;
Copy link
Contributor

Choose a reason for hiding this comment

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

forward_func_ 这个也没用到

int32_t idx_offset = conv_state->idx_offset_;

FOR_RANGE(int64_t, i, 0, in->shape().At(0)) {
// channels first: col_buf' = weight(T) * out[i]'
Copy link
Contributor

Choose a reason for hiding this comment

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

注释应该是 weight(T) * in[i] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,已修正。

conv_state->weight_5d_shape_.At(0), static_cast<T>(1), weight->dptr<T>(),
GetImgDptr<T>(in, i), static_cast<T>(0), col_buf->mut_dptr<T>());

// in' = col2im(col_buf')
Copy link
Contributor

Choose a reason for hiding this comment

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

out = col2im(col_buf)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的。

@Ldpe2G Ldpe2G requested review from oneflow-ci-bot and removed request for oneflow-ci-bot June 17, 2021 13:43
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot June 17, 2021 13:44
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot June 17, 2021 14:35
@oneflow-ci-bot oneflow-ci-bot merged commit 8c27e5a into master Jun 17, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the add_deconv_cpu_impl branch June 17, 2021 15:20
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