Skip to content
This repository was archived by the owner on Jul 22, 2026. It is now read-only.

Commit 559d8a6

Browse files
author
NeiroYT
committed
Test branch
1 parent 4800010 commit 559d8a6

22 files changed

Lines changed: 1269 additions & 333 deletions

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20)
22

33
project(ITLabAI)
44

5-
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
5+
# set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
66

77
option(ENABLE_STATISTIC_TENSORS "Enable statistic tensors" OFF)
88

@@ -22,7 +22,7 @@ if(ENABLE_STATISTIC_WEIGHTS)
2222
add_definitions(-DENABLE_STATISTIC_WEIGHTS)
2323
endif()
2424

25-
set(CMAKE_CXX_STANDARD 17)
25+
set(CMAKE_CXX_STANDARD 20)
2626

2727
enable_testing()
2828

app/Converters/parser_onnx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def default(self, obj):
166166

167167
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
168168

169-
MODEL_PATH = os.path.join(BASE_DIR, 'docs\\models', 'resnest101e_Opset16.onnx')
170-
MODEL_DATA_PATH = os.path.join(BASE_DIR, 'docs\\jsons', 'resnest101e_Opset16_onnx_model.json')
169+
MODEL_PATH = os.path.join(BASE_DIR, 'docs\\models', 'yolo11x-cls.pt')
170+
MODEL_DATA_PATH = os.path.join(BASE_DIR, 'docs\\jsons', 'yolo11x-cls_onnx_model.json')
171171

172172
onnx_to_json(MODEL_PATH, MODEL_DATA_PATH)

app/Graph/build.cpp

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
2525
std::string json_file = MODEL_PATH_H5;
2626
it_lab_ai::json model_data = it_lab_ai::read_json(json_file);
2727

28-
if (comments) std::cout << "Loaded model data from JSON." << '\n';
28+
if (comments) {
29+
std::cout << "Loaded model data from JSON." << '\n';
30+
}
2931

3032
for (const auto& layer_data : model_data) {
3133
std::string layer_type = layer_data["type"];
@@ -70,7 +72,9 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
7072
options, 1, pads, 1, tmp_values, tmp_bias, 1, true);
7173
layers.push_back(conv_layer);
7274
layerpostop.push_back(false);
73-
if (comments) std::cout << "ConvLayer added to layers." << '\n';
75+
if (comments) {
76+
std::cout << "ConvLayer added to layers." << '\n';
77+
}
7478
}
7579
if (layer_type.find("relu") != std::string::npos) {
7680
auto ew_layer = LayerFactory::createEwLayer("relu", options);
@@ -85,7 +89,9 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
8589
auto fc_layer = std::make_shared<it_lab_ai::FCLayer>(tensor, tmp_bias);
8690
layers.push_back(fc_layer);
8791
layerpostop.push_back(false);
88-
if (comments) std::cout << "DenseLayer added to layers." << '\n';
92+
if (comments) {
93+
std::cout << "DenseLayer added to layers." << '\n';
94+
}
8995
}
9096

9197
if (layer_type.find("Pool") != std::string::npos) {
@@ -105,15 +111,19 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
105111

106112
layers.push_back(pool_layer);
107113
layerpostop.push_back(false);
108-
if (comments) std::cout << "PoolingLayer added to layers." << '\n';
114+
if (comments) {
115+
std::cout << "PoolingLayer added to layers." << '\n';
116+
}
109117
}
110118

111119
if (layer_type.find("Flatten") != std::string::npos) {
112120
auto flatten_layer = std::make_shared<it_lab_ai::FlattenLayer>(
113121
std::vector<size_t>({0, 3, 2, 1}));
114122
layers.push_back(flatten_layer);
115123
layerpostop.push_back(false);
116-
if (comments) std::cout << "FlattenLayer added to layers." << '\n';
124+
if (comments) {
125+
std::cout << "FlattenLayer added to layers." << '\n';
126+
}
117127
}
118128

119129
if (layer_type.find("Dropout") != std::string::npos) {
@@ -128,26 +138,34 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
128138
}
129139
}
130140
}
131-
if (comments) std::cout << "number of layers - " << layers.size() + 1 << '\n';
141+
if (comments) {
142+
std::cout << "number of layers - " << layers.size() + 1 << '\n';
143+
}
132144
auto a1 = std::make_shared<it_lab_ai::InputLayer>(it_lab_ai::kNchw,
133145
it_lab_ai::kNchw);
134146

135-
if (comments) std::cout << "InputLayer created." << '\n';
147+
if (comments) {
148+
std::cout << "InputLayer created." << '\n';
149+
}
136150

137151
graph.setInput(a1, input);
138-
if (comments) std::cout << "Input set in graph." << '\n';
152+
if (comments) {
153+
std::cout << "Input set in graph." << '\n';
154+
}
139155

140156
graph.makeConnection(a1, layers[0]);
141-
if (comments)
157+
if (comments) {
142158
std::cout << "Connection made between InputLayer and first layer." << '\n';
159+
}
143160

