Skip to content

Faster reference implementation for operator Conv based on im2col #5069

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

Merged
merged 23 commits into from
May 11, 2023

Conversation

xadupre
Copy link
Contributor

@xadupre xadupre commented Mar 30, 2023

Description

Current implementation of Operator Conv is very slow. This is a faster one based on im2col.

Measures with shape(X)=(1, 1, 64, 64), shape(kernel)=(3, 3), before time is 0.0033s, after time is 0.00075, > 4 times faster. This ratio is higher with bigger matrices.

Motivation and Context

Performance.

xadupre added 2 commits March 27, 2023 15:22
Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: xadupre <xadupre@microsoft.com>
@xadupre xadupre changed the title [WIP] Faster rference implementation for operator Conv based on im2col [WIP] Faster reference implementation for operator Conv based on im2col Mar 30, 2023
xadupre added 2 commits March 30, 2023 18:37
Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: xadupre <xadupre@microsoft.com>
@xadupre xadupre changed the title [WIP] Faster reference implementation for operator Conv based on im2col Faster reference implementation for operator Conv based on im2col Apr 3, 2023
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Xavier Dupré <xadupre@users.noreply.github.com>
@gramalingam
Copy link
Contributor

A general idea (applies to both conv and im2col). It makes sense to me to support multiple implementations of an op (specifically, here, one may be slower/naive but easier to verify correct or read and understand, while another may be more efficient).

Shall we adopt some naming convention for the methods in the classes that implement the ops to support this?

So, for example, your naive implementation of im2col can go back into the main class (instead of being in the testing code). We just use an appropriate suffix to distinguish the two implementations. Eg., may be add _optimized for the faster on. Or, add _spec to the naive implementation.

xadupre added 4 commits April 25, 2023 13:05
Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: xadupre <xadupre@microsoft.com>
xadupre added 9 commits April 25, 2023 17:01
Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: xadupre <xadupre@microsoft.com>
@xadupre xadupre enabled auto-merge (squash) May 11, 2023 09:50
@xadupre xadupre merged commit 61dbadb into onnx:main May 11, 2023
adityagoel4512 pushed a commit to adityagoel4512/onnx that referenced this pull request Jul 28, 2023
…nx#5069)

Signed-off-by: xadupre <xadupre@microsoft.com>
Signed-off-by: Xavier Dupré <xadupre@users.noreply.github.com>
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Aditya Goel <agoel4512@gmail.com>
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