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
[Commit Slider] Multimodel support (#27279)
Yury Gaydaychuk72b381a555b9
diff --git a/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py b/src/plugins/intel_cpu/tools/commit_slider/commit_slider.pyindex 72f9f617b93..0a513de1c93 100644--- a/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py+++ b/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py@@ -7,13 +7,27 @@ import shutilimport sysfrom distutils.dir_util import copy_treefrom distutils.errors import DistutilsFileError-from utils.helpers import safeClearDir, getParams+from utils.cfg_manager import CfgManager+from utils.helpers import safeClearDir, getParams, getActualCfgargs, cfgData, customCfgPath = getParams()+# multiconfig handling: fetch actual config by idx+curCfgData = getActualCfg(cfgData, args.multiconfig)++if isinstance(cfgData, list) and args.multiconfig == "undefined":+ for idx, _ in enumerate(cfgData):+ argString = " ".join(sys.argv)+ workPath = os.getcwd()+ formattedCmd = "{py} {argString} -x {idx}".format(+ py=sys.executable, argString=argString, idx=idx+ )+ subprocess.call(formattedCmd.split())+ exit()+if args.utility != "no_utility":from utils.helpers import runUtility- runUtility(cfgData, args)+ runUtility(curCfgData, args)elif args.isWorkingDir:# rerun script from work directory@@ -22,14 +36,14 @@ elif args.isWorkingDir:from utils.helpers import checkArgAndGetCommitscommitList = []- if "commitList" in cfgData["runConfig"] and\- "explicitList" in cfgData["runConfig"]["commitList"]:- commitList = cfgData["runConfig"]["commitList"]["explicitList"]+ if "commitList" in curCfgData["runConfig"] and\+ "explicitList" in curCfgData["runConfig"]["commitList"]:+ commitList = curCfgData["runConfig"]["commitList"]["explicitList"]elif args.commitSeq is None:- if "getCommitListCmd" in cfgData["runConfig"]["commitList"]:- commitListCmd = cfgData["runConfig"]["commitList"]+ if "getCommitListCmd" in curCfgData["runConfig"]["commitList"]:+ commitListCmd = curCfgData["runConfig"]["commitList"]commitListCmd = commitListCmd["getCommitListCmd"]- cwd = cfgData["gitPath"]+ cwd = curCfgData["gitPath"]try:out = subprocess.check_output(commitListCmd.split(), cwd=cwd)except subprocess.CalledProcessError as e:@@ -37,26 +51,37 @@ elif args.isWorkingDir:raise CfgError("{msg} {e}".format(msg=msg, e=str(e)))out = out.decode("utf-8")commitList = out.split()- elif "explicitList" in cfgData["runConfig"]["commitList"]:- commitList = cfgData["runConfig"]["commitList"]["explicitList"]+ elif "explicitList" in curCfgData["runConfig"]["commitList"]:+ commitList = curCfgData["runConfig"]["commitList"]["explicitList"]else:raise CfgError("Commit list is mandatory")else:- commitList = checkArgAndGetCommits(args.commitSeq, cfgData)+ commitList = checkArgAndGetCommits(args.commitSeq, curCfgData)commitList.reverse()- p = Mode.factory(cfgData)- p.run(commitList, cfgData)+ p = Mode.factory(curCfgData)+ p.run(commitList, curCfgData)p.printResult()else:- workPath = cfgData["workPath"]+ # prepare run+ workPath = curCfgData["workPath"]if not os.path.exists(workPath):os.mkdir(workPath)else:- safeClearDir(workPath, cfgData)+ safeClearDir(workPath, curCfgData)curPath = os.getcwd()copy_tree(curPath, workPath)+ # handle user cache path+ tempCachePath = CfgManager.singlestepStrFormat(curCfgData["cachePath"], "workPath", workPath)+ permCachePath = CfgManager.singlestepStrFormat(curCfgData["cachePath"], "workPath", curPath)+ # setup cache path if specified+ if curCfgData['userCachePath']:+ permCachePath = curCfgData['userCachePath']+ else:+ curCfgData['userCachePath'] = permCachePath++ # run CSscriptName = os.path.basename(__file__)argString = " ".join(sys.argv)formattedCmd = "{py} {workPath}/{argString} -wd".format(@@ -65,14 +90,17 @@ else:subprocess.call(formattedCmd.split())# copy logs and cache back to general repo- tempLogPath = cfgData["logPath"].format(workPath=workPath)- permLogPath = cfgData["logPath"].format(workPath=curPath)- safeClearDir(permLogPath, cfgData)- copy_tree(tempLogPath, permLogPath)-- tempCachePath = cfgData["cachePath"].format(workPath=workPath)- permCachePath = cfgData["cachePath"].format(workPath=curPath)- safeClearDir(permCachePath, cfgData)+ tempLogPath = CfgManager.singlestepStrFormat(curCfgData["logPath"], "workPath", workPath)+ permLogPath = CfgManager.singlestepStrFormat(curCfgData["logPath"], "workPath", curPath)++ if curCfgData['userLogPath']:+ permLogPath = curCfgData['userLogPath']++ safeClearDir(permLogPath, curCfgData)+ if not curCfgData['clearLogsAposteriori']:+ copy_tree(tempLogPath, permLogPath)++ safeClearDir(permCachePath, curCfgData)try:copy_tree(tempCachePath, permCachePath)except DistutilsFileError:@@ -89,4 +117,4 @@ else:# prevent exception raising if cfg set up from outer locationpass- safeClearDir(workPath, cfgData)+ safeClearDir(workPath, curCfgData)diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/commit_slider_test.py b/src/plugins/intel_cpu/tools/commit_slider/tests/commit_slider_test.pyindex 9ebce6ae2b3..2d342da339e 100644--- a/src/plugins/intel_cpu/tools/commit_slider/tests/commit_slider_test.py+++ b/src/plugins/intel_cpu/tools/commit_slider/tests/commit_slider_test.py@@ -7,14 +7,14 @@ from tests import skip_commit_slider_devtestsys.path.append('./')from test_util import getExpectedCommit,\- getBordersByTestData, getActualCommit+ getBordersByTestData, getActualCommit, getCSOutputfrom utils.break_validator import validateBMOutput, BmValidationErrorfrom test_data import FirstBadVersionData, FirstValidVersionData,\BmStableData, BmValidatorSteppedBreakData, BmValidatorSteppedBreakData2,\BenchmarkAppDataUnstable, BenchmarkAppDataStable, BenchmarkAppNoDegradationData,\BenchmarkAppUnstableDevData, BenchmarkAppWrongPathData, BenchmarkAppPathFoundData,\- BenchmarkFirstFixedAppData, AcModeData, BenchmarkMetricData-+ BenchmarkFirstFixedAppData, AcModeData, BenchmarkMetricData, CustomizedLogData, \+ MultiConfigData, ConfigMultiplicatorData, ConfigMultiplicatorWithKeyDataclass CommitSliderTest(TestCase):@skip_commit_slider_devtest@@ -32,6 +32,40 @@ class CommitSliderTest(TestCase):actualCommit, _ = getActualCommit(updatedData)self.assertEqual(breakCommit, actualCommit)+ @skip_commit_slider_devtest+ def testCustomizedLog(self):+ breakCommit, updatedData = getExpectedCommit(+ CustomizedLogData())+ actualCommit, _ = getActualCommit(updatedData)+ self.assertEqual(breakCommit, actualCommit)++ @skip_commit_slider_devtest+ def testMultiConfig(self):+ _, updatedData = getExpectedCommit(+ MultiConfigData())++ self.assertEqual(+ getCSOutput(updatedData),+ "\n\n".join(['cfg #{n}'.format(n=n) for n in range(3)]) + "\n")++ @skip_commit_slider_devtest+ def testConfigMultiplicatorByKey(self):+ from utils.helpers import multiplyCfgByKey+ from utils.helpers import deepCopyJSON+ testData = ConfigMultiplicatorData()+ self.assertEqual(+ multiplyCfgByKey(testData.testCfg),+ deepCopyJSON(testData.multipliedCfg))++ @skip_commit_slider_devtest+ def testRunCSMultiplicatedCfgByKey(self):+ _, updatedData = getExpectedCommit(+ ConfigMultiplicatorWithKeyData())++ self.assertEqual(+ getCSOutput(updatedData),+ "\n\n".join(['cfg #{n}'.format(n=n) for n in range(3)]) + "\n")+@skip_commit_slider_devtestdef testBmUnstable(self):_, updatedData = getExpectedCommit(@@ -323,7 +357,7 @@ class CommitSliderTest(TestCase):}}}- cfg = deepMapUpdate(cfg, ["path", "to", "placeholder"], "updated")+ deepMapUpdate(cfg, ["path", "to", "placeholder"], "updated")self.assertEqual(cfg["path"]["to"]["placeholder"],"updated"diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/test_data.py b/src/plugins/intel_cpu/tools/commit_slider/tests/test_data.pyindex eed382aba58..50249b1f24a 100644--- a/src/plugins/intel_cpu/tools/commit_slider/tests/test_data.py+++ b/src/plugins/intel_cpu/tools/commit_slider/tests/test_data.py@@ -3,6 +3,7 @@from enum import Enumimport json+from utils.cfg_manager import CfgManagerclass TestData():__test__ = False@@ -21,14 +22,14 @@ class TestData():def formatConfig(self, content):# redefine for non trivial cases- return content.format(- appCmd="./{}".format(self.repoName),- appPath="tests/{}/build".format(self.repoName),- buildPath="tests/{}/build".format(self.repoName),- gitPath="tests/{}".format(self.repoName),- start=self.start,- end=self.end- )+ return CfgManager.multistepStrFormat(content, [+ {'p' : 'appCmd', 's' : "./{}".format(self.repoName)},+ {'p' : 'appPath', 's' : "tests/{}/build".format(self.repoName)},+ {'p' : 'buildPath', 's' : "tests/{}/build".format(self.repoName)},+ {'p' : 'gitPath', 's' : "tests/{}".format(self.repoName)},+ {'p' : 'start', 's' : self.start},+ {'p' : 'end', 's' : self.end}+ ])@staticmethoddef checkTestSet():@@ -66,7 +67,11 @@ class TestData():BmPathFound = 11,BmFirstFixed = 12,BmLatencyMetric = 13,- ACModeData = 14+ ACModeData = 14,+ CustomizedLog = 15,+ MultiConfig = 16,+ ConfigMultiplicator = 17,+ MultiConfigWithKey = 18def requireTestData(self, reqLambda):# mapping json to test data holder@@ -91,6 +96,61 @@ class FirstBadVersionData(TestData):requireBinarySearchData)+class CustomizedLogData(TestData):+ def getTestCase():+ return TestData.TestCase.CustomizedLog++ def getTestName(self):+ return "CustomizedLog"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )++class MultiConfigData(TestData):+ def getTestCase():+ return TestData.TestCase.CustomizedLog++ def getTestName(self):+ return "MultiConfig"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )++class ConfigMultiplicatorWithKeyData(TestData):+ def getTestCase():+ return TestData.TestCase.MultiConfigWithKey++ def getTestName(self):+ return "MultiConfigWithKey"++ def __init__(self):+ from test_util import requireBinarySearchData+ self.requireTestData(+ requireBinarySearchData+ )++class ConfigMultiplicatorData(TestData):+ def getTestCase():+ return TestData.TestCase.ConfigMultiplicator++ def getTestName(self):+ return "ConfigMultiplicatorByKey"++ def __init__(self):+ self.requireTestData(+ lambda td, rsc: [+ setattr(td, key, rsc[td.getTestName()][key])+ for key in [+ 'multipliedCfg', 'testCfg'+ ]]+ )+class BenchmarkAppDataUnstable(TestData):def getTestCase():return TestData.TestCase.BmBinarySearchUnstablediff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/test_util.py b/src/plugins/intel_cpu/tools/commit_slider/tests/test_util.pyindex 82b2776673c..14dcf1dd5b3 100644--- a/src/plugins/intel_cpu/tools/commit_slider/tests/test_util.py+++ b/src/plugins/intel_cpu/tools/commit_slider/tests/test_util.py@@ -8,6 +8,7 @@ import jsonimport sysimport shutilfrom os import path+from utils.cfg_manager import CfgManagerfrom test_data import TestDatafrom test_data import TestErrorfrom utils.helpers import formatJSON@@ -149,33 +150,61 @@ def getExpectedCommit(td: TestData):return breakCommit, tddef getActualCommit(td: TestData):+ sliderOutput = runCS(td)+ rejectReason, foundCommit = parseSliderOutput(sliderOutput)+ # clear temp data+ [shutil.rmtree(dir) for dir in [+ td.repoName,+ td.userCachePath,+ td.userLogPath+ ]]+ os.remove(td.testCfgName)++ return foundCommit, rejectReason++def getCSOutput(td: TestData):+ sliderOutput = runCS(td)+ # clear temp data+ [shutil.rmtree(dir) for dir in [+ td.repoName,+ td.userCachePath,+ td.userLogPath+ ]]+ os.remove(td.testCfgName)++ return sliderOutput++def runCS(td: TestData):if not td.actualDataReceived:raise TestError("Running actual commit before expected.")# prepare configcfg = formatJSON(td.testCfg, td.formatConfig)- testCfg = "test_cfg.json"-- with open(testCfg, "w+") as customCfg:+ td.userLogPath = CfgManager.singlestepStrFormat(+ td.userLogPath, "testDir", os.getcwd())+ td.userCachePath = CfgManager.singlestepStrFormat(+ td.userCachePath, "testDir", os.getcwd())+ td.testCfgName = "test_cfg.json"+ for key in [+ 'userLogPath', 'clearLogsAposteriori',+ 'userCachePath', 'clearCache'+ ]:+ if isinstance(cfg, list):+ cfg[0][key] = getattr(td, key)+ else:+ cfg[key] = getattr(td, key)+ with open(td.testCfgName, "w+") as customCfg:customCfg.truncate(0)json.dump(cfg, customCfg)customCfg.close()# run slider and check outputsliderOutput = runCmd(- "python3.8 commit_slider.py -cfg tests/{}".format(testCfg),+ "python3.8 commit_slider.py -cfg tests/{}".format(td.testCfgName),"../")sliderOutput = '\n'.join(map(str, sliderOutput))- rejectReason, foundCommit = parseSliderOutput(sliderOutput)- # clear temp data- [shutil.rmtree(dir) for dir in [- td.repoName,- td.cachePath,- td.logPath]]- os.remove(testCfg)-- return foundCommit, rejectReason+ return sliderOutputdef parseSliderOutput(sliderOutput: str):rejectReason, foundCommit, matcher = None, None, None@@ -220,9 +249,14 @@ def requireBinarySearchData(td: TestData, rsc: map):'testCfg', 'patchedFile', 'repoName']])-- [setattr(td, key, td.commonRsc[key]) for key in [- 'repoStructure', 'cachePath', 'logPath',+ [setattr(td, key, td.commonRsc[key] \+ if not key in td.testCfg or \+ not isinstance(td.testCfg[key], str) \+ else td.testCfg[key]) for key in [+ 'repoStructure',+ 'userCachePath',+ 'userLogPath',+ 'clearLogsAposteriori', 'clearCache','mainFile', 'repoPath']]td.patternPrefix = td.commonRsc['patchGeneratorPrefix']diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/tests_res.json b/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/tests_res.jsonindex 008b762e781..7f357753de1 100644--- a/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/tests_res.json+++ b/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/tests_res.json@@ -1,8 +1,10 @@{"binarySearchRes": {"repoPath": "./",- "cachePath": "../slider_cache",- "logPath": "../log",+ "userCachePath": "{testDir}/test_cache/",+ "userLogPath" : "{testDir}/test_log/",+ "clearLogsAposteriori" : true,+ "clearCache" : true,"patchGeneratorPrefix": "const char \\*patchGenerator = R\"V0G0N\\(","patchGeneratorPostfix": "\\)V0G0N\";","mainFile": "main.cpp",@@ -34,6 +36,196 @@}}},+ "CustomizedLog": {+ "repoName": "firstBadVersion",+ "patchedFile": "tests_res/fbv_main.cpp",+ "testCfg": {+ "appCmd" : "{appCmd}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "userLogPath" : "{testDir}/test_log/sub_log/",+ "clearLogsAposteriori" : false,+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "getCommitListCmd" : "git log {start}..{end} --boundary --pretty=\"%h\""+ },+ "mode" : "checkOutput",+ "traversal" : "firstFailedVersion",+ "stopPattern" : "(.)*failed(.)*"+ }+ }+ },+ "MultiConfig": {+ "repoName": "firstBadVersion",+ "patchedFile": "tests_res/fbv_main.cpp",+ "testCfg": [+ {+ "appCmd" : "{appCmd}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "userLogPath" : "{testDir}/test_log/sub_log_0/",+ "clearLogsAposteriori" : false,+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "getCommitListCmd" : "git log {start}..{end} --boundary --pretty=\"%h\""+ },+ "mode" : "nop",+ "traversal" : "bruteForce",+ "msg" : "cfg #0"+ }+ },+ {+ "appCmd" : "{appCmd}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "userLogPath" : "{testDir}/test_log/sub_log_1/",+ "clearLogsAposteriori" : false,+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "getCommitListCmd" : "git log {start}..{end} --boundary --pretty=\"%h\""+ },+ "mode" : "nop",+ "traversal" : "bruteForce",+ "msg" : "cfg #1"+ }+ },+ {+ "appCmd" : "{appCmd}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "userLogPath" : "{testDir}/test_log/sub_log_2/",+ "clearLogsAposteriori" : false,+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "getCommitListCmd" : "git log {start}..{end} --boundary --pretty=\"%h\""+ },+ "mode" : "nop",+ "traversal" : "bruteForce",+ "msg" : "cfg #2"+ }+ }+ ]+ },+ "ConfigMultiplicatorByKey": {+ "testCfg":+ {+ "appCmd" : "{appCmd}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "userLogPath" : {+ "multiplication_type": "dot_product",+ "multiplication_key": [+ "{testDir}/test_log/sub_log_0/",+ "{testDir}/test_log/sub_log_1/",+ "{testDir}/test_log/sub_log_2/"+ ]+ },+ "clearLogsAposteriori" : false,+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "getCommitListCmd" : {+ "multiplication_type": "dot_product",+ "multiplication_key": [+ "git log start_0..end_0 --boundary --pretty=\"%h\"",+ "git log start_1..end_1 --boundary --pretty=\"%h\"",+ "git log start_2..end_2 --boundary --pretty=\"%h\""+ ]+ }+ },+ "someKey" : ["dot_product", "", "dot_product"],+ "complexOblect": {"multiplication_key": [+ {"k1" : "v0", "k2" : ["v00", "v01"]},+ {"k1" : "v1", "k2" : ["v10", "v11"]},+ {"k1" : "v2", "k2" : ["v20", "v21"]}+ ]},+ "someList" : [+ "val_0", "val_1",+ {"multiplication_key": [+ "val_20",+ "val_21",+ "val_22"+ ]}+ ],+ "mode" : "nop",+ "traversal" : "bruteForce",+ "msg" : {+ "multiplication_type": "dot_product",+ "multiplication_key": ["cfg #1", "cfg #2", "cfg #3"]+ }+ }+ },+ "multipliedCfg" : [{"appCmd":"{appCmd}","appPath":"{appPath}","buildPath":"{buildPath}","clearLogsAposteriori":false,"gitPath":"{gitPath}","runConfig":{"commitList":{"getCommitListCmd":"git log start_0..end_0 --boundary --pretty=\"%h\""},"complexOblect":{"k1":"v0","k2":["v00","v01"]},"mode":"nop","msg":"cfg #1","someKey":["dot_product","","dot_product"],"someList":["val_0","val_1","val_20"],"traversal":"bruteForce"},"userLogPath":"{testDir}/test_log/sub_log_0/","verboseOutput":false},{"appCmd":"{appCmd}","appPath":"{appPath}","buildPath":"{buildPath}","clearLogsAposteriori":false,"gitPath":"{gitPath}","runConfig":{"commitList":{"getCommitListCmd":"git log start_1..end_1 --boundary --pretty=\"%h\""},"complexOblect":{"k1":"v1","k2":["v10","v11"]},"mode":"nop","msg":"cfg #2","someKey":["dot_product","","dot_product"],"someList":["val_0","val_1","val_21"],"traversal":"bruteForce"},"userLogPath":"{testDir}/test_log/sub_log_1/","verboseOutput":false},{"appCmd":"{appCmd}","appPath":"{appPath}","buildPath":"{buildPath}","clearLogsAposteriori":false,"gitPath":"{gitPath}","runConfig":{"commitList":{"getCommitListCmd":"git log start_2..end_2 --boundary --pretty=\"%h\""},"complexOblect":{"k1":"v2","k2":["v20","v21"]},"mode":"nop","msg":"cfg #3","someKey":["dot_product","","dot_product"],"someList":["val_0","val_1","val_22"],"traversal":"bruteForce"},"userLogPath":"{testDir}/test_log/sub_log_2/","verboseOutput":false}]+ },+ "MultiConfigWithKey": {+ "repoName": "firstBadVersion",+ "patchedFile": "tests_res/fbv_main.cpp",+ "testCfg": {+ "appCmd" : "{appCmd}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "userLogPath" : {+ "multiplication_type": "dot_product",+ "multiplication_key": [+ "{testDir}/test_log/sub_log_0/",+ "{testDir}/test_log/sub_log_1/",+ "{testDir}/test_log/sub_log_2/"+ ]+ },+ "clearLogsAposteriori" : false,+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "getCommitListCmd" : "git log {start}..{end} --boundary --pretty=\"%h\""+ },+ "mode" : "nop",+ "traversal" : "bruteForce",+ "msg" : {+ "multiplication_type": "dot_product",+ "multiplication_key": [+ "cfg #0",+ "cfg #1",+ "cfg #2"+ ]+ }+ }+ }+ },+ "ConfigMultiplicator": {+ "repoName": "firstBadVersion",+ "patchedFile": "tests_res/fbv_main.cpp",+ "testCfg":+ {+ "appCmd" : "{appCmd}",+ "appPath": "{appPath}",+ "gitPath" : "{gitPath}",+ "userLogPath" : "{testDir}/test_log/sub_log_0/",+ "clearLogsAposteriori" : false,+ "buildPath" : "{buildPath}",+ "verboseOutput": false,+ "runConfig" : {+ "commitList" : {+ "getCommitListCmd" : "git log {start}..{end} --boundary --pretty=\"%h\""+ },+ "mode" : "nop",+ "traversal" : "bruteForce",+ "msg" : {+ "multiplication_type": "dot_product",+ "multiplication_key": ["cfg #1", "cfg #2", "cfg #3"]+ }+ }+ }+ },"BmBinarySearchUnstable": {"repoName": "BmBinarySearchUnstable","patchedFile": "tests_res/fbv_bm_unstable_main.cpp",diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.jsonindex d31439f1a54..3e70fbd9f98 100644--- a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json+++ b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json@@ -70,7 +70,10 @@"appPath" : "../../../../../bin/intel64/Release/","buildPath" : "../../../../../build/","cachePath" : "{workPath}/slider_cache/",+ "userCachePath" : "","logPath" : "{workPath}/log/",+ "userLogPath" : "",+ "clearLogsAposteriori" : false,"workPath" : "will be defined in runtime","linWorkPath" : "/tmp/commit_slider_tool","winWorkPath" : "%tmp%\\commit_slider",diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg_manager.py b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg_manager.pyindex 85d1b775494..074c52102af 100644--- a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg_manager.py+++ b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg_manager.py@@ -10,16 +10,21 @@ class CfgManager():self.cfg = cfg@staticmethod- def multistepStrFormat(input: str, placeholder: str, substitution: str):+ def singlestepStrFormat(input: str, placeholder: str, substitution: str):return input.replace('{}{}{}'.format('{', placeholder, '}'),substitution)+ @staticmethod+ def multistepStrFormat(input: str, placeholderSubstPairArr):+ for ps in placeholderSubstPairArr:+ input = CfgManager.singlestepStrFormat(input, ps['p'], ps['s'])+ return input+def applyTemplate(self):if not "template" in self.cfg:return self.cfg- logPath = self.cfg["logPath"]tmplName = self.cfg["template"]["name"]fullCfg = {}# todo: generalize tmplcfg generator@@ -29,16 +34,18 @@ class CfgManager():fullCfg = self.generateE2ETemplate()elif tmplName == "bm_functional":fullCfg = self.generatebmFunctionalTemplate()+ elif tmplName == "bm_arm_mac":+ fullCfg = self.generateArmBmTemplate()else:raise Exception("Unknown template '{}'".format(tmplName))- fullCfg["logPath"] = logPathreturn fullCfgdef readJsonTmpl(self, tmplFileName: str):+ smplPath = os.path.dirname(os.path.realpath(__file__))tmplFileName = os.path.join(- "utils/cfg_samples/", tmplFileName+ smplPath, "cfg_samples/", tmplFileName)with open(tmplFileName) as cfgFile:tmplJSON = json.load(cfgFile)@@ -54,7 +61,7 @@ class CfgManager():tmpJSON["runConfig"]["stopPattern"] = tmpl["errorPattern"]tmpJSON["dlbConfig"]["commonPath"] = tmpl["precommitPath"]tmpJSON["cachedPathConfig"]["commonPath"] = tmpl["precommitPath"]- tmpJSON["appCmd"] = CfgManager.multistepStrFormat(+ tmpJSON["appCmd"] = CfgManager.singlestepStrFormat(tmpJSON["appCmd"],tmpl["appCmd"],"testCmd"@@ -99,3 +106,107 @@ class CfgManager():else:tmpJSON["runConfig"]["traversal"] = "firstFailedVersion"return tmpJSON++ def generateArmBmTemplate(self):+ tmpl = self.cfg["template"]+ tmpJSON = self.readJsonTmpl("bm_arm_mac.json")+ # handle syntactic sugar: logs, models, intervals+ isMultimodel = False+ if isinstance(tmpl['model'], list):+ isMultimodel = True+ tmpJSON['clearCache'] = True+ appCmdList = []+ logPathList = []+ for model in tmpl['model']:+ appCmdList.append(+ CfgManager.singlestepStrFormat(+ tmpJSON['appCmd'], 'model', model+ )+ )+ logPathList.append(+ CfgManager.singlestepStrFormat(+ "{workPath}/log/sublog/{model}",+ 'model',+ model+ ))+ tmpJSON['appCmd'] = appCmdList+ if 'interval' in tmpl:+ runCfgList = []+ for interval in tmpl['interval']:+ runCfg = tmpJSON['runConfig']+ cmtList = "\"commitList\" : {\+ \"getCommitListCmd\" : \"git log {interval} \+ --boundary --pretty=\\\"%h\\\"\"}"+ CfgManager.singlestepStrFormat(+ cmtList, 'interval', interval)+ runCfg['commitList'] = cmtList+ runCfgList.append(runCfg)+ tmpJSON['runConfig'] = runCfgList++ devParam = "perfAppropriateDeviation"+ isFirstFixed = "isFirstFixed"+ if isMultimodel:+ pass+ elif "appCmd" in tmpl:+ tmpJSON["appCmd"] = tmpl["appCmd"]+ elif 'model' in tmpl: # check if model param separated+ newCmd = CfgManager.singlestepStrFormat(+ tmpJSON['appCmd'], "model", tmpl['model']+ )+ tmpJSON['appCmd'] = newCmd+ else:+ raise Exception("No 'appcmd' in template")+ if devParam in tmpl:+ tmpJSON["runConfig"][devParam] = tmpl[devParam]+ if isFirstFixed in tmpl and tmpl[isFirstFixed]:+ tmpJSON["runConfig"]["traversal"] = "firstFixedVersion"+ else:+ tmpJSON["runConfig"]["traversal"] = "firstFailedVersion"+ return tmpJSON++# Example 1+# {+# "template": {+# "name":"bm_arm_mac",+# "buildEnvVars" : [+# {"name" : "ALL_PROXY", "val" : "<path_1>"},+# {"name" : "http_proxy", "val" : "<path_2>"},+# {"name" : "https_proxy", "val" : "<path_3>"}+# ],+# "model":["path_0", "path_1", "path_2"]+# }+# }++# Example 2+# {+# "template": {+# "name":"bm_arm_mac",+# "buildEnvVars" : [+# {"name" : "ALL_PROXY", "val" : "<path_1>"},+# {"name" : "http_proxy", "val" : "<path_2>"},+# {"name" : "https_proxy", "val" : "<path_3>"}+# ],+# "appCmd":"./benchmark_app -m {model} <other_parameters>",+# "model":["path_0", "path_1", "path_2"],+# "traversal":"firstFixedVersion",+# "perfAppropriateDeviation": 0.2,+# "interval":["hash_00..hash_01", "hash_10..hash_11", "hash_20..hash_21"]+# }+# }++# Example 3+# {+# "template": {+# "name":"bm_arm_mac",+# "buildEnvVars" : [+# {"name" : "ALL_PROXY", "val" : "<path_1>"},+# {"name" : "http_proxy", "val" : "<path_2>"},+# {"name" : "https_proxy", "val" : "<path_3>"}+# ],+# "appCmd":[+# "./benchmark_app -m <model_path_0> <other_parameters_0>",+# "./benchmark_app -m <model_path_1> <other_parameters_1>",+# "./benchmark_app -m <model_path_2> <other_parameters_2>",+# ]+# }+# }diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg_samples/bm_arm_mac.json b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg_samples/bm_arm_mac.jsonindex f8e2007720d..376db19a0c2 100644--- a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg_samples/bm_arm_mac.json+++ b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg_samples/bm_arm_mac.json@@ -4,7 +4,7 @@{"name" : "http_proxy", "val" : "<path_2>"},{"name" : "https_proxy", "val" : "<path_3>"}],- "appCmd" : "./benchmark_app -m <model_path> -d CPU -hint latency -inference_only=false -t 60",+ "appCmd" : "./benchmark_app -m {model} -d CPU -hint latency -inference_only=false -t 60","makeCmd" : "cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=OFF -DTHREADING=TBB -DENABLE_INTEL_GPU=OFF -DENABLE_SAMPLES=ON -DENABLE_TESTS=OFF -DENABLE_HETERO=OFF -DENABLE_TEMPLATE=OFF -DENABLE_CPU_DEBUG_CAPS=OFF -DENABLE_DEBUG_CAPS=OFF -DENABLE_OPENVINO_DEBUG=OFF -DCMAKE_CXX_FLAGS=-Wno-deprecated -DCMAKE_C_FLAGS=-Wno-deprecated -DCMAKE_CXX_FLAGS=-Wno-deprecated-declarations -DCMAKE_C_FLAGS=-Wno-deprecated-declarations ..","appPath" : "../../../../../bin/arm64/Release/","runConfig" : {@@ -12,7 +12,7 @@"getCommitListCmd" : "git log <start>..<end> --boundary --pretty=\"%h\""},"mode" : "bmPerf",- "traversal" : "firstFixedVersion",+ "traversal" : "{traversal}","perfAppropriateDeviation" : 0.1,"metric": "latency:average"},diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py b/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.pyindex 16400cdde65..d0726414687 100644--- a/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py+++ b/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py@@ -35,6 +35,10 @@ class Mode(ABC):self.commonLogger = util.setupLogger("commonLogger", logPath, "common_log.log")+ self.outLogger = util.setupLogger(+ "outLogger", logPath, "out_log.log"+ )+ self.checkOutPathPattern = "check_output_cache.json"def isPerformanceBased(self):return False@@ -45,22 +49,37 @@ class Mode(ABC):cp = util.getActualPath("cachePath", self.cfg)if not os.path.exists(cp):os.makedirs(cp)- self.cachePath = os.path.join(cp, "check_output_cache.json")+ self.cachePath = os.path.join(cp, self.checkOutPathPattern)initCacheMap = {}+ self.commonLogger.info("Cache created")+ self.commonLogger.info("Work cache:")+ self.commonLogger.info(self.cachePath)+ self.commonLogger.info("User cache:")+ self.commonLogger.info(self.cfg["userCachePath"])+ # check if old cache must be reused+ userCachePath = os.path.join(+ self.cfg["userCachePath"],+ self.checkOutPathPattern)try:- with open(self.cachePath, "r+") as cacheDump:+ with open(userCachePath, "r+") as cacheDump:if self.cfg["clearCache"]:- cacheDump.truncate(0)- json.dump(initCacheMap, cacheDump)+ # we don't need old cache+ passelse:try:- json.load(cacheDump)+ # check if JSON is valid+ initCacheMap = json.load(cacheDump)except json.decoder.JSONDecodeError:json.dump(initCacheMap, cacheDump)+ cacheDump.close()except FileNotFoundError:- with open(self.cachePath, "w") as cacheDump:- json.dump(initCacheMap, cacheDump)- cacheDump.close()+ # no old cache, never mind+ pass++ # create work cache+ with open(self.cachePath, "w") as workCacheDump:+ json.dump(initCacheMap, workCacheDump)+ workCacheDump.close()def getCommitIfCashed(self, commit):with open(self.cachePath, "r") as cacheDump:@@ -222,17 +241,23 @@ class Mode(ABC):def printResult(self):if not self.commitPath.metaInfo["preValidationPassed"]:- print("Preliminary check failed, reason: {}".format(+ msg = "Preliminary check failed, reason: {}".format(self.commitPath.metaInfo["reason"]- ))+ )+ print(msg)+ self.outLogger.info(msg)elif not self.commitPath.metaInfo["postValidationPassed"]:- print("Output results invalid, reason: {}".format(+ msg = "Output results invalid, reason: {}".format(self.commitPath.metaInfo["reason"]- ))+ )+ print(msg)+ self.outLogger.info(msg)else:for pathcommit in self.commitPath.getList():if pathcommit.state is not Mode.CommitPath.CommitState.DEFAULT:- print(self.getCommitInfo(pathcommit))+ commitInfo = self.getCommitInfo(pathcommit)+ print(commitInfo)+ self.outLogger.info(commitInfo)def getCommitInfo(self, commit):# override if you need more details in output representationdiff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py b/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.pyindex 970974637bd..c444b5bb63f 100644--- a/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py+++ b/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py@@ -15,13 +15,25 @@ from utils.cfg_manager import CfgManagerimport copy+mulKey = 'multiplication_key'+def getMeaningfullCommitTail(commit):return commit[:7]+def extractModelPath(cmdStr):args = cmdStr.split()return args[args.index("-m") + 1]++def getActualCfg(cfg, multiconfig: str):+ if isinstance(cfg, list) and \+ multiconfig != 'undefined':+ return cfg[int(multiconfig)]+ else:+ return cfg++def getParams():parser = ArgumentParser()parser.add_argument("-c", "--commits", dest="commitSeq", help="commit set")@@ -46,6 +58,14 @@ def getParams():help="run utility with specified name",default="no_utility",)++ parser.add_argument(+ "-x",+ "--multiconfig",+ dest="multiconfig",+ help="index in config array or 'undefined' mark",+ default="undefined"+ )args, additionalArgs = parser.parse_known_args()argHolder = DictHolder(args.__dict__)@@ -53,38 +73,65 @@ def getParams():presetCfgPath = "utils/cfg.json"customCfgPath = ""customCfgPath = argHolder.configuration- presetCfgData = None- with open(presetCfgPath) as cfgFile:- presetCfgData = json.load(cfgFile)- cfgFile.close()+ presetCfgData = loadJSONToString(presetCfgPath)if argHolder.utility != "no_utility":it = iter(additionalArgs)addDict = dict(zip(it, it))mergedArgs = {**(args.__dict__), **addDict}argHolder = DictHolder(mergedArgs)+ presetCfgData = loadJSONToObject(presetCfgPath)return argHolder, presetCfgData, presetCfgPath- customCfgData = None- with open(customCfgPath) as cfgFile:- customCfgData = json.load(cfgFile)- cfgFile.close()-- # config manager resolves templates in config,- # in the future, all interactions with config will- # be incapsulated in config manager- cm = CfgManager(customCfgData)- customCfgData = cm.applyTemplate()+ customCfgData = loadJSONToString(customCfgPath)+ if mulKey in customCfgData:+ customCfgData = multiplyCfgByKey(json.loads(customCfgData))+ else:+ customCfgData = json.loads(customCfgData)- # customize cfg- for key in customCfgData:- newVal = customCfgData[key]- presetCfgData[key] = newVal+ presetCfgData = customizeCfg(customCfgData, presetCfgData)- presetCfgData = absolutizePaths(presetCfgData)return argHolder, presetCfgData, customCfgPath+def loadJSONToString(path):+ with open(path, 'r') as file:+ data = file.read()+ file.close()+ return data+++def loadJSONToObject(path):+ with open(path) as file:+ obj = json.load(file)+ file.close()+ return obj+++def customizeCfg(customCfg, presetCfg: str):+ if isinstance(customCfg, list):+ returnCfgList = [{}] * len(customCfg)+ for idx, subCfg in enumerate(customCfg):+ returnCfgList[idx] = customizeCfg(subCfg, presetCfg)+ return returnCfgList+ else:+ presetCfg = json.loads(presetCfg)++ # config manager resolves templates in config,+ # in the future, all interactions with config will+ # be incapsulated in config manager+ cm = CfgManager(customCfg)+ customCfg = cm.applyTemplate()++ # customize cfg+ for key in customCfg:+ newVal = customCfg[key]+ presetCfg[key] = newVal++ presetCfg = absolutizePaths(presetCfg)+ return presetCfg++def getBlobDiff(file1, file2):with open(file1) as file:content = file.readlines()@@ -299,7 +346,7 @@ def fetchAppOutput(cfg, commit):{"src": cfg["appPath"], "dst": "appPath"},{"src": sys.executable, "dst": "py"}]:- appCmd = CfgManager.multistepStrFormat(+ appCmd = CfgManager.singlestepStrFormat(appCmd,item["dst"],item["src"]@@ -495,8 +542,8 @@ def returnToActualVersion(cfg):def setupLogger(name, logPath, logFileName, level=log.INFO):if not os.path.exists(logPath):os.makedirs(logPath)- logFileName = logPath + logFileName- with open(logFileName, "w"): # clear old log+ logFileName = os.path.join(logPath, logFileName)+ with open(logFileName, "w+"): # clear old logpasshandler = log.FileHandler(logFileName)formatter = log.Formatter("%(asctime)s %(levelname)s %(message)s")@@ -635,6 +682,7 @@ class DictHolder:for k, v in dict.items():setattr(self, k, v)+def formatJSON(content, formatLambda):if isinstance(content, dict):for k, value in content.items():@@ -649,6 +697,99 @@ def formatJSON(content, formatLambda):passreturn content++def findJSONPathsByValue(content, soughtFor, curPath:list=['$']):+ pathVector = []+ if isinstance(content, dict):+ for k, value in content.items():+ newRes = findJSONPathsByValue(value, soughtFor,+ curPath.copy() + [k])+ if newRes:+ pathVector.extend(newRes)+ elif isinstance(content, list):+ for id, item in enumerate(content):+ newPath = curPath.copy()+ newPath.append('[{}]'.format(id))+ newRes = findJSONPathsByValue(item, soughtFor,+ newPath)+ if newRes:+ pathVector.extend(newRes)+ else:+ if content == soughtFor:+ pathVector.append(curPath)+ return pathVector+++def findJSONPathsByKey(content, soughtFor, curPath:list=['$']):+ pathVector = []+ if isinstance(content, dict):+ for k, value in content.items():+ if k == soughtFor:+ pathVector.append(curPath)+ newRes = findJSONPathsByKey(value, soughtFor,+ curPath.copy() + [k])+ if newRes:+ pathVector.extend(newRes)+ elif isinstance(content, list):+ for id, item in enumerate(content):+ newPath = curPath.copy()+ newPath.append('[{}]'.format(id))+ newRes = findJSONPathsByKey(item, soughtFor,+ newPath)+ if newRes:+ pathVector.extend(newRes)+ else:+ pass+ return pathVector+++def multiplyCfgByKey(content):+ substVector = getSubstVectorByKey(content)+ pathVector = findJSONPathsByKey(content, mulKey)+ n = -1+ for v in substVector:+ if n != -1 and len(v) != n:+ raise Exception("Inconsistent multiplication keys: sizes differ")+ n = len(v)+ substNum = len(substVector)+ retList = []+ for _ in range(n):+ retList.append(deepCopyJSON(content))+ for substIdx in range(substNum):+ for cfgIdx in range(n):+ deepMapUpdate(retList[cfgIdx], pathVector[substIdx][1:],+ substVector[substIdx][cfgIdx])+ return retList+++def deepCopyJSON(obj):+ return json.loads(json.dumps(obj, sort_keys=True))+++def getSubstVectorByKey(content, soughtFor=mulKey):+ pathVector = findJSONPathsByKey(content, soughtFor)+ keyVector = []+ # populate configs+ def stepInto(jObj, item):+ try:+ idx = int(item[1:-1])+ if item[0] == '[' and item[-1] == ']':+ return jObj[idx]+ except ValueError:+ pass+ return jObj[item]+ for path in pathVector: # except root '$'+ curObj = content+ for item in path[1:]:+ curObj = stepInto(curObj, item)+ curObj = curObj[mulKey]+ if isinstance(curObj, list):+ keyVector.append(curObj)+ else:+ raise Exception("Wrong JSON type in multiplicaiton key")+ return keyVector++def applySubstitutionRules(cfg: map, rules: list, commit: str=None):# if commit is None or rule['type'] == 'static',# the rule is considered as static,@@ -691,7 +832,7 @@ def applySubstitutionRules(cfg: map, rules: list, commit: str=None):dstPos = formatJSON(dstPos,lambda content:- CfgManager.multistepStrFormat(+ CfgManager.singlestepStrFormat(content,rule["placeholder"],getMapValueByShortHash(srcPos, commit)\@@ -715,5 +856,11 @@ def deepMapUpdate(content: map, path: list, substitution):return substitutionelse:root = path.pop(0)+ if isinstance(content, list):+ try:+ root = int(root[1:-1])+ except TypeError:+ raise Exception("Wrong index {}".format(root))content[root] = deepMapUpdate(content[root], path, substitution)- return content\ No newline at end of file+ return content+\ No newline at end of filediff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py b/src/plugins/intel_cpu/tools/commit_slider/utils/modes.pyindex 45133e82915..4800d0854ae 100644--- a/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py+++ b/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py@@ -16,9 +16,12 @@ from utils.common_mode import Modeclass NopMode(Mode):# helpful with mode-ignorant traversal (brute force)def __init__(self, cfg):+ self.msg = "default"super().__init__(cfg)def checkCfg(self, cfg):+ if "msg" in cfg["runConfig"]:+ self.msg = cfg["runConfig"]["msg"]super().checkCfg(cfg)def getPseudoMetric(self, commit, cfg):@@ -32,6 +35,10 @@ class NopMode(Mode):commitLogger.info(checkOut)return+ def printResult(self):+ print(self.msg)+ self.outLogger.info(self.msg)+class CheckOutputMode(Mode):def __init__(self, cfg):@@ -474,6 +481,7 @@ class CompareBlobsMode(Mode):def createCash(self):# we use separate files instead of json cache,# so, we just set up path to cache folder+ # todo: handle usercache for multimodel caseself.cachePath = getActualPath("cachePath", self.cfg)pass