144161
for (size_t i = 0; i < layers.size() - 1; ++i) {
145162
if (layerpostop[i]) {
146163
layers[i - 1]->postops.layers.push_back(layers[i]);
147164
layers[i - 1]->postops.count++;
148165
graph.makeConnection(layers[i - 1], layers[i + 1]);
149-
} else if (!layerpostop[i + 1])
166+
} else if (!layerpostop[i + 1]) {
150167
graph.makeConnection(layers[i], layers[i + 1]);
168+
}
151169
}
152170

153171
graph.setOutput(layers.back(), output);
@@ -195,21 +213,22 @@ void build_graph(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
195213
}
196214

197215
try {
198-
std::sort(
199-
connection_list.begin(), connection_list.end(),
200-
[&](const auto& a, const auto& b) {
201-
if (!name_to_layer.count(a.first) || !name_to_layer.count(b.first)) {
202-
return false;
203-
}
204-
return name_to_layer[a.first]->getID() <
205-
name_to_layer[b.first]->getID();
206-
});
216+
std::sort(connection_list.begin(), connection_list.end(),
217+
[&](const auto& a, const auto& b) {
218+
if (!name_to_layer.contains(a.first) ||
219+
!name_to_layer.contains(b.first)) {
220+
return false;
221+
}
222+
return name_to_layer[a.first]->getID() < name_to_layer[b.first]->getID();
223+
});
224+
207225
} catch (const std::exception& e) {
208226
std::cerr << "ERROR during sorting: " << e.what() << '\n';
209227
}
210228

211229
for (const auto& [source_name, target_name] : connection_list) {
212-
if (name_to_layer.count(source_name) && name_to_layer.count(target_name)) {
230+
if (name_to_layer.contains(source_name) &&
231+
name_to_layer.contains(target_name)) {
213232
if (target_name.find("Concat") != std::string::npos ||
214233
name_to_layer[target_name]->getName() == it_lab_ai::kConcat) {
215234
if (concat_connections.find(target_name) != concat_connections.end()) {
@@ -294,7 +313,9 @@ ParseResult parse_json_model(RuntimeOptions options,
294313
}
295314
}
296315

297-
if (comments) std::cout << "Loaded model data from JSON." << '\n';
316+
if (comments) {
317+
std::cout << "Loaded model data from JSON." << '\n';
318+
}
298319

299320
auto input_layer = std::make_shared<it_lab_ai::InputLayer>(it_lab_ai::kNchw,
300321
it_lab_ai::kNchw);
@@ -307,7 +328,9 @@ ParseResult parse_json_model(RuntimeOptions options,
307328
try {
308329
std::string layer_type = layer_data["type"];
309330

310-
if (layer_type == "InputLayer") continue;
331+
if (layer_type == "InputLayer") {
332+
continue;
333+
}
311334
std::string layer_name = layer_data["name"];
312335
int layer_index = layer_data["index"];
313336
if (comments) {
@@ -512,7 +535,7 @@ ParseResult parse_json_model(RuntimeOptions options,
512535
std::string constant_name = inputs[1].get<std::string>();
513536
constant_name = get_base_layer_name(constant_name);
514537

515-
if (layer_parameters.count(constant_name)) {
538+
if (layer_parameters.contains(constant_name)) {
516539
splits = layer_parameters[constant_name];
517540
} else if (constant_name.find("onnx::") != std::string::npos) {
518541
splits = last_constant_value;
@@ -701,7 +724,9 @@ ParseResult parse_json_model(RuntimeOptions options,
701724
std::cout << "TransposeLayer added with perm: [";
702725
for (size_t i = 0; i < perm.size(); ++i) {
703726
std::cout << perm[i];
704-
if (i < perm.size() - 1) std::cout << ", ";
727+
if (i < perm.size() - 1) {
728+
std::cout << ", ";
729+
}
705730
}
706731
std::cout << "]" << '\n';
707732
}
@@ -715,7 +740,7 @@ ParseResult parse_json_model(RuntimeOptions options,
715740
std::string constant_name = inputs[1].get<std::string>();
716741
constant_name = get_base_layer_name(constant_name);
717742

718-
if (layer_parameters.count(constant_name)) {
743+
if (layer_parameters.contains(constant_name)) {
719744
shape = layer_parameters[constant_name];
720745
}
721746
}
@@ -777,7 +802,7 @@ ParseResult parse_json_model(RuntimeOptions options,
777802
std::string constant_name = inputs[1].get<std::string>();
778803
constant_name = get_base_layer_name(constant_name);
779804

780-
if (layer_parameters.count(constant_name)) {
805+
if (layer_parameters.contains(constant_name)) {
781806
axes = layer_parameters[constant_name];
782807
} else if (constant_name.find("onnx::") != std::string::npos) {
783808
axes = last_constant_value;

app/Graph/graph_build.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ int main(int argc, char* argv[]) {
3838
options.par_backend = ParBackend::kThreads;
3939
} else if (backend_str == "omp") {
4040
options.par_backend = ParBackend::kOmp;
41-
} else if (backend_str == "kokkos") {
42-
options.par_backend = ParBackend::kKokkos;
4341
} else {
4442
std::cerr << "Unknown parallel backend: " << backend_str
4543
<< ". Using default (Threads)." << '\n';

0 commit comments

Comments
 (0)