Skip to content

Fuse Convolution + Activation node as a part of graph transformations pipeline#276

Merged
allnes merged 15 commits into
mainfrom
neiroyt/feature_fuseconvrelu
Mar 13, 2026
Merged

Fuse Convolution + Activation node as a part of graph transformations pipeline#276
allnes merged 15 commits into
mainfrom
neiroyt/feature_fuseconvrelu

Conversation

@NeiroYT

@NeiroYT NeiroYT commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Closes #272

@codecov

codecov Bot commented Feb 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.06061% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.95%. Comparing base (028996d) to head (e27d175).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/layers_fused/ConvRelu.cpp 79.24% 9 Missing and 13 partials ⚠️
include/layers_fused/ConvRelu.hpp 91.38% 8 Missing and 10 partials ⚠️
...rc/graph_transformations/graph_transformations.cpp 28.57% 3 Missing and 2 partials ⚠️
include/layers/ConvLayer.hpp 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #276      +/-   ##
==========================================
+ Coverage   84.42%   84.95%   +0.53%     
==========================================
  Files          57       59       +2     
  Lines        3274     3710     +436     
  Branches     1989     2287     +298     
==========================================
+ Hits         2764     3152     +388     
- Misses        245      271      +26     
- Partials      265      287      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

NeiroYT added 12 commits February 27, 2026 19:04
…_2023 into neiroyt/feature_fuseconvrelu

e enter a commit message to explain why this merge is necessary,
iall if it merges an updated upstream into a topic branch.

 starting with '#' will be ignored, and an empty message aborts
}
std::shared_ptr<Layer> layer = layer_based_shared_copy(layer_to, options);
std::shared_ptr<Layer> layer;
if (layer_to->getName() == kConvRelu &&

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.

Can't we use layer_based_shared_copy() for kConvRelu case as well? This looks cumbersome

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

layer_based_shared_copy() copies layer (shared_ptr layer_to in this case), also this func is used in graph.clone().
However any ConvRelu in new graph needs fields from ConvLayer+Relu, so here in general case a new function can be implemented, which constructs layer depending on what we want.

Comment thread include/graph/graph.hpp Outdated
start_ = layer->getID();
}

void setInput(Tensor& vec) {

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.

Is it possible to avoid introducing setInput/setOutput just for the one function call?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ok

Comment thread app/Graph/build.cpp
void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
it_lab_ai::Tensor& output, RuntimeOptions options,
bool comments) {
bool comments, bool enable_postops) {

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.

I remember you mentioned that you need ito set enable_postops = false. Where is that?

Comment thread src/layers_fused/ConvRelu.cpp Outdated
Comment on lines +18 to +30
conv.run(input, output, options);
switch (input[0].get_type()) {
case Type::kInt: {
relu<int>(output[0]);
break;
}
case Type::kFloat: {
relu<float>(output[0]);
break;
}
default: {
throw std::runtime_error("Unsupported tensor type");
}

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.

Now I clearly see why conv + relu exec time is the same as with fused layers. You need to implement fsed implementation here to see the time difference instead of calling two layers

@allnes allnes merged commit e581001 into main Mar 13, 2026
23 checks passed
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.

Fuse Convolution + Activation node as a part of graph transformations pipeline

3 participants