Skip to content

Commit 5075d25

Browse files
authored
Merge branch 'main' into Semyon1104/BuildGraph_branching
2 parents 2a49ff5 + ccaf84d commit 5075d25

8 files changed

Lines changed: 144 additions & 30 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
env:
107107
CTEST_OUTPUT_ON_FAILURE: 1
108108
build-macos:
109-
runs-on: macos-14
109+
runs-on: macos-15
110110
steps:
111111
- uses: actions/checkout@v4
112112
with:
@@ -132,21 +132,27 @@ jobs:
132132
env:
133133
CTEST_OUTPUT_ON_FAILURE: 1
134134
build-windows:
135-
runs-on: windows-2022
135+
runs-on: windows-2025
136136
steps:
137137
- uses: actions/checkout@v4
138138
with:
139139
submodules: true
140+
- name: Add msbuild to PATH
141+
uses: microsoft/setup-msbuild@v2
142+
with:
143+
vs-version: 'latest'
140144
- name: Setup ccache
141-
uses: hendrikmuhs/ccache-action@v1.2
145+
uses: Chocobo1/setup-ccache-action@v1
142146
with:
143-
key: ccache-${{ github.job }}
144-
max-size: 2G
145-
variant: sccache
147+
windows_compile_environment: msvc
148+
- name: Setup ninja
149+
uses: seanmiddleditch/gha-setup-ninja@v6
150+
- name: Setup MSVC for Ninja again
151+
uses: ilammy/msvc-dev-cmd@v1
146152
- name: Build
147153
run: |
148-
cmake -S . -B build -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
149-
cmake --build build --parallel
154+
cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release
155+
cmake --build build --parallel --config Release
150156
- name: Test
151157
run: |
152158
cd build
@@ -159,9 +165,16 @@ jobs:
159165
submodules: true
160166
- name: Install prerequisites
161167
run: sudo apt-get update && sudo apt-get install -y libomp-dev build-essential cmake
168+
- name: Setup ccache
169+
uses: hendrikmuhs/ccache-action@v1.2
170+
with:
171+
key: ccache-${{ github.job }}
162172
- name: Build and Test
163173
run: |
164-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
174+
cmake -S . -B build \
175+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
176+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
177+
-DCMAKE_BUILD_TYPE=Release
165178
cmake --build build --parallel
166179
cmake --build build -t test
167180
env:
@@ -269,7 +282,7 @@ jobs:
269282
- name: Verify library integrity
270283
run: |
271284
echo "### Library verification ###"
272-
file build/bin/opencv_libs/libopencv_imgcodecs.so.4.9.0 | grep "shared object"
285+
file build/bin/opencv_libs/libopencv_imgcodecs.so.4.12.0 | grep "shared object"
273286
274287
- name: Run evaluation
275288
run: |

3rdparty/opencv

Submodule opencv updated 2148 files

app/Graph/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,9 @@ if (NOT CMAKE_BUILD_TYPE)
2626
endif()
2727

