OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[CS] New usercases added + Templ. infr. + Userguide (#30353)
Yury Gaydaychuk8331c1476591
diff --git a/tools/commit_slider/common_architecture.md b/tools/commit_slider/common_architecture.mdindex 439ae6e7fce..98f55296425 100644--- a/tools/commit_slider/common_architecture.md+++ b/tools/commit_slider/common_architecture.md@@ -1,4 +1,22 @@## CS workflow with template++There are two essential approaches to solving problems via CS: pure configuration and `Template`. In the first case we use full functional under-hood. `Template` gives opportunity to create custom API and output representation.++CS uses `Template` via configuration:+```+{+ 'template' : {+ 'name' : 'some_template',+ 'parameter_1' : '...',+ ...+ 'parameter_N' : '...'+ }+}+```+or via CLI:++`python3 commit_slider -t some_template <template parameters>`+```mermaidsequenceDiagramparticipant Userdiff --git a/tools/commit_slider/dev_guide.md b/tools/commit_slider/dev_guide.mdnew file mode 100644index 00000000000..be63b1af931--- /dev/null+++ b/tools/commit_slider/dev_guide.md@@ -0,0 +1,13 @@+# How to customize CS for specific user case++To face the user case we should clarify some aspects.++- Customization of existing Mode / creating a new one.+- The way of linking/compilation of main app.+- What kind of analisys do we need ?+- Do we need some preparation (collecting of specific data, validation of hardware behaviour, code preprocessing) ?+- Validation of result.+- API design.++Examples of solved problems:+([Performance cross-checking](perf_cross_check.md))\ No newline at end of filediff --git a/tools/commit_slider/perf_cross_check.md b/tools/commit_slider/perf_cross_check.mdnew file mode 100644index 00000000000..88722f904f6--- /dev/null+++ b/tools/commit_slider/perf_cross_check.md@@ -0,0 +1,338 @@+# Case #1. Cross-checking of performance degradation.++([Basic concepts.](README.md) [More about templates.](common_architecture.md))++#### Themes: Mode and Template customization, API design+++For 2 given versions, defined by commit hashes and 2 models we need to resolve which of two changes (ov or model) caused degradation. In other words, we need to differentiate 2 possible cases:++model-caused:+|'Bad' model | model_1.xml| model_2.xml|+| -------- | ------- | -------|+| ov_version_1 | 100 % (ref)|50% |+| ov_version_2 | 98 % |51% |++and ov - caused++|'Bad' ov-version| model_1.xml| model_2.xml|+| -------- | ------- | -------|+| ov_version_1 | 100 % (ref)|98% |+| ov_version_2 | 48% % |51% |++In the next steps we will use progressively more advanced methods to solve given problem.++## Version #1. Reusing of existing classes++### Traversal+We need full bypass of commit set (pair of commits in the given case), independently on the result of a specific commit.++It corresponds to the existing `brute_force` traversal.++### Mode++On every commit we run several commands.++For the first version, we also reuse the existing `Nop` (No Operation) mode with simple list of bash commands.++### Configuration+The simplest configuration with default settings (openvino/, build/ and bin/intel64/Release/ paths correspondingly).+```+We use explicitList instead of commit interval.+{+ "appCmd" : [+ "./benchmark_app -m model_1_path.xml",+ "./benchmark_app -m model_2_path.xml"+ ],+ "runConfig" : {+ "commitList" : {+ "explicitList" : [ "<start_commit>", "<end_commit>" ]+ },+ "mode" : "nop",+ "traversal" : "bruteForce"+}+```+Or specified with custom paths:+```+{+ "appCmd" : [+ "echo first model",+ "./benchmark_app -m model_1_path.xml",+ "echo second model",+ "./benchmark_app -m model_2_path.xml"+ ],+ "appPath": "<path_to_benchmark_app>",+ "gitPath" : "<path_to_git_repository>",+ "buildPath" : "<path_to_build_dir>",+ "runConfig" : {+ "commitList" : {+ "explicitList" : [ "<start_commit>", "<end_commit>" ]+ },+ "mode" : "nop",+ "traversal" : "bruteForce"+}+```+### Example of launch and output+```+python3 commit_slider.py -cfg cfg.json++current commit: <start_commit_hash>+first model+<...> Throughput: 500 FPS+second model+<...> Throughput: 500 FPS++current commit: <end_commit_hash>+first model+<...> Throughput: 1000 FPS+second model+<...> Throughput: 1000 FPS++```+It faces given problem, but looks clumsy and verbose. We also need to interpret results ourselves.++## Version #2: Specific Mode++If there is no Mode [Details about Mode](README.md# implementing-custom-traversal-rule) which resolves commit with our task or we need more readable output and opportunity to handle every commit directly, we can implement custom Mode. We can also pass specific parameters directly to Mode.+### Mode+```+# Mode supposes to be as much generic as possible+# and corresponds all similar problems,+# and not connected with the separate user case,+# but as the example we provide simplified version.+class CrossCheckMode(Mode):+ def __init__(self, cfg):+ super().__init__(cfg)++def checkCfg(self, cfg):+ # preparation pattern for parsing and parameters+ self.firstAppCmd = cfg["runConfig"]["firstAppCmd"]+ self.secondAppCmd = cfg["runConfig"]["secondAppCmd"]+ self.outPattern = r'{spec}:\s*([0-9]*[.][0-9]*)\s*{measure}'.format(spec='Throughput', measure='FPS')+ super().checkCfg(cfg)++def getPseudoMetric(self, commit, cfg):+ # main Mode method initially resolving two compared+ # commits (for performance goals it is numeric metric, as+ # soon as in some Modes 'metric' has non-numeric value,+ # e.g. filename we got pseudometric), for noncomparative+ # Modes it doesn't return any value, just run procedures+ # for handling single commit.+ commit = commit.replace('"', "")+ commitLogger = getCommitLogger(cfg, commit)+ self.commonLogger.info("New commit: {commit}".format(commit=commit))++ # building and compilation of given version+ handleCommit(commit, cfg)+ fullOutput = ""++ # passing each of the commandlines for execution+ simpleSubstitute(cfg, "actualAppCmd", "$.runConfig.firstAppCmd", "$.appCmd")++ # run first app+ checkOut = fetchAppOutput(cfg, commit)+ commitLogger.info(checkOut)+ foundThroughput = re.search(+ self.outPattern, checkOut, flags=re.MULTILINE+ ).group(1)++ # parsing of output and holding it with full commandline+ # and specific model for the final result+ self.firstThroughput = foundThroughput+ self.firstModel = cfg['appCmd']+ fullOutput = checkOut+ simpleSubstitute(cfg, "actualAppCmd", "$.runConfig.secondAppCmd", "$.appCmd")++ # run second app+ checkOut = fetchAppOutput(cfg, commit)+ commitLogger.info(checkOut)+ foundThroughput = re.search(+ self.outPattern, checkOut, flags=re.MULTILINE+ ).group(1)+ self.secondThroughput = foundThroughput+ self.secondModel = cfg['appCmd']++ # add commit data to commit path+ pc = Mode.CommitPath.PathCommit(+ commit,+ Mode.CommitPath.CommitState.DEFAULT+ )+ self.setOutputInfo(pc)+ self.commitPath.accept(self.traversal, pc)++def printResult(self):+ # formatting of full output+ for pathcommit in self.commitPath.getList():+ commitInfo = self.getCommitInfo(pathcommit)+ print(commitInfo)+ self.outLogger.info(commitInfo)++def setOutputInfo(self, pathCommit):+ # populating of commit path+ pathCommit.firstThroughput = self.firstThroughput+ pathCommit.firstModel = self.firstModel+ pathCommit.secondThroughput = self.secondThroughput+ pathCommit.secondModel = self.secondModel++def getCommitInfo(self, commit):+ return "{hash}, throughput_1 = {t1}, throughput_2 = {t2}".format(+ hash=commit.cHash,+ t1=commit.firstThroughput,+ t2=commit.secondThroughput)+```+### Configuration++Supposedly we pass both command lines launching models in two parameters `cfg["runConfig"]["firstAppCmd"]` and `cfg["runConfig"]["secondAppCmd"]`, i.e.++```+cfg = {+ "appCmd" : "{actualAppCmd}",+ "appPath": "<path_to_benchmark_app>",+ "gitPath" : "<path_to_git_repository>",+ "buildPath" : "<path_to_build_dir>",+ "runConfig" : {+ "commitList" : {+ "explicitList" : [ "{start}", "{end}" ]+ },+ "mode" : "crossCheck",+ "firstAppCmd" : "./benchmark_app -m model_1.xml --other_params",+ "secondAppCmd" : "./benchmark_app -m model_2.xml --other_params",+ "traversal" : "bruteForce"+ }+}+```+### Output+```+python3 commit_slider.py -cfg cfg.json++<hash_1>, throughput_1 = 500.0, throughput_2 = 500.0+<hash_2>, throughput_1 = 1000.0, throughput_2 = 1000.0++```+We've got rid of full output and learned to provide only necessary information, but we still limited by verbose configuration-style API and still provide raw output information.++## Version #3: Specific Template+### API design+We want to provide for user 2 ways to set up command lines for comparation. ```'appCmd' : ['./benchmark_app --parameters_1', './benchmark_app --parameters_2']``` for detailed parameters and simplified ```'par_1' : 'parameter_1', 'par_2' : 'parameter_2'``` supposing that substitute the placeholder ```'appCmd' : 'prefix {actualPar} postfix'```. The example of this approach may be ```'par_1' : 'model_1.xml', 'par_2' : 'model_2.xml' : 'parameter_2', 'appCmd' : './benchmark_app -m {actualPar} -i input.png'```++### Custom template+```+from utils.templates.common import CommonTemplate++class BenchmarkCrossCheckTemplate(CommonTemplate):++def printResult(commitPath, outLogger, getCommitInfo):+ # formatting of output anf post analisys+ print("\n" + "*" * 17 "<Commit slider output>" + "*" * 17 "\nTable of throughputs:" + '\n\t\thr_1\thr_2')+ for pathcommit in commitPath.getList():+ commitInfo = getCommitInfo(pathcommit)+ cHash = pathcommit.cHash+ cHash = cHash[:7]+ commMsg = "{}\t\t{}\t{}".format( cHash,+ pathcommit.firstThroughput,+ pathcommit.secondThroughput)+ print(commMsg)+ outLogger.info(commitInfo)+ cPath = commitPath.getList()+ thr00 = float(cPath[0].firstThroughput)+ thr01 = float(cPath[0].secondThroughput)+ thr10 = float(cPath[1].firstThroughput)++ print("{}\nSupposed rootcause is: {}".format(+ "*" * 58,+ 'Model' if abs(thr00 - thr01) > abs(thr00 - thr10) else 'OV'+ ))+ print("*" * 58" + "\n")+ print("* m1 = {}".format(pathcommit.firstModel))+ print("** m2 = {}".format(pathcommit.secondModel))++def generateFullConfig(cfg, customCfg):+ tmpJSON = cfg+ # handling input commits+ if 'c' in customCfg:+ curCfg = tmpJSON['runConfig']+ interval = customCfg['c'].split("..")+ start, end = interval[0], interval[1]+ curCfg['commitList'] = {'explicitList': [ start, end ] }+ tmpJSON['runConfig'] = curCfg+ # passing base parameters+ CommonTemplate.passParameters([+ 'gitPath', 'buildPath', 'appPath'+ ], customCfg, tmpJSON)+ # resolving of API types+ if isinstance(customCfg['appCmd'], list):+ curCfg = tmpJSON['runConfig']+ curCfg['par_1'] = customCfg['appCmd'][0]+ curCfg['par_2'] = customCfg['appCmd'][1]+ tmpJSON['runConfig'] = curCfg+ else:+ curCfg = tmpJSON['runConfig']+ curCfg['par_1'] = customCfg['appCmd'].format(model=customCfg['modelList'][0])+ curCfg['par_2'] = customCfg['appCmd'].format(model=customCfg['modelList'][1])+ tmpJSON['runConfig'] = curCfg+ tmpJSON['appCmd'] = "{actualPar}"+```+---+### Configuration and CLI++We designed two interfaces, depending on usercase++API #1 (full command lines, so we can define parameters separately)+```+"template" : {+ "name" : "bm_cc",+ "gitPath":"{gitPath}",+ "buildPath":"{buildPath}",+ "appPath":"{buildPath}",+ "c": "{start}..{end}",+ "appCmd" : ["{appCmd} -m first_model.xml", "{appCmd} -m second_model.xml"]+}+```+API #2 (for unified parameters, only model changes)+```+# Here we use default paths.+"template" : {+ "name" : "bm_cc",+ "c": "{start}..{end}",+ "appCmd" : "./benchmark_app {actualPar} -hint throughput -i input.png",+ "par_1" : "first_model.xml",+ "par_2" : "second_model.xml",+}+```+CLI+```+python3 commit_slider -t bm_cc -c <start>..<end> -appCmd './benchmark_app {actualPar} -hint throughput -i input.png' -par_1 first_model.xml -par_2 second_model.xml+```+### Output+```+python3 commit_slider.py -cfg cfg.json++*****************<Commit slider output>*******************++Table of throughputs:++ m1 m2++<start_hash> 1000.0 500.0++<end_hash> 1000.0 500.0++**********************************************************++Supposed rootcause is: Model++**********************************************************++++* m1 = ./crossCheckSeparateTemplateBadModel -m good_model.xml++** m2 = ./crossCheckSeparateTemplateBadModel -m bad_model.xml++```++## What we can do the next ?++- Separate Traversal with performance cross-checking.++- Additional step with binary search in the case of ov-caused degradation to find problematic commit.diff --git a/tools/commit_slider/tests/commit_slider_test.py b/tools/commit_slider/tests/commit_slider_test.pyindex ffb21544c3f..09494b5273b 100644--- a/tools/commit_slider/tests/commit_slider_test.py+++ b/tools/commit_slider/tests/commit_slider_test.py@@ -6,8 +6,9 @@ from unittest import TestCasefrom tests import skip_commit_slider_devtestsys.path.append('./')-from test_util import getExpectedCommit,\- getBordersByTestData, getActualCommit, getCSOutput+from test_util import getExpectedCommit, \+ getBordersByTestData, getActualCommit, getCSOutput, \+ createRepoAndUpdateData, runCSAndCheckPatternfrom utils.break_validator import validateBMOutput, BmValidationErrorfrom test_data import FirstBadVersionData, FirstValidVersionData,\BmStableData, BmValidatorSteppedBreakData, BmValidatorSteppedBreakData2,\@@ -15,7 +16,10 @@ from test_data import FirstBadVersionData, FirstValidVersionData,\BenchmarkAppUnstableDevData, BenchmarkAppWrongPathData, BenchmarkAppPathFoundData,\BenchmarkFirstFixedAppData, AcModeData, BenchmarkMetricData, CustomizedLogData, \MultiConfigData, ConfigMultiplicatorData, ConfigMultiplicatorWithKeyData, \- AcModeDataBitwise, CompareBlobsData, CompareBlobsMulOutputData, CompareBlobsAutomatchData+ AcModeDataBitwise, CompareBlobsData, CompareBlobsMulOutputData, CompareBlobsAutomatchData, \+ BrokenCompilationData, TemplateData, CrossCheckBadAppl, CrossCheckBadModel, CrossCheckPerformance, \+ CrossCheckPerformanceSeparateMode, CrossCheckPerformanceSeparateTemplate, CrossCheckPerformanceSeparateTemplateBadModel, \+ TableTemplateclass CommitSliderTest(TestCase):@skip_commit_slider_devtest@@ -26,6 +30,20 @@ class CommitSliderTest(TestCase):self.assertEqual(breakCommit, actualCommit)+ @skip_commit_slider_devtest+ def testBrokenCompilation(self):+ breakCommit, updatedData = getExpectedCommit(+ BrokenCompilationData())+ actualCommit, _ = getActualCommit(updatedData)+ self.assertEqual(breakCommit, actualCommit)++ @skip_commit_slider_devtest+ def testBrokenCompTmplate(self):+ breakCommit, updatedData = getExpectedCommit(+ TemplateData())+ actualCommit, _ = getActualCommit(updatedData)+ self.assertEqual(breakCommit, actualCommit)+@skip_commit_slider_devtestdef testFirstBadVersion(self):breakCommit, updatedData = getExpectedCommit(@@ -33,6 +51,62 @@ class CommitSliderTest(TestCase):actualCommit, _ = getActualCommit(updatedData)self.assertEqual(breakCommit, actualCommit)+ @skip_commit_slider_devtest+ def testCrossCheckBadAppl(self):+ updatedData = createRepoAndUpdateData(+ CrossCheckBadAppl())+ res = runCSAndCheckPattern(updatedData, ["failed", "failed", "success", "success"])++ self.assertEqual(True, res)++ @skip_commit_slider_devtest+ def testCrossCheckBadModel(self):+ updatedData = createRepoAndUpdateData(+ CrossCheckBadModel())+ res = runCSAndCheckPattern(updatedData, ["success", "failed", "success", "failed"])++ self.assertEqual(True, res)++ @skip_commit_slider_devtest+ def testCrossCheckPerformance(self):+ updatedData = createRepoAndUpdateData(+ CrossCheckPerformance())+ res = runCSAndCheckPattern(updatedData, ["500.0 FPS", "500.0 FPS", "1000.0 FPS", "1000.0 FPS"])++ self.assertEqual(True, res)++ @skip_commit_slider_devtest+ def testCrossCheckPerformanceSeparateMode(self):+ updatedData = createRepoAndUpdateData(+ CrossCheckPerformanceSeparateMode())+ res = runCSAndCheckPattern(updatedData, ["500.0", "500.0", "1000.0", "1000.0"])++ self.assertEqual(True, res)++ @skip_commit_slider_devtest+ def testCrossCheckPerformanceSeparateTemplate(self):+ updatedData = createRepoAndUpdateData(+ CrossCheckPerformanceSeparateTemplate())+ res = runCSAndCheckPattern(updatedData, ["rootcause", "OV"])++ self.assertTrue(res)++ @skip_commit_slider_devtest+ def testTableTemplate(self):+ updatedData = createRepoAndUpdateData(+ TableTemplate())+ res = runCSAndCheckPattern(updatedData, ["rootcause", "OV"])++ self.assertTrue(res)++ @skip_commit_slider_devtest+ def testCrossCheckPerformanceSeparateTemplateBadModel(self):+ updatedData = createRepoAndUpdateData(+ CrossCheckPerformanceSeparateTemplateBadModel())+ res = runCSAndCheckPattern(updatedData, ["rootcause", "Model"])++ self.assertTrue(res)+@skip_commit_slider_devtestdef testCustomizedLog(self):breakCommit, updatedData = getExpectedCommit(diff --git a/tools/commit_slider/tests/test_data.py b/tools/commit_slider/tests/test_data.pyindex 7b59d897dff..e571bfaada0 100644--- a/tools/commit_slider/tests/test_data.py+++ b/tools/commit_slider/tests/test_data.py@@ -75,7 +75,16 @@ class TestData():AcModeDataBitwise = 19,CompareBlobsData = 20,MulOutput = 21,- CmpBlobsAutomatch = 22+ CmpBlobsAutomatch = 22,+ BrokenCompilation = 23,+ TemplateData = 24,+ CrossCheckBadAppl = 25,+ CrossCheckBadModel = 26,+ CrossCheckPerformance = 27,+ CrossCheckPerformanceSeparateMode = 28,+ CrossCheckPerformanceSeparateTemplate = 29,+ CrossCheckPerformanceSeparateTemplateBadModel = 30,+ TableTemplate = 31def requireTestData(self, reqLambda):# mapping json to test data holder@@ -100,6 +109,105 @@ class FirstBadVersionData(TestData):requireBinarySearchData)++class CrossCheckBadAppl(TestData):+ def getTestCase():+ return TestData.TestCase.CrossCheckBadAppl++ def getTestName(self):+ return "CfgCrossCheckBadApplication"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )+++class CrossCheckBadModel(TestData):+ def getTestCase():+ return TestData.TestCase.CrossCheckBadModel++ def getTestName(self):+ return "CfgCrossCheckBadModel"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )+++class CrossCheckPerformance(TestData):+ def getTestCase():+ return TestData.TestCase.CrossCheckPerformance++ def getTestName(self):+ return "CfgCrossCheckPerformance"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )+++class CrossCheckPerformanceSeparateTemplate(TestData):+ def getTestCase():+ return TestData.TestCase.CrossCheckPerformanceSeparateTemplate++ def getTestName(self):+ return "CfgCrossCheckPerformanceSeparateTemplate"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )+++class TableTemplate(TestData):+ def getTestCase():+ return TestData.TestCase.TableTemplate++ def getTestName(self):+ return "CfgTableTemplate"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )+++class CrossCheckPerformanceSeparateTemplateBadModel(TestData):+ def getTestCase():+ return TestData.TestCase.CrossCheckPerformanceSeparateTemplateBadModel++ def getTestName(self):+ return "CrossCheckPerformanceSeparateTemplateBadModel"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )+++class CrossCheckPerformanceSeparateMode(TestData):+ def getTestCase():+ return TestData.TestCase.CrossCheckPerformanceSeparateMode++ def getTestName(self):+ return "CfgCrossCheckPerformanceSeparateMode"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )++class CustomizedLogData(TestData):def getTestCase():return TestData.TestCase.CustomizedLog@@ -350,6 +458,45 @@ class FirstValidVersionData(TestData):requireBinarySearchData)+class BrokenCompilationData(TestData):+ def getTestCase():+ return TestData.TestCase.BrokenCompilation++ def getTestName(self):+ return "BrokenCompilation"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )++class TemplateData(TestData):+ def getTestCase():+ return TestData.TestCase.TemplateData++ def getTestName(self):+ return "TemplateBrokenCompilation"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )++class TemplateBrokenCompilationData(TestData):+ def getTestCase():+ return TestData.TestCase.TemplateBrokenCompilation++ def getTestName(self):+ return "TemplateBrokenCompilation"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )+class BmStableData(TestData):def getTestCase():return TestData.TestCase.BmValidatorStablediff --git a/tools/commit_slider/tests/test_util.py b/tools/commit_slider/tests/test_util.pyindex 249d361018b..45c22030873 100644--- a/tools/commit_slider/tests/test_util.py+++ b/tools/commit_slider/tests/test_util.py@@ -116,7 +116,7 @@ def commitPatchList(versionList, innerPath, fileName):textFile.write(version['content'])runCmd("git add {}".format(fileName), innerPath)- runCmd("git commit -m \"{}\"".format(version['comment']), innerPath)+ runCmd("git commit -m \"{}\"".format(version['comment'].replace(" ", "_")), innerPath)hash = runCmd("git rev-parse HEAD", innerPath)[0]markedVersion = {@@ -148,6 +148,23 @@ def getExpectedCommit(td: TestData):return breakCommit, td+def createRepoAndUpdateData(td: TestData):+ markedVersionList = createRepo(td)++ td.fillActualData(markedVersionList)+ td.actualDataReceived = True++ return td++def runCSAndCheckPattern(td: TestData, pattern: list):+ sliderOutput = runCS(td)+ pattern = '((.|\n)*)'.join(pattern)+ matcher = re.search(+ pattern, sliderOutput, flags=re.MULTILINE+ )+ print(sliderOutput)+ return matcher is not None+def getActualCommit(td: TestData):sliderOutput = runCS(td)rejectReason, foundCommit = parseSliderOutput(sliderOutput)diff --git a/tools/commit_slider/tests/tests_res/broken_comp_main.cpp b/tools/commit_slider/tests/tests_res/broken_comp_main.cppnew file mode 100644index 00000000000..4cc1b085605--- /dev/null+++ b/tools/commit_slider/tests/tests_res/broken_comp_main.cpp@@ -0,0 +1,26 @@+#include <iostream>++int main () {+ const char *patchGenerator = R"V0G0N(+[+ {+ "str": "std::cout << \"prefix\\n[100%] Built target\\n\";",+ "comment": "error_1"+ },+ {+ "str": "std::cout << \"prefix\\n[100%] Built target\\n\";",+ "comment": "error_2"+ },+ {+ "str": "wrong code #1",+ "comment": "wrong code 1",+ "state": "BREAK"+ },+ {+ "str": "wrong code #2",+ "comment": "wrong code 2"+ }+]+)V0G0N";+ return 0;+}\ No newline at end of filediff --git a/tools/commit_slider/tests/tests_res/cross_check.cpp b/tools/commit_slider/tests/tests_res/cross_check.cppnew file mode 100644index 00000000000..8db5ef88fa0--- /dev/null+++ b/tools/commit_slider/tests/tests_res/cross_check.cpp@@ -0,0 +1,30 @@+#include <iostream>++int main (int argc, char *argv[]) {+ if (argv[2][0] == 'b') {+ std::cout << "prefix\nfailed\n";+ } else {+ std::cout << "prefix\nsuccess\n";+ };+ const char *patchGenerator = R"V0G0N(+[+ {+ "str": "// depends on model only",+ "comment": "commit #1"+ },+ {+ "str": "// depends on model only",+ "comment": "commit #2"+ },+ {+ "str": "// depends on model only",+ "comment": "commit #3"+ },+ {+ "str": "// depends on model only",+ "comment": "commit #4"+ }+]+)V0G0N";+ return 0;+}\ No newline at end of filediff --git a/tools/commit_slider/tests/tests_res/cross_check_perf.cpp b/tools/commit_slider/tests/tests_res/cross_check_perf.cppnew file mode 100644index 00000000000..d3479fe494a--- /dev/null+++ b/tools/commit_slider/tests/tests_res/cross_check_perf.cpp@@ -0,0 +1,30 @@+#include <iostream>++int main (int argc, char *argv[]) {+ if (argv[2][0] == 'b') {+ std::cout << "Throughput: 500.0 FPS\n";+ } else {+ std::cout << "Throughput: 1000.0 FPS\n";+ };+ const char *patchGenerator = R"V0G0N(+[+ {+ "str": "// depends on model only",+ "comment": "commit #1"+ },+ {+ "str": "// depends on model only",+ "comment": "commit #2"+ },+ {+ "str": "// depends on model only",+ "comment": "commit #3"+ },+ {+ "str": "// depends on model only",+ "comment": "commit #4"+ }+]+)V0G0N";+ return 0;+}\ No newline at end of filediff --git a/tools/commit_slider/tests/tests_res/fbv_model_comp.cpp b/tools/commit_slider/tests/tests_res/fbv_model_comp.cppnew file mode 100644index 00000000000..3258c5ac63a--- /dev/null+++ b/tools/commit_slider/tests/tests_res/fbv_model_comp.cpp@@ -0,0 +1,42 @@+#include <iostream>++int main () {+ const char *patchGenerator = R"V0G0N(+[+ {+ "str": "std::cout << \"prefix\\nCompile model took 1000.0 ms\\n\";",+ "comment": "success_1"+ },+ {+ "str": "std::cout << \"prefix\\nCompile model took 1000.0 ms\\n\";",+ "comment": "success_2"+ },+ {+ "str": "std::cout << \"prefix\\nCompile model took 500.0 ms\\n\";",+ "comment": "error_1",+ "state": "BREAK"+ },+ {+ "str": "std::cout << \"prefix\\nCompile model took 500.0 ms\\n\";",+ "comment": "error_2"+ },+ {+ "str": "std::cout << \"prefix\\nCompile model took 500.0 ms\\n\";",+ "comment": "error_1"+ },+ {+ "str": "std::cout << \"prefix\\nCompile model took 500.0 ms\\n\";",+ "comment": "error_2"+ },+ {+ "str": "std::cout << \"prefix\\nCompile model took 500.0 ms\\n\";",+ "comment": "error_1"+ },+ {+ "str": "std::cout << \"prefix\\nCompile model took 500.0 ms\\n\";",+ "comment": "error_2"+ }+]+)V0G0N";+ return 0;+}\ No newline at end of filediff --git a/tools/commit_slider/tests/tests_res/tests_res.json b/tools/commit_slider/tests/tests_res/tests_res.jsonindex 3077fe239d5..a9b7d4eb9ad 100644--- a/tools/commit_slider/tests/tests_res/tests_res.json+++ b/tools/commit_slider/tests/tests_res/tests_res.json@@ -75,7 +75,8 @@},"mode" : "nop","traversal" : "bruteForce",- "msg" : "cfg #0"+ "msg" : "cfg #0",+ "onlyMsg" : true}},{@@ -92,7 +93,8 @@},"mode" : "nop","traversal" : "bruteForce",- "msg" : "cfg #1"+ "msg" : "cfg #1",+ "onlyMsg" : true}},{@@ -109,7 +111,8 @@},"mode" : "nop","traversal" : "bruteForce",- "msg" : "cfg #2"+ "msg" : "cfg #2",+ "onlyMsg" : true}}]@@ -197,7 +200,8 @@"cfg #1","cfg #2"]- }+ },+ "onlyMsg" : true}}},@@ -222,7 +226,8 @@"msg" : {"multiplication_type": "dot_product","multiplication_key": ["cfg #1", "cfg #2", "cfg #3"]- }+ },+ "onlyMsg" : true}}},@@ -503,6 +508,165 @@}}},+ "BrokenCompilation": {+ "repoName": "brokenCompilation",+ "patchedFile": "tests_res/broken_comp_main.cpp",+ "testCfg": {+ "commandList" : [+ {"cmd" : "git checkout -- .", "catchMsg" : "(.)*error: (.)*", "path" : "{gitPath}"},+ {"cmd" : "git clean -fxd", "path" : "{gitPath}", "tag" : "clean"},+ {"cmd" : "mkdir -p build", "path" : "{gitPath}"},+ {"cmd" : "git checkout {commit}", "catchMsg" : "(.)*error: (.)*", "path" : "{gitPath}"},+ {"cmd" : "git submodule init", "path" : "{gitPath}"},+ {"cmd" : "git submodule update --recursive", "path" : "{buildPath}"},+ {"cmd" : "{makeCmd}", "catchMsg" : "CMake Error", "path" : "{buildPath}"}+ ],+ "appCmd" : "make --jobs=4",+ "appPath": "{buildPath}",+ "gitPath" : "{gitPath}",+ "buildPath" : "{buildPath}",+ "verboseOutput": true,+ "runConfig" : {+ "commitList" : {+ "getCommitListCmd" : "git log {start}..{end} --boundary --pretty=\"%h\""+ },+ "mode" : "checkOutput",+ "traversal" : "firstFixedVersion",+ "stopPattern" : "(.)*\\[100%]\\ Built\\ target(.)*"+ }+ }+ },+ "TemplateBrokenCompilation": {+ "repoName": "brokenCompilation",+ "patchedFile": "tests_res/broken_comp_main.cpp",+ "testCfg": {+ "template": {+ "name": "broken_comp",+ "gitPath":"{gitPath}",+ "buildPath":"{buildPath}",+ "c": "{start}..{end}"+ }+ }+ },+ "CfgCrossCheckBadApplication": {+ "repoName": "cfgCrossCheckBadApplication",+ "patchedFile": "tests_res/fbv_main.cpp",+ "testCfg": {+ "appCmd" : ["echo first model", "{appCmd}", "echo second model", "{appCmd}"],+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "explicitList" : [ "{start}", "{end}" ]+ },+ "mode" : "nop",+ "traversal" : "bruteForce"+ }+ }+ },+ "CfgCrossCheckBadModel": {+ "repoName": "cfgCrossCheckBadApplication",+ "patchedFile": "tests_res/cross_check.cpp",+ "testCfg": {+ "appCmd" : ["echo first model", "{appCmd} -m good_model", "echo second model", "{appCmd} -m bad_model"],+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "explicitList" : [ "{start}", "{end}" ]+ },+ "mode" : "nop",+ "traversal" : "bruteForce"+ }+ }+ },+ "CfgCrossCheckPerformance": {+ "repoName": "cfgCrossCheckBadApplication",+ "patchedFile": "tests_res/fbv_bm_stable_main.cpp",+ "testCfg": {+ "appCmd" : ["echo first model", "{appCmd}", "echo second model", "{appCmd}"],+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "explicitList" : [ "{start}", "{end}" ]+ },+ "mode" : "nop",+ "traversal" : "bruteForce"+ }+ }+ },+ "CfgCrossCheckPerformanceSeparateMode": {+ "repoName": "cfgCrossCheckBadApplication",+ "patchedFile": "tests_res/fbv_bm_stable_main.cpp",+ "testCfg": {+ "appCmd" : "{actualPar}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "explicitList" : [ "{start}", "{end}" ]+ },+ "mode" : "crossCheck",+ "par_1" : "{appCmd}",+ "par_2" : "{appCmd}",+ "traversal" : "bruteForce"+ }+ }+ },+ "CfgCrossCheckPerformanceSeparateTemplate": {+ "repoName": "crossCheckSeparateTemplate",+ "patchedFile": "tests_res/fbv_bm_stable_main.cpp",+ "testCfg": {+ "template" : {+ "name" : "bm_cc",+ "gitPath":"{gitPath}",+ "buildPath":"{buildPath}",+ "appPath":"{buildPath}",+ "c": "{start}..{end}",+ "verboseOutput": false,+ "appCmd" : ["{appCmd} -m first_model.xml", "{appCmd} -m second_model.xml"]+ }+ }+ },+ "CfgTableTemplate": {+ "repoName": "tableTemplate",+ "patchedFile": "tests_res/fbv_model_comp.cpp",+ "testCfg": {+ "template" : {+ "name" : "model_comp_table",+ "gitPath":"{gitPath}",+ "buildPath":"{buildPath}",+ "appPath":"{buildPath}",+ "c": "{start}..{end}",+ "verboseOutput": false,+ "appCmd" : ["{appCmd} -m first_model.xml", "{appCmd} -m second_model.xml"]+ }+ }+ },+ "CrossCheckPerformanceSeparateTemplateBadModel": {+ "repoName": "crossCheckSeparateTemplateBadModel",+ "patchedFile": "tests_res/cross_check_perf.cpp",+ "testCfg": {+ "template" : {+ "name" : "bm_cc",+ "gitPath":"{gitPath}",+ "buildPath":"{buildPath}",+ "appPath":"{buildPath}",+ "c": "{start}..{end}",+ "verboseOutput": false,+ "appCmd" : ["{appCmd} -m good_model.xml", "{appCmd} -m bad_model.xml"]+ }+ }+ },"BmValidatorStable": {"bmOutputMap": [{"id": "0", "hash": "57571d36e6c", "throughput": "768.66"},diff --git a/tools/commit_slider/utils/cfg.json b/tools/commit_slider/utils/cfg.jsonindex 13f30fff67c..a6b625f01e3 100644--- a/tools/commit_slider/utils/cfg.json+++ b/tools/commit_slider/utils/cfg.json@@ -5,7 +5,9 @@"compareBlobs" : "CompareBlobsMode","ac" : "AccuracyCheckerMode","llmBench" : "LLMBenchMode",- "nop" : "NopMode"+ "nop" : "NopMode",+ "crossCheck" : "CrossCheckMode",+ "mComp" : "ModelCompilationMode"},"traversalMap" : {"firstFailedVersion" : "FirstFailedVersion",@@ -83,6 +85,7 @@"clearCache" : false,"checkIfBordersDiffer" : true,"printCSV" : true,+ "template" : "common_template","usePrevRunCache" : false,"verboseOutput": false,"venvCfg": {diff --git a/tools/commit_slider/utils/cfg_manager.py b/tools/commit_slider/utils/cfg_manager.pyindex 074c52102af..45c12a13848 100644--- a/tools/commit_slider/utils/cfg_manager.py+++ b/tools/commit_slider/utils/cfg_manager.py@@ -23,12 +23,16 @@ class CfgManager():return inputdef applyTemplate(self):+ from utils.templates.common import CommonTemplateif not "template" in self.cfg:return self.cfgtmplName = self.cfg["template"]["name"]fullCfg = {}- # todo: generalize tmplcfg generator- if tmplName == "bm_simple":+ fullCfg = CommonTemplate.populateCfg(tmplName, self.cfg["template"])+ if fullCfg != None:+ # todo: incapsulate every template in Template class+ pass+ elif tmplName == "bm_simple":fullCfg = self.generatebmSimpleTemplate()elif tmplName == "e2e":fullCfg = self.generateE2ETemplate()@@ -40,9 +44,11 @@ class CfgManager():raise Exception("Unknown template '{}'".format(tmplName))+ fullCfg['template'] = self.cfg["template"]["name"]return fullCfg- def readJsonTmpl(self, tmplFileName: str):+ @staticmethod+ def readJsonTmpl(tmplFileName: str):smplPath = os.path.dirname(os.path.realpath(__file__))tmplFileName = os.path.join(smplPath, "cfg_samples/", tmplFileNamediff --git a/tools/commit_slider/utils/cfg_samples/benchmark_crosscheck.json b/tools/commit_slider/utils/cfg_samples/benchmark_crosscheck.jsonnew file mode 100644index 00000000000..067f6f5b60d--- /dev/null+++ b/tools/commit_slider/utils/cfg_samples/benchmark_crosscheck.json@@ -0,0 +1,16 @@+{+ "appCmd":"{actualPar}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "buildPath" : "{buildPath}",+ "verboseOutput":false,+ "runConfig" : {+ "commitList" : {+ "explicitList" : [ "{start}", "{end}" ]+ },+ "mode" : "crossCheck",+ "par_1" : "{appCmd}",+ "par_2" : "{appCmd}",+ "traversal" : "bruteForce"+ }+}diff --git a/tools/commit_slider/utils/cfg_samples/broken_compilation.json b/tools/commit_slider/utils/cfg_samples/broken_compilation.jsonnew file mode 100644index 00000000000..182a568cad4--- /dev/null+++ b/tools/commit_slider/utils/cfg_samples/broken_compilation.json@@ -0,0 +1,43 @@+{+ "commandList":[+ {+ "cmd":"git checkout -- .",+ "catchMsg":"(.)*error: (.)*",+ "path":"{gitPath}"+ },+ {+ "cmd":"git clean -fxd",+ "path":"{gitPath}",+ "tag":"clean"+ },+ {+ "cmd":"mkdir -p build",+ "path":"{gitPath}"+ },+ {+ "cmd":"git checkout {commit}",+ "catchMsg":"(.)*error: (.)*",+ "path":"{gitPath}"+ },+ {+ "cmd":"git submodule init",+ "path":"{gitPath}"+ },+ {+ "cmd":"git submodule update --recursive",+ "path":"{buildPath}"+ },+ {+ "cmd":"{makeCmd}",+ "catchMsg":"CMake Error",+ "path":"{buildPath}"+ }+ ],+ "appCmd":"make --jobs=4",+ "verboseOutput":true,+ "runConfig":{+ "mode":"checkOutput",+ "traversal":"firstFixedVersion",+ "stopPattern":"(.)*\\[100%]\\ Built\\ target(.)*"+ }+}\ No newline at end of filediff --git a/tools/commit_slider/utils/cfg_samples/model_compilation_time_table.json b/tools/commit_slider/utils/cfg_samples/model_compilation_time_table.jsonnew file mode 100644index 00000000000..35171334c7c--- /dev/null+++ b/tools/commit_slider/utils/cfg_samples/model_compilation_time_table.json@@ -0,0 +1,16 @@+{+ "appCmd":"{actualPar}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "buildPath" : "{buildPath}",+ "verboseOutput":false,+ "runConfig" : {+ "commitList" : {+ "explicitList" : [ "{start}", "{end}" ]+ },+ "mode" : "mComp",+ "par_1" : "{appCmd}",+ "par_2" : "{appCmd}",+ "traversal" : "bruteForce"+ }+}diff --git a/tools/commit_slider/utils/helpers.py b/tools/commit_slider/utils/helpers.pyindex cb4fb3c3e90..071be90780f 100644--- a/tools/commit_slider/utils/helpers.py+++ b/tools/commit_slider/utils/helpers.py@@ -59,6 +59,13 @@ def getParams():help="run utility with specified name",default="no_utility",)+ parser.add_argument(+ "-t",+ "--template",+ dest="template",+ help="launched with template",+ default="undefined",+ )parser.add_argument("-x",@@ -84,6 +91,20 @@ def getParams():presetCfgData = loadJSONToObject(presetCfgPath)return argHolder, presetCfgData, presetCfgPath+ if argHolder.template != "undefined":+ it = iter(additionalArgs)+ addDict = dict(zip(it, it))+ mergedArgs = {**(args.__dict__), **addDict}+ argHolder = DictHolder(mergedArgs)+ customCfgPath = "custom_cfg_on_run.json"+ jsonObj = {"template" : {"name" : argHolder.template}}+ for k, v in addDict.items():+ jsonObj['template'][k] = v+ curTempl = jsonObj['template']+ curTempl[k.replace('-', '')] = v+ jsonObj['template'] = curTempl+ saveJSON(jsonObj, customCfgPath)+customCfgData = loadJSONToString(customCfgPath)if mulKey in customCfgData:customCfgData = multiplyCfgByKey(json.loads(customCfgData))@@ -108,6 +129,9 @@ def loadJSONToObject(path):file.close()return obj+def saveJSON(obj, path):+ with open(path, 'w', encoding='utf-8') as f:+ json.dump(obj, f, ensure_ascii=False, indent=4)def customizeCfg(customCfg, presetCfg: str):if isinstance(customCfg, list):@@ -362,6 +386,14 @@ def runCommandList(commit, cfgData):def fetchAppOutput(cfg, commit):+ appCmd = cfg["appCmd"]+ if isinstance(appCmd, list):+ aggregatedOutput = ""+ for cmd in appCmd:+ curCfg = deepCopyJSON(cfg)+ curCfg["appCmd"] = cmd+ aggregatedOutput = aggregatedOutput + fetchAppOutput(curCfg, commit)+ return aggregatedOutputcommitLogger = getCommitLogger(cfg, commit)appPath = cfg["appPath"]# format appPath if it was cashed@@ -378,7 +410,6 @@ def fetchAppOutput(cfg, commit):envKey = env["name"]envVal = env["val"]newEnv[envKey] = envVal- appCmd = cfg["appCmd"]commitLogger.info("Run command: {command}".format(command=appCmd))@@ -727,6 +758,12 @@ def checkAndGetSubclass(clName, parentClass):else:return cl[0]+def getClassByMethod(method, methodRes, parentClass):+ cl = [cl for cl in parentClass.__subclasses__() if getattr(cl, method)() == methodRes]+ if not (cl.__len__() == 1):+ raise CfgError("Class returning {} doesn't exist".format(methodRes))+ else:+ return cl[0]class DictHolder:def __init__(self, dict: dict = None):@@ -894,6 +931,20 @@ def applySubstitutionRules(cfg: map, rules: list, commit: str=None):)cfg = deepMapUpdate(cfg, pathToDst, dstPos)+def simpleSubstitute(cfg: map, placeholder: str,+ fromPath: str, toPath: str):+ rules = [+ {+ "name": "simple rule",+ "enabled": True,+ "type": "static",+ "placeholder": placeholder,+ "from": fromPath,+ "to": toPath+ }+ ]+ applySubstitutionRules(cfg, rules)+def getMapValueByShortHash(map: dict, commit: str):for k in map:if getMeaningfullCommitTail(k) ==\diff --git a/tools/commit_slider/utils/modes.py b/tools/commit_slider/utils/modes.pyindex 78201869f6d..334fc8855e9 100644--- a/tools/commit_slider/utils/modes.py+++ b/tools/commit_slider/utils/modes.py@@ -4,7 +4,7 @@import osfrom utils.helpers import CfgManager, fetchAppOutput, getActualPathfrom utils.helpers import getMeaningfullCommitTail, extractModelPath-from utils.helpers import handleCommit, getBlobDiff+from utils.helpers import handleCommit, getBlobDiff, applySubstitutionRules, simpleSubstitutefrom utils.helpers import getCommitLogger, CashError, CfgError,\CmdError, PreliminaryAnalysisErrorfrom utils.break_validator import checkStability@@ -17,6 +17,7 @@ class NopMode(Mode):# helpful with mode-ignorant traversal (brute force)def __init__(self, cfg):self.msg = "default"+ self.onlyMsg = 'onlyMsg' in cfg['runConfig'] and cfg['runConfig']['onlyMsg']super().__init__(cfg)def checkCfg(self, cfg):@@ -33,13 +34,168 @@ class NopMode(Mode):handleCommit(commit, cfg)checkOut = fetchAppOutput(cfg, commit)commitLogger.info(checkOut)+ if not self.onlyMsg:+ print("current commit: {}".format(commit))+ print(checkOut)returndef printResult(self):+ # if CS launched with template we use custom representation+ # if not, as default we print msg attributeprint(self.msg)self.outLogger.info(self.msg)+class CrossCheckMode(Mode):+ def __init__(self, cfg):+ super().__init__(cfg)++ def checkCfg(self, cfg):+ self.par_1 = cfg["runConfig"]["par_1"]+ self.par_2 = cfg["runConfig"]["par_2"]+ # todo: extend for another metrics+ self.outPattern = r'{spec}:\s*([0-9]*[.][0-9]*)\s*{measure}'.format(+ spec='Throughput', measure='FPS')+ super().checkCfg(cfg)++ def getPseudoMetric(self, commit, cfg):+ commit = commit.replace('"', "")+ commitLogger = getCommitLogger(cfg, commit)+ self.commonLogger.info("New commit: {commit}".format(+ commit=commit)+ )+ handleCommit(commit, cfg)+ fullOutput = ""+ simpleSubstitute(cfg, "actualPar", "$.runConfig.par_1", "$.appCmd")++ # run first app+ checkOut = fetchAppOutput(cfg, commit)+ foundThroughput = re.search(+ self.outPattern, checkOut, flags=re.MULTILINE+ ).group(1)+ self.firstThroughput = foundThroughput+ self.firstModel = cfg['appCmd']+ fullOutput = checkOut+ simpleSubstitute(cfg, "actualPar", "$.runConfig.par_2", "$.appCmd")++ # run second app+ checkOut = fetchAppOutput(cfg, commit)+ foundThroughput = re.search(+ self.outPattern, checkOut, flags=re.MULTILINE+ ).group(1)+ self.secondThroughput = foundThroughput+ self.secondModel = cfg['appCmd']+ pc = Mode.CommitPath.PathCommit(+ commit,+ Mode.CommitPath.CommitState.DEFAULT+ )+ self.setOutputInfo(pc)+ self.commitPath.accept(self.traversal, pc)++ fullOutput = fullOutput + checkOut++ commitLogger.info(fullOutput)++ def printResult(self):+ if self.cfg['template'] == 'common_template':+ for pathcommit in self.commitPath.getList():+ commitInfo = self.getCommitInfo(pathcommit)+ print(commitInfo)+ self.outLogger.info(commitInfo)+ else:+ from utils.templates.common import CommonTemplate+ tmpl = CommonTemplate.getTemplate(self.cfg['template'])+ tmpl.printResult(self.commitPath, self.outLogger, self.getCommitInfo)+++ def setOutputInfo(self, pathCommit):+ pathCommit.firstThroughput = self.firstThroughput+ pathCommit.firstModel = self.firstModel+ pathCommit.secondThroughput = self.secondThroughput+ pathCommit.secondModel = self.secondModel++ def getCommitInfo(self, commit):+ return "{hash}, throughput_1 = {t1}, throughput_2 = {t2}".format(+ hash=commit.cHash,+ t1=commit.firstThroughput,+ t2=commit.secondThroughput)+++class ModelCompilationMode(Mode):+ def __init__(self, cfg):+ super().__init__(cfg)++ def checkCfg(self, cfg):+ self.par_1 = cfg["runConfig"]["par_1"]+ self.par_2 = cfg["runConfig"]["par_2"]+ # todo: extend for another metrics+ self.outPattern = r'{spec}\s*([0-9]*[.][0-9]*)\s*{measure}'.format(+ spec='Compile model took', measure='ms')+ super().checkCfg(cfg)++ def getPseudoMetric(self, commit, cfg):+ commit = commit.replace('"', "")+ commitLogger = getCommitLogger(cfg, commit)+ self.commonLogger.info("New commit: {commit}".format(+ commit=commit)+ )+ handleCommit(commit, cfg)+ fullOutput = ""+ simpleSubstitute(cfg, "actualPar", "$.runConfig.par_1", "$.appCmd")++ # run first app+ checkOut = fetchAppOutput(cfg, commit)+ foundThroughput = re.search(+ self.outPattern, checkOut, flags=re.MULTILINE+ ).group(1)+ self.firstThroughput = foundThroughput+ self.firstModel = cfg['appCmd']+ fullOutput = checkOut+ simpleSubstitute(cfg, "actualPar", "$.runConfig.par_2", "$.appCmd")++ # run second app+ checkOut = fetchAppOutput(cfg, commit)+ foundThroughput = re.search(+ self.outPattern, checkOut, flags=re.MULTILINE+ ).group(1)+ self.secondThroughput = foundThroughput+ self.secondModel = cfg['appCmd']+ pc = Mode.CommitPath.PathCommit(+ commit,+ Mode.CommitPath.CommitState.DEFAULT+ )+ self.setOutputInfo(pc)+ self.commitPath.accept(self.traversal, pc)++ fullOutput = fullOutput + checkOut++ commitLogger.info(fullOutput)++ def printResult(self):+ if self.cfg['template'] == 'common_template':+ for pathcommit in self.commitPath.getList():+ commitInfo = self.getCommitInfo(pathcommit)+ print(commitInfo)+ self.outLogger.info(commitInfo)+ else:+ from utils.templates.common import CommonTemplate+ tmpl = CommonTemplate.getTemplate(self.cfg['template'])+ tmpl.printResult(self.commitPath, self.outLogger, self.getCommitInfo)+++ def setOutputInfo(self, pathCommit):+ pathCommit.firstThroughput = self.firstThroughput+ pathCommit.firstModel = self.firstModel+ pathCommit.secondThroughput = self.secondThroughput+ pathCommit.secondModel = self.secondModel++ def getCommitInfo(self, commit):+ return "{hash}, throughput_1 = {t1}, throughput_2 = {t2}".format(+ hash=commit.cHash,+ t1=commit.firstThroughput,+ t2=commit.secondThroughput)++class CheckOutputMode(Mode):def __init__(self, cfg):super().__init__(cfg)@@ -534,7 +690,6 @@ class CompareBlobsMode(Mode):# option of automatic matching of comparing blobs i.e.# blob_for_node_1_commit_1.ieb <--> blob_for_node_1_commit_2.ieb# blob_for_node_2_commit_1.ieb <--> blob_for_node_2_commit_2.ieb- self.autoMatch = Falsedef prepareRun(self, list, cfg):# we need to exclude initial prerun-cash handling, as it maydiff --git a/tools/commit_slider/utils/templates/benchmark_cross_check.md b/tools/commit_slider/utils/templates/benchmark_cross_check.mdnew file mode 100644index 00000000000..9264cb4ca17--- /dev/null+++ b/tools/commit_slider/utils/templates/benchmark_cross_check.md@@ -0,0 +1,49 @@++# Performance cross - check++`bm_cc` — template for checking if degradation caused ov-version or model.++---+++## How to run++Example 1+```+python3 commit_slider -t bm_cc -c <start>..<end> -appCmd './benchmark_app {actualPar} -hint throughput -i input.png' -par_1 first_model.xml -par_2 second_model.xml -gitPath <pathToGitRepository> -buildPath <pathToBuildDirectory>+```+Example 2 (with configuration)+```+python3 commit_slider -cfg custom_cfg.json+```+where+```+cfg = { "template" : {+ "name" : "bm_cc",+ "c" : "<start>..<end>",+ "appCmd" : [+ "./benchmark_app -m model_1 -hint throughput -i input_1.png",+ "./benchmark_app -m model_2 -hint throughput -i input_2.png"+ ]+}}+```+### Independent variables:++```+- verbosity: -v {true|false}+```+### Expected output:++```+*****************<Commit slider output>*******************+Table of throughputs:+ m1 m2+<start_hash> <throughput_00> <throughput_01>+<end_hash> <throughput_10> <throughput_11>+**********************************************************+Supposed rootcause is: <Model | OV>+**********************************************************++* m1 = ./benchmark_app -m first_model.xml+** m2 = ./benchmark_app -m second_model.xml+```\ No newline at end of filediff --git a/tools/commit_slider/utils/templates/benchmark_cross_check.py b/tools/commit_slider/utils/templates/benchmark_cross_check.pynew file mode 100644index 00000000000..c132b62bfc0--- /dev/null+++ b/tools/commit_slider/utils/templates/benchmark_cross_check.py@@ -0,0 +1,64 @@+from utils.templates.common import CommonTemplate++class BenchmarkCrossCheckTemplate(CommonTemplate):+ def getName():+ return 'bm_cc'++ def getBilletFileName():+ return 'benchmark_crosscheck.json'++ def printResult(commitPath, outLogger, getCommitInfo):+ print("\n*****************<Commit slider output>*******************\nTable of throughputs:" + '\n\t\tm1\tm2')+ for pathcommit in commitPath.getList():+ commitInfo = getCommitInfo(pathcommit)+ cHash = pathcommit.cHash+ cHash = cHash[:7]+ commMsg = "{}\t\t{}\t{}".format(+ cHash,+ pathcommit.firstThroughput,+ pathcommit.secondThroughput)+ print(commMsg)+ outLogger.info(commitInfo)+ cPath = commitPath.getList()+ thr00 = float(cPath[0].firstThroughput)+ thr01 = float(cPath[0].secondThroughput)+ thr10 = float(cPath[1].firstThroughput)++ print("{}\nSupposed rootcause is: {}".format(+ "*" * 58,+ 'Model' if abs(thr00 - thr01) > abs(thr00 - thr10) else 'OV'+ ))+ print('**********************************************************\n')+ print("* m1 = {}".format(pathcommit.firstModel))+ print("** m2 = {}".format(pathcommit.secondModel))++ def generateFullConfig(cfg, customCfg):+ tmpJSON = cfg+ if '-v' in customCfg and customCfg['-v'] == 'false':+ tmpJSON['verboseOutput'] = False+ if '-c' in customCfg:+ # WA: additional args are passed with '-' with standart argparser+ customCfg['c'] = customCfg['-c']+ if 'c' in customCfg:+ curCfg = tmpJSON['runConfig']+ interval = customCfg['c'].split("..")+ start, end = interval[0], interval[1]+ curCfg['commitList'] = {'explicitList': [ start, end ] }+ tmpJSON['runConfig'] = curCfg+ CommonTemplate.passParameters([+ 'gitPath', 'buildPath', 'appPath'+ ], customCfg, tmpJSON)+ if 'appCmd' in customCfg:+ if isinstance(customCfg['appCmd'], list):+ curCfg = tmpJSON['runConfig']+ curCfg['par_1'] = customCfg['appCmd'][0]+ curCfg['par_2'] = customCfg['appCmd'][1]+ tmpJSON['runConfig'] = curCfg+ else:+ curCfg = tmpJSON['runConfig']+ curCfg['par_1'] = customCfg['appCmd'].format(model=customCfg['modelList'][0])+ curCfg['par_2'] = customCfg['appCmd'].format(model=customCfg['modelList'][1])+ tmpJSON['runConfig'] = curCfg+ tmpJSON['appCmd'] = "{actualPar}"++ return tmpJSON\ No newline at end of filediff --git a/tools/commit_slider/utils/templates/broken_compilation.md b/tools/commit_slider/utils/templates/broken_compilation.mdnew file mode 100644index 00000000000..ad6ebf59d74--- /dev/null+++ b/tools/commit_slider/utils/templates/broken_compilation.md@@ -0,0 +1,33 @@+# Broken Compilation++`broken_compilation` — template for searching of eirst broken commit (in a sense of failed compilation stage).++- Cmake-way of building (without wheels)+- Looking for compilation (not linking) errors++---++## How to run+Example 1 (CLI)+```+python3 commit_slider.py -t broken_compilation -c <start_commit>..<end_commit> -gitPath <pathToGitRepository> -buildPath <pathToBuildDirectory>+```+Example 2 (Configuration, default paths)+```+{ "template" : {+ "name" : "broken_compilation",+ "c" : "<start_commit>..<end_commit>"+}+```+### Independent variables:+```+- verbosity: -v {true|false}+```++### Expected output:+```+*****************<Commit slider output>*******************+* Commit with broken compilation found: *+* Break commit: <comit_hash>, state: CommitState.BREAK *+**********************************************************+```\ No newline at end of filediff --git a/tools/commit_slider/utils/templates/broken_compilation.py b/tools/commit_slider/utils/templates/broken_compilation.pynew file mode 100644index 00000000000..c24c52faeb3--- /dev/null+++ b/tools/commit_slider/utils/templates/broken_compilation.py@@ -0,0 +1,52 @@+from utils.templates.common import CommonTemplate++class BrokenCompilationTemplate(CommonTemplate):+ def getName():+ return 'broken_comp'++ def getBilletFileName():+ return 'broken_compilation.json'++ def printResult(commitPath, outLogger, getCommitInfo):+ print("\n*****************<Commit slider output>*******************\n* Commit with broken compilation found:" + ' ' * 18 + '*')+ if not commitPath.metaInfo["preValidationPassed"]:+ msg = "Preliminary check failed, reason: {}".format(+ commitPath.metaInfo["reason"]+ )+ print(msg)+ outLogger.info(msg)+ elif not commitPath.metaInfo["postValidationPassed"]:+ msg = "Output results invalid, reason: {}".format(+ commitPath.metaInfo["reason"]+ )+ print(msg)+ outLogger.info(msg)+ else:+ for pathcommit in commitPath.getList():+ from utils.common_mode import Mode+ if pathcommit.state is not Mode.CommitPath.CommitState.DEFAULT:+ commitInfo = getCommitInfo(pathcommit)+ commMsg = "* {}".format(commitInfo)+ print(commMsg + ' ' * (57 - len(commMsg)) + '*')+ outLogger.info(commitInfo)+ print('**********************************************************\n')++ def generateFullConfig(cfg, customCfg):+ tmpJSON = cfg+ if '-v' in customCfg and customCfg['-v'] == 'false':+ tmpJSON['verboseOutput'] = False+ if '-c' in customCfg:+ # WA: additional args are passed with '-' with standart argparser+ customCfg['c'] = customCfg['-c']+ if 'c' in customCfg:+ curCfg = tmpJSON['runConfig']+ curCfg['commitList'] = {'getCommitListCmd': "git log {} --boundary --pretty=\"%h\"".format(customCfg['c'])}+ tmpJSON['runConfig'] = curCfg+ # todo: move common method to helpers+ if 'gitPath' in customCfg:+ tmpJSON['gitPath'] = customCfg['gitPath']+ if 'buildPath' in customCfg:+ tmpJSON['buildPath'] = customCfg['buildPath']+ tmpJSON['appPath'] = customCfg['buildPath']++ return tmpJSON\ No newline at end of filediff --git a/tools/commit_slider/utils/templates/common.py b/tools/commit_slider/utils/templates/common.pynew file mode 100644index 00000000000..b1f866ad534--- /dev/null+++ b/tools/commit_slider/utils/templates/common.py@@ -0,0 +1,82 @@+# Copyright (C) 2025 Intel Corporation+# SPDX-License-Identifier: Apache-2.0++from abc import ABC+from utils.subscription import SubscriptionManager+from utils.break_validator import BmValidationError+from utils.helpers import getClassByMethod+from enum import Enum+from utils.cfg_manager import CfgManager++class CommonTemplate(ABC):+ def getName():+ # simplified ID for API+ return 'common_template'++ def getBilletFileName():+ # filename for template billet to be defined by config population+ # 'some_custom_template.json' (".. {par_1} .. {par_N} ..") + parameters = full config,+ return None++ def getTemplateByCfg(cfg):+ if CommonTemplate.getName() == cfg['template']:+ return CommonTemplate+ else:+ return getClassByMethod('getName', cfg['template'], CommonTemplate)++ def passParameters(parList, srcCfg, dstCfg):+ for par in parList:+ if par in srcCfg:+ dstCfg[par] = srcCfg[par]++ def printResult(commitPath, outLogger, getCommitInfo):+ if not commitPath.metaInfo["preValidationPassed"]:+ msg = "Preliminary check failed, reason: {}".format(+ commitPath.metaInfo["reason"]+ )+ print(msg)+ outLogger.info(msg)+ elif not commitPath.metaInfo["postValidationPassed"]:+ msg = "Output results invalid, reason: {}".format(+ commitPath.metaInfo["reason"]+ )+ print(msg)+ outLogger.info(msg)+ else:+ for pathcommit in commitPath.getList():+ from utils.common_mode import Mode+ if pathcommit.state is not Mode.CommitPath.CommitState.DEFAULT:+ commitInfo = getCommitInfo(pathcommit)+ print(commitInfo)+ outLogger.info(commitInfo)++ @staticmethod+ def getTmplByMethod(target, method):+ def templateNameByFileName(filename):+ filename = filename.split('_')+ filename = ''.join(word.capitalize() for word in filename)+ return filename + 'Template'+ import os+ import importlib.util+ curDir = os.path.dirname(__file__)+ for filename in os.listdir(curDir):+ if filename.endswith(".py"):+ filename = filename[:-3]+ className = templateNameByFileName(filename)+ filename = 'utils.templates.' + filename+ module = importlib.import_module(filename)+ templateClass = getattr(module, className)+ if getattr(templateClass, method)() == target:+ return templateClass+ return CommonTemplate++ @staticmethod+ def getTemplate(tmplName):+ return CommonTemplate.getTmplByMethod(tmplName, 'getName')++ @staticmethod+ def populateCfg(tmplName, cfg):+ tmpl = CommonTemplate.getTemplate(tmplName)+ cfgBillet = tmpl.getBilletFileName()+ fullCfg = CommonTemplate.getTemplate(tmplName).generateFullConfig(CfgManager.readJsonTmpl(cfgBillet), cfg)+ return fullCfg\ No newline at end of filediff --git a/tools/commit_slider/utils/templates/model_compilation_table.py b/tools/commit_slider/utils/templates/model_compilation_table.pynew file mode 100644index 00000000000..e80ea48acae--- /dev/null+++ b/tools/commit_slider/utils/templates/model_compilation_table.py@@ -0,0 +1,66 @@+from utils.templates.common import CommonTemplate++class ModelCompilationTableTemplate(CommonTemplate):+ def getName():+ return 'model_comp_table'++ def getBilletFileName():+ return 'model_compilation_time_table.json'++ def printResult(commitPath, outLogger, getCommitInfo):+ print("\n*****************<Commit slider output>*******************\nTable of compilation time:" + '\n\t\tm1\tm2')+ for pathcommit in commitPath.getList():+ commitInfo = getCommitInfo(pathcommit)+ cHash = pathcommit.cHash+ cHash = cHash[:7]+ commMsg = "{}\t\t{}\t{}".format(+ cHash,+ pathcommit.firstThroughput,+ pathcommit.secondThroughput)+ print(commMsg)+ outLogger.info(commitInfo)+ cPath = commitPath.getList()+ thr00 = float(cPath[0].firstThroughput)+ thr01 = float(cPath[0].secondThroughput)+ thr10 = float(cPath[1].firstThroughput)++ print("{}\nSupposed rootcause is: {}".format(+ "*" * 58,+ 'Model' if abs(thr00 - thr01) > abs(thr00 - thr10) else 'OV'+ ))+ print('**********************************************************\n')+ print("* m1 = {}".format(pathcommit.firstModel))+ print("** m2 = {}".format(pathcommit.secondModel))++ def generateFullConfig(cfg, customCfg):+ tmpJSON = cfg+ if '-v' in customCfg and customCfg['-v'] == 'false':+ tmpJSON['verboseOutput'] = False+ else:+ tmpJSON['verboseOutput'] = True+ if '-c' in customCfg:+ # WA: additional args are passed with '-' with standart argparser+ customCfg['c'] = customCfg['-c']+ if 'c' in customCfg:+ curCfg = tmpJSON['runConfig']+ interval = customCfg['c'].split("..")+ start, end = interval[0], interval[1]+ curCfg['commitList'] = {'explicitList': [ start, end ] }+ tmpJSON['runConfig'] = curCfg+ CommonTemplate.passParameters([+ 'gitPath', 'buildPath', 'appPath'+ ], customCfg, tmpJSON)+ if 'appCmd' in customCfg:+ if isinstance(customCfg['appCmd'], list):+ curCfg = tmpJSON['runConfig']+ curCfg['par_1'] = customCfg['appCmd'][0]+ curCfg['par_2'] = customCfg['appCmd'][1]+ tmpJSON['runConfig'] = curCfg+ else:+ curCfg = tmpJSON['runConfig']+ curCfg['par_1'] = customCfg['appCmd'].format(model=customCfg['modelList'][0])+ curCfg['par_2'] = customCfg['appCmd'].format(model=customCfg['modelList'][1])+ tmpJSON['runConfig'] = curCfg+ tmpJSON['appCmd'] = "{actualPar}"++ return tmpJSON\ No newline at end of file