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

Replace custom IOHW -> OIHW reorder with build-in oneDNN reorder #37175

Merged
merged 10 commits into from
Nov 17, 2021

Conversation

Silv3S
Copy link
Member

@Silv3S Silv3S commented Nov 13, 2021

PR types

Performance optimization

PR changes

OPs

Describe

PR resolves #18842

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@CLAassistant
Copy link

CLAassistant commented Nov 13, 2021

CLA assistant check
All committers have signed the CLA.

@Silv3S Silv3S marked this pull request as ready for review November 13, 2021 21:18
Copy link
Contributor

@jakpiase jakpiase left a comment

Choose a reason for hiding this comment

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

Nicely done, but don't you want to try out AcquireApi?


return reordered_filter_data;
};
platform::MKLDNNEngine engine = dev_ctx.GetEngine();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
platform::MKLDNNEngine engine = dev_ctx.GetEngine();
const platform::MKLDNNEngine& engine = dev_ctx.GetEngine();

return reordered_filter_data;
};
platform::MKLDNNEngine engine = dev_ctx.GetEngine();
platform::MKLDNNStream engine_stream(engine);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
platform::MKLDNNStream engine_stream(engine);
auto& astream = platform::MKLDNNDeviceContext::tls().get_stream();

source_data_md, engine, platform::to_void_cast<K>(filter_data));
auto reordered_data_mem = platform::MKLDNNMemory(reordered_data_md, engine);
platform::Reorder(source_data_mem, reordered_data_mem, engine);
engine_stream.wait();

return this->template AcquireMemoryWithReorder<K>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why "AcquireMemoryWithReorder" is called just after doing a reorder?

@jakpiase jakpiase added the Intel label Nov 14, 2021

return reordered_filter_data;
};
const platform::MKLDNNEngine& engine = dev_ctx.GetEngine();
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually think this block of code is not needed. What should be modified is fragment "filter->format()" to "dnnl::format_tag::iohw" (guess) and then AcquireMemoryWithReorder will take care of rordering from IOHW -> blocked_optimized format. In your current changes you have two reorders: IOHW -> OIHW and then OIHW to blocked_optimized_format. One issue here is that filter-<format() is returning (probably) OIHW while in fact data is IOHW .

Copy link
Contributor

@jczaja jczaja left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@jakpiase jakpiase left a comment

Choose a reason for hiding this comment

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

LGTM, good job!

@Silv3S
Copy link
Member Author

Silv3S commented Nov 17, 2021

@jczaja please merge

@jczaja jczaja merged commit 162ac04 into PaddlePaddle:develop Nov 17, 2021
@Silv3S Silv3S deleted the custom_reorder branch November 17, 2021 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MKL-DNN] Replace manually implemented reorder iohw->oihw with mkl-dnn one
4 participants