Skip to content

Commit 291328f

Browse files
committed
variables
1 parent e446579 commit 291328f

2 files changed

Lines changed: 35 additions & 31 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,17 @@ jobs:
340340
parser: parser_onnx.py
341341
model_file: densenet121_Opset16.onnx
342342
model_url: https://github.com/onnx/models/raw/refs/heads/main/Computer_Vision/densenet121_Opset16_timm/densenet121_Opset16.onnx?download=
343-
extra_args: "--onednn 1000"
343+
extra_args: "--onednn 10000"
344344
- model: resnet
345345
parser: parser_onnx.py
346346
model_file: resnest101e_Opset16.onnx
347347
model_url: https://github.com/onnx/models/raw/refs/heads/main/Computer_Vision/resnest101e_Opset16_timm/resnest101e_Opset16.onnx?download=
348-
extra_args: "--onednn 1000"
348+
extra_args: "--onednn 10000"
349349
- model: yolo
350350
parser: parser_onnx.py
351351
model_file: yolo11x-cls.pt
352352
model_url: https://github.com/ultralytics/assets/releases/download/v8.4.0/yolo11x-cls.pt
353-
extra_args: "--onednn 1000"
353+
extra_args: "--onednn 10000"
354354

355355
steps:
356356
- uses: actions/checkout@v4

app/Graph/acc_check.cpp

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,23 @@ int main(int argc, char* argv[]) {
5454
options.threads = std::stoi(argv[++i]);
5555
} else {
5656
try {
57-
num_photo = std::stoi(argv[i]);
58-
59-
if (num_photo < 1 || num_photo > 50000) {
60-
std::cerr << "Warning: num_photo should be between 1 and 0000 "
61-
<< "Using value: " << num_photo << '\n';
57+
size_t input_value = std::stoul(argv[i]);
58+
59+
if (input_value < 1) {
60+
std::cerr << "Warning: num_photo cannot be less than 1. Using 1."
61+
<< '\n';
62+
num_photo = 1;
63+
} else if (input_value > 50000) {
64+
std::cerr << "Warning: num_photo cannot exceed 50000. Using 50000."
65+
<< '\n';
66+
num_photo = 50000;
67+
} else {
68+
num_photo = input_value;
6269
}
6370
} catch (const std::exception& e) {
64-
std::cerr << "Error: Invalid numeric argument: " << argv[i]
65-
<< ". Using default value: 1000" << e.what() << '\n';
71+
std::cerr << "Error: Invalid numeric argument: " << e.what() << argv[i]
72+
<< ". Using default value: 1000" << '\n';
73+
num_photo = 1000;
6674
}
6775
}
6876
}
@@ -113,7 +121,7 @@ int main(int argc, char* argv[]) {
113121
for (int j = 0; j < 28; ++j) {
114122
size_t a = ind;
115123
for (size_t n = 0; n < name; n++) a += counts[n] + 1;
116-
res[(a)*28 * 28 + i * 28 + j] = channels[0].at<uchar>(j, i);
124+
res[(a) * 28 * 28 + i * 28 + j] = channels[0].at<uchar>(j, i);
117125
}
118126
}
119127
}
@@ -150,10 +158,11 @@ int main(int argc, char* argv[]) {
150158

151159
return 0;
152160
}
161+
153162
size_t output_classes = 1000;
154163
std::vector<size_t> counts(output_classes, 0);
155164

156-
for (int class_id = 0; class_id < output_classes; ++class_id) {
165+
for (size_t class_id = 0; class_id < output_classes; ++class_id) {
157166
std::ostringstream folder_oss;
158167
folder_oss << std::setw(5) << std::setfill('0') << class_id;
159168
std::string class_folder_path = dataset_path + "/" + folder_oss.str();
@@ -168,15 +177,14 @@ int main(int argc, char* argv[]) {
168177
}
169178
}
170179
}
171-
180+
172181
size_t images_per_class_base = num_photo / output_classes;
173182
size_t remaining = num_photo % output_classes;
174183

