Skip to content

BuildGraph for GoogleNet, DenseNet, ResNet, Yolo. Add MatMul_Layer, SoftMax_Layer, Reshape_Layer, BatchNormalization_Layer. Modificates for FCLayer, Flatten, Pooling, Convolution. Add universal accuracy check#212

Merged
aobolensk merged 62 commits into
mainfrom
Semyon1104/BuildGraph_branching
Oct 20, 2025

Conversation

@Semyon1104

@Semyon1104 Semyon1104 commented Sep 30, 2025

Copy link
Copy Markdown
Collaborator

The accuracy of alexnet_mnist remained the same at 98.01%

At the time of PR, the inference speed for one image is as follows: Googlenet - 1.5 seconds, Densenet - 2.8 seconds, Yolo - 7.6 seconds, Resnet - 14.6 seconds (after modifying the parallelism in the convolution layer, parallelization is performed not by batch size, but by output). It should also be noted that if the laptop is not charging, the time for each network increases by an average of 2 times.

I think I'll need to add parallelism for EWLayer, as it takes a long time to run in some places

The test dataset currently contains 50,000 images, and I think that before running accuracy, we should try to to optimize some parts further, both in the graph assembly and image preparation, and possibly within the layers. For example, there is no parallel implementation for ConvDepthVise and EWlayer, which immediately comes to mind. Alternatively, we can check the accuracy on smaller parts of the dataset.

@Semyon1104 Semyon1104 force-pushed the Semyon1104/BuildGraph_branching branch from 6997efa to c06e0cd Compare October 2, 2025 20:28
Comment thread app/Graph/build.cpp Outdated
Comment on lines +298 to +307
input_layer->setName(it_lab_ai::kInput);
layers.push_back(input_layer);
if (json_path == MODEL_PATH_RESNET_ONNX ||
json_path == MODEL_PATH_DENSENET_ONNX) {
name_to_layer["x"] = input_layer;
} else if (json_path == MODEL_PATH_GOOGLENET_ONNX) {
name_to_layer["image_tensor"] = input_layer;
} else {
name_to_layer["images"] = input_layer;
}

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.

This should be specified as a parameter, so we will have no need to hardcode every input layer name for each net

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.

fixed

Comment thread app/Graph/graph_build.cpp

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.

We need to clean up debug logs everywhere

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.

everywhere in graph_build.cpp?

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.

Newly added ones should be removed at least

Comment thread docs/imagenet1000_clsidx_to_labels.txt Outdated

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.

If you replace ' with " you may use it as a .json file

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.

fixed

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.

Rename it .json as well

Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread app/Converters/parser_onnx.py
Comment thread app/Converters/parser_onnx.py Outdated
Comment thread include/layers/FCLayer.hpp
Comment thread include/layers/FCLayer.hpp
Comment thread include/layers/FCLayer.hpp
Comment thread test/single_layer/test_fclayer.cpp
Comment thread src/layers/BatchNormalizationLayer.cpp
@NeiroYT

NeiroYT commented Oct 9, 2025

Copy link
Copy Markdown
Collaborator

Why should we have that big pull request (~6k lines of changes) without proper explanations for these changes?
It will be hard to explain this after some time, so you can do this now in description, or split these changes into different PRs

@allnes allnes requested review from NeiroYT and aobolensk October 18, 2025 09:56
@Semyon1104 Semyon1104 force-pushed the Semyon1104/BuildGraph_branching branch from 9c89a34 to 2229aa7 Compare October 18, 2025 10:42
Comment thread app/Graph/build.cpp
}
}

void build_graph(it_lab_ai::Tensor& input, it_lab_ai::Tensor& output,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please consider shortening this function, for example giant for (const auto& layer_data : model_data) parsing can be moved away to different function or even class.
main idea of build_graph is not parsing after all

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.

fixed

Comment thread include/graph/graph.hpp Outdated
if (layers_[current_layer]->getName() == kSplit) {
for (const auto& tensor : outten_) {
for (size_t d = 0; d < tensor.get_shape().dims(); ++d) {
if (d < tensor.get_shape().dims() - 1) std::cout << "";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what is this?

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.

sorry, fixed

3.0f, 9.0f, 4.0f, 10.0f, 5.0f, 11.0f,
12.0f, 18.0f, 13.0f, 19.0f, 14.0f, 20.0f,
15.0f, 21.0f, 16.0f, 22.0f, 17.0f, 23.0f};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why test of correctness of flatten layer was removed?

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.

fixed

@aobolensk aobolensk 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.

Let's proceed with what we have right now

@aobolensk aobolensk merged commit 3d2f33b into main Oct 20, 2025
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.

4 participants