2828
if (WIN32)
29-
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
30-
set(CMAKE_BUILD_TYPE "Debug")
31-
endif()
32-
if ("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
33-
set(CMAKE_BUILD_TYPE "Release")
34-
endif()
3529
add_custom_command(TARGET Graph_Build POST_BUILD
3630
COMMAND ${CMAKE_COMMAND} -E copy_directory
37-
"${OPENCV_BUILD_DIR}/bin/${CMAKE_BUILD_TYPE}/."
31+
"${OPENCV_BUILD_DIR}/bin/."
3832
"${CMAKE_BINARY_DIR}/bin/")
3933
endif()
4034

@@ -47,7 +41,7 @@ if (WIN32)
4741
endif()
4842
add_custom_command(TARGET ACC POST_BUILD
4943
COMMAND ${CMAKE_COMMAND} -E copy_directory
50-
"${OPENCV_BUILD_DIR}/bin/${CMAKE_BUILD_TYPE}/."
44+
"${OPENCV_BUILD_DIR}/bin/."
5145
"${CMAKE_BINARY_DIR}/bin/")
5246
endif()
5347

include/layers/OutputLayer.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ std::pair<std::vector<std::string>, std::vector<ValueType>> top_k_vec(
104104
for (size_t i = 0; i < input.size(); i++) {
105105
sort_buf[i] = std::make_pair(labels[i], input[i]);
106106
}
107-
std::sort(sort_buf.begin(), sort_buf.end(), compare_pair<ValueType>);
107+
std::partial_sort(sort_buf.begin(), sort_buf.begin() + k, sort_buf.end(),
108+
compare_pair<ValueType>);
108109
std::vector<std::string> res_labels(k);
109110
std::vector<ValueType> res_input(k);
110111
for (size_t i = 0; i < k; i++) {

test/CMakeLists.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,22 @@ if (NOT WIN32)
55
target_link_libraries(run_test PUBLIC OpenMP::OpenMP_CXX)
66
endif()
77
target_link_libraries(run_test PUBLIC perf_lib layers_lib)
8-
target_link_libraries(run_test PUBLIC gtest_main)
8+
target_link_libraries(run_test PUBLIC gtest)
99
target_link_libraries(run_test PUBLIC ReadLib)
1010
target_link_libraries(run_test PUBLIC reader_lib)
1111

1212

13+
target_include_directories(run_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
1314
target_include_directories(run_test PRIVATE "${CMAKE_SOURCE_DIR}/app/ReaderImage")
1415

1516
if (NOT CMAKE_BUILD_TYPE)
1617
set(CMAKE_BUILD_TYPE "Debug")
1718
endif()
1819

1920
if (WIN32)
20-
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
21-
set(CMAKE_BUILD_TYPE "Debug")
22-
endif()
23-
if ("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
24-
set(CMAKE_BUILD_TYPE "Release")
25-
endif()
2621
add_custom_command(TARGET run_test POST_BUILD
2722
COMMAND ${CMAKE_COMMAND} -E copy_directory
28-
"${OPENCV_BUILD_DIR}/bin/${CMAKE_BUILD_TYPE}/."
23+
"${OPENCV_BUILD_DIR}/bin/."
2924
"${CMAKE_BINARY_DIR}/bin/")
3025
endif()
3126

test/inference/test_inference.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "layers/OutputLayer.hpp"
1313
#include "layers/PoolingLayer.hpp"
1414
#include "layers/SplitLayer.hpp"
15+
#include "utils/flaky_test_runner.hpp"
1516

1617
using namespace it_lab_ai;
1718

@@ -494,7 +495,7 @@ TEST(bfs, check_struct_layer_added) {
494495
ASSERT_EQ(tmp, res);
495496
}
496497

497-
TEST(bfs, check_struct_graph_split) {
498+
FLAKY_TEST(bfs, check_struct_graph_split) {
498499
std::vector<std::vector<std::pair<int, int>>> split = {
499500
{{12, 0}, {13, 0}, {14, 0}}};
500501
Graph graph(151, split);
@@ -572,4 +573,5 @@ TEST(bfs, check_struct_graph_split) {
572573
std::vector<int> tmp = *output.as<int>();
573574
std::vector<int> res(36, 81);
574575
ASSERT_EQ(tmp, res);
575-
}
576+
}
577+
FLAKY_END_TEST

test/main.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <gtest/gtest.h>
2+
3+
#include <cstdlib>
4+
#include <cstring>
5+
#include <iostream>
6+
7+
int main(int argc, char** argv) {
8+
::testing::InitGoogleTest(&argc, argv);
9+
10+
const char* flaky_disabled = std::getenv("DISABLE_FLAKY_TESTS");
11+
bool flaky_enabled =
12+
(flaky_disabled == nullptr) || (std::strcmp(flaky_disabled, "1") != 0 &&
13+
std::strcmp(flaky_disabled, "true") != 0);
14+
15+
if (flaky_enabled) {
16+
const char* retries = std::getenv("FLAKY_RETRIES");
17+
int retry_count = retries ? std::atoi(retries) : 10;
18+
std::cout << "Flaky test support enabled. Max retries: " << retry_count
19+
<< std::endl;
20+
std::cout << "Use FLAKY_TEST/FLAKY_TEST_F macros to create flaky tests."
21+
<< std::endl;
22+
}
23+
24+
return RUN_ALL_TESTS();
25+
}

test/utils/flaky_test_runner.hpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#pragma once
2+
3+
#include <gtest/gtest.h>
4+
5+
#include <cstdlib>
6+
#include <cstring>
7+
#include <iostream>
8+
9+
namespace test_utils {
10+
11+
static int getFlakyRetries() {
12+
const char* retry_env = std::getenv("FLAKY_RETRIES");
13+
if (retry_env != nullptr) {
14+
try {
15+
int retries = std::stoi(retry_env);
16+
return std::max(1, std::min(retries, 100));
17+
} catch (const std::exception&) {
18+
return 10;
19+
}
20+
}
21+
return 10;
22+
}
23+
24+
static bool isFlakyTestsEnabled() {
25+
const char* disabled = std::getenv("DISABLE_FLAKY_TESTS");
26+
if (disabled == nullptr) {
27+
return true;
28+
}
29+
return std::strcmp(disabled, "1") != 0 && std::strcmp(disabled, "true") != 0;
30+
}
31+
32+
template <typename TestFunc>
33+
void runFlakyTest(const char* test_name, TestFunc test_func) {
34+
if (!isFlakyTestsEnabled()) {
35+
test_func();
36+
return;
37+
}
38+
39+
int max_retries = getFlakyRetries();
40+
41+
for (int attempt = 1; attempt <= max_retries; ++attempt) {
42+
try {
43+
if (attempt > 1) {
44+
std::cout << "[FLAKY RETRY " << attempt << "/" << max_retries << "] "
45+
<< test_name << std::endl;
46+
}
47+
48+
test_func();
49+
50+
if (attempt > 1) {
51+
std::cout << "[FLAKY SUCCESS] " << test_name << " passed on attempt "
52+
<< attempt << std::endl;
53+
}
54+
return;
55+
56+
} catch (...) {
57+
if (attempt == max_retries) {
58+
std::cout << "[FLAKY EXHAUSTED] " << test_name << " failed after "
59+
<< max_retries << " attempts" << std::endl;
60+
throw;
61+
} else if (attempt == 1) {
62+
std::cout << "[FLAKY FAILED] " << test_name << " failed on attempt "
63+
<< attempt << ", retrying..." << std::endl;
64+
}
65+
}
66+
}
67+
}
68+
69+
#define FLAKY_TEST(test_case_name, test_name) \
70+
TEST(test_case_name, test_name) { \
71+
auto flaky_test_body = []()
72+
73+
#define FLAKY_TEST_F(test_fixture, test_name) \
74+
TEST_F(test_fixture, test_name) { \
75+
auto flaky_test_body = [this]()
76+
77+
#define FLAKY_END_TEST \
78+
; \
79+
test_utils::runFlakyTest( \
80+
testing::UnitTest::GetInstance()->current_test_info()->name(), \
81+
flaky_test_body); \
82+
}
83+
84+
}

0 commit comments

Comments
 (0)