175184
int channels = input_shape[1];
176185
int height = input_shape[2];
177186
int width = input_shape[3];
178187
size_t image_size = channels * height * width;
179-
180188

181189
int correct_predictions_top1 = 0;
182190
int correct_predictions_top5 = 0;
@@ -196,9 +204,8 @@ int main(int argc, char* argv[]) {
196204
batch_data.reserve(batch_size * image_size);
197205
batch_labels.reserve(batch_size);
198206

199-
for (int class_id = 0;
200-
class_id < output_classes && total_processed < num_photo;
201-
++class_id) {
207+
for (size_t class_id = 0;
208+
class_id < output_classes && total_processed < num_photo; ++class_id) {
202209
size_t need_from_class = images_per_class_base;
203210
if (remaining > 0) {
204211
need_from_class++;
@@ -236,7 +243,7 @@ int main(int argc, char* argv[]) {
236243
const auto& img_data = *prepared.as<float>();
237244

238245
batch_data.insert(batch_data.end(), img_data.begin(), img_data.end());
239-
batch_labels.push_back(class_id);
246+
batch_labels.push_back(static_cast<int>(class_id));
240247
total_processed++;
241248

242249
if (batch_labels.size() >= batch_size) {
@@ -295,15 +302,15 @@ int main(int argc, char* argv[]) {
295302
int true_label = batch_labels[i];
296303

297304
std::vector<std::pair<float, int>> top5;
298-
for (int j = 0; j < output_classes; ++j) {
305+
for (size_t j = 0; j < output_classes; ++j) {
299306
float val = img_start[j];
300307

301308
if (top5.size() < 5) {
302-
top5.emplace_back(val, j);
309+
top5.emplace_back(val, static_cast<int>(j));
303310
std::sort(top5.begin(), top5.end(),
304311
[](auto& a, auto& b) { return a.first > b.first; });
305312
} else if (val > top5.back().first) {
306-
top5.back() = {val, j};
313+
top5.back() = {val, static_cast<int>(j)};
307314
std::sort(top5.begin(), top5.end(),
308315
[](auto& a, auto& b) { return a.first > b.first; });
309316
}
@@ -367,14 +374,14 @@ int main(int argc, char* argv[]) {
367374
int true_label = batch_labels[i];
368375

369376
std::vector<std::pair<float, int>> top5;
370-
for (int j = 0; j < output_classes; ++j) {
377+
for (size_t j = 0; j < output_classes; ++j) {
371378
float val = img_start[j];
372379
if (top5.size() < 5) {
373-
top5.emplace_back(val, j);
380+
top5.emplace_back(val, static_cast<int>(j));
374381
std::sort(top5.begin(), top5.end(),
375382
[](auto& a, auto& b) { return a.first > b.first; });
376383
} else if (val > top5.back().first) {
377-
top5.back() = {val, j};
384+
top5.back() = {val, static_cast<int>(j)};
378385
std::sort(top5.begin(), top5.end(),
379386
[](auto& a, auto& b) { return a.first > b.first; });
380387
}
@@ -391,16 +398,13 @@ int main(int argc, char* argv[]) {
391398
}
392399

393400
auto total_end_time = std::chrono::high_resolution_clock::now();
394-
int total_time =
395-
static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(
396-
total_end_time - total_start_time)
397-
.count());
398401

399-
std::cout << "\n========== TOTAL STATISTICS FOR ALL BATCHES ==========\n";
400402
std::cout << "Total inference time: " << total_inference_time << " ms\n";
401403
std::cout << "Number of batches: " << batch_count << '\n';
402-
std::cout << "Average time per batch: " << total_inference_time / batch_count
403-
<< " ms\n";
404+
if (batch_count > 0) {
405+
std::cout << "Average time per batch: "
406+
<< total_inference_time / batch_count << " ms\n";
407+
}
404408

405409
double final_accuracy_top1 =
406410
(static_cast<double>(correct_predictions_top1) / num_photo) * 100;

0 commit comments

Comments
 (0)