Skip to content

fuse Conv+Add+activation for CPU from different op-branch - #10987

Merged
wejoncy merged 4 commits into
masterfrom
jicheng/fuse_elmentwise_op
Apr 1, 2022
Merged

fuse Conv+Add+activation for CPU from different op-branch#10987
wejoncy merged 4 commits into
masterfrom
jicheng/fuse_elmentwise_op

Conversation

@wejoncy

@wejoncy wejoncy commented Mar 24, 2022

Copy link
Copy Markdown
Contributor

Description: Describe your changes.
For CPU, we have to pay the cost of reschedule thread and re-read the data from memory for a even a element-wise op.
But once all of them fused into one Op, we don't need to pay for that. the benefit is strait forward for Resnet-like models.

RedMi Note9 resnet50_v1.onnx
before Average inference time cost: 260.355 ms
after Average inference time cost: 252.672 ms
RedMi K40 resnet50_v1.onnx
before Average inference time cost: 87.74 ms
after Average inference time cost: 83.0393 ms

Motivation and Context

  • Why is this change required? What problem does it solve?
  • If it fixes an open issue, please link to the issue here.

Comment thread include/onnxruntime/core/graph/constants.h Outdated
Comment thread onnxruntime/core/graph/contrib_ops/mobile_schema_defs.cc Outdated
Comment thread onnxruntime/core/optimizer/graph_transformer_utils.cc Outdated
Comment thread onnxruntime/core/optimizer/mobile_transformer.cc Outdated
Comment thread onnxruntime/core/optimizer/mobile_transformer.cc Outdated
Comment thread onnxruntime/core/optimizer/mobile_transformer.cc Outdated
Comment thread onnxruntime/core/optimizer/mobile_transformer.cc Outdated
Comment thread onnxruntime/core/optimizer/mobile_transformer.cc Outdated
Comment thread onnxruntime/core/optimizer/mobile_transformer.cc Outdated
Comment thread onnxruntime/core/optimizer/mobile_transformer.cc Outdated
Comment thread onnxruntime/core/providers/cpu/nn/conv.cc
Comment thread onnxruntime/core/optimizer/graph_transformer_utils.cc Outdated
Comment thread onnxruntime/core/optimizer/graph_transformer_utils.cc
@skottmckay

Copy link
Copy Markdown
Contributor

Chen Fu (@chenfucn) or Yufeng Li (@yufenglee) could you please review the changes to mlas code?

Comment thread onnxruntime/core/mlas/lib/convolve.cpp Outdated
Comment thread onnxruntime/core/optimizer/conv_add_act_fusion.cc Outdated
Comment thread onnxruntime/core/optimizer/conv_add_act_fusion.cc Outdated
Comment thread onnxruntime/core/optimizer/conv_add_act_fusion.cc Outdated
Comment thread onnxruntime/core/optimizer/conv_add_act_fusion.cc Outdated
Comment thread onnxruntime/core/optimizer/conv_add_act_fusion.cc Outdated
@wejoncy
wejoncy force-pushed the jicheng/fuse_elmentwise_op branch from 2d8b9b0 to 5c633c6 Compare March 30, 2022 12:10
Comment thread onnxruntime/core/mlas/inc/mlas.h Outdated
Comment thread onnxruntime/core/mlas/inc/mlas.h Outdated

@yufenglee Yufeng Li (yufenglee) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Change in MLAS looks good to me.

@skottmckay Scott McKay (skottmckay) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

@wejoncy
wejoncy merged commit 11a4ca7 into master Apr 1, 2022
@wejoncy
wejoncy deleted the jicheng/fuse_elmentwise_op branch April 1, 2022 01:25
Rinne (SanftMonster) pushed a commit to SanftMonster/onnxruntime that referenced this pull request Apr 1, 2022
…10987)

* Fuse op conv Add and activation from two branch
* simplify code

Co-authored-by: Jicheng Wen <jicwen@microsoft.com>
wejoncy added a commit that referenced this pull request Apr 1, 2022
* Fuse op conv Add and activation from two branch
* simplify code

Co-authored-by: Jicheng Wen <jicwen@microsoft.com>
wejoncy added a commit that referenced this pull request Apr 19, 2022
* Fuse op conv Add and activation from two branch
* simplify code

Co-authored-by: Jicheng Wen <jicwen@microsoft.com>
wejoncy pushed a commit that referenced this pull request Apr 19, 2022
* Fuse op conv Add and activation from two branch
* simplify code
Mike Seddon (seddonm1) pushed a commit to seddonm1/onnxruntime that referenced this pull request May 15, 2022
…10987)

* Fuse op conv Add and activation from two branch
* simplify code

Co-authored-by: Jicheng Wen <jicwen@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants