Skip to content

Commit de29b40

Browse files
authored
Merge pull request #581 from mlcommons/submission-generation-patch
Support for platform details in submission generation
2 parents 9f79f45 + f458fb0 commit de29b40

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

script/generate-mlperf-inference-submission/_cm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ input_mapping:
8383
submitter: CM_MLPERF_SUBMITTER
8484
sw_notes_extra: CM_MLPERF_SUT_SW_NOTES_EXTRA
8585
tar: CM_TAR_SUBMISSION_DIR
86+
get_platform_details: CM_GET_PLATFORM_DETAILS
8687
post_deps:
8788
- enable_if_env:
8889
CM_RUN_MLPERF_ACCURACY:

script/generate-mlperf-inference-submission/customize.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def generate_submission(env, state, inp, submission_division):
240240
compliance_path = os.path.join(path_submission, "compliance", sub_res)
241241
system_path = os.path.join(path_submission, "systems")
242242
submission_system_path = system_path
243+
243244
if not os.path.isdir(submission_system_path):
244245
os.makedirs(submission_system_path)
245246
system_file = os.path.join(submission_system_path, sub_res+".json")
@@ -273,6 +274,8 @@ def generate_submission(env, state, inp, submission_division):
273274

274275
print('* MLPerf inference model: {}'.format(model))
275276
for scenario in scenarios:
277+
# the system_info.txt is copied from the mode directory if found, else it would be looked under scenario directory
278+
system_info_from_mode = False
276279
results[model][scenario] = {}
277280
result_scenario_path = os.path.join(result_model_path, scenario)
278281
submission_scenario_path = os.path.join(submission_model_path, scenario)
@@ -429,6 +432,8 @@ def generate_submission(env, state, inp, submission_division):
429432
elif f in [ "README.md", "README-extra.md", "cm-version-info.json", "os_info.json", "cpu_info.json", "pip_freeze.json", "system_info.txt", "cm-deps.png", "cm-deps.mmd" ] and mode == "performance":
430433
shutil.copy(os.path.join(result_mode_path, f), os.path.join(submission_measurement_path, f))
431434
if f == "system_info.txt" and not platform_info_file:
435+
# the first found system_info.txt will be taken as platform info file for a specific model to be placed in
436+
# measurements-model folder when generating the final submission
432437
platform_info_file = os.path.join(result_mode_path, f)
433438
elif f in [ "console.out" ]:
434439
shutil.copy(os.path.join(result_mode_path, f), os.path.join(submission_measurement_path, mode+"_"+f))
@@ -445,6 +450,9 @@ def generate_submission(env, state, inp, submission_division):
445450
p_target = os.path.join(submission_results_path, f)
446451
shutil.copy(os.path.join(result_mode_path, f), p_target)
447452

453+
if os.path.exists(os.path.join(result_scenario_path, "system_info.txt")):
454+
shutil.copy(os.path.join(result_scenario_path, "system_info.txt"), os.path.join(submission_measurement_path, f))
455+
platform_info_file = os.path.join(result_scenario_path, "system_info.txt")
448456

449457
readme_file = os.path.join(submission_measurement_path, "README.md")
450458
if not os.path.exists(readme_file):
@@ -459,24 +467,39 @@ def generate_submission(env, state, inp, submission_division):
459467
with open(readme_file, mode='a') as f:
460468
f.write(result_string)
461469

462-
#Copy system_info.txt to the submission measurements model folder if any scenario performance run has it
470+
# Copy system_info.txt to the submission measurements model folder if any scenario performance run has it
463471
sys_info_file = None
472+
464473
if os.path.exists(os.path.join(result_model_path, "system_info.txt")):
465474
sys_info_file = os.path.join(result_model_path, "system_info.txt")
466475
elif platform_info_file:
467476
sys_info_file = platform_info_file
477+
468478
if sys_info_file:
469479
model_platform_info_file = sys_info_file
470480
shutil.copy(sys_info_file, os.path.join(measurement_model_path, "system_info.txt"))
471481

472482
#Copy system_info.txt to the submission measurements folder if any model performance run has it
473483
sys_info_file = None
484+
474485
if os.path.exists(os.path.join(result_path, "system_info.txt")):
475486
sys_info_file = os.path.join(result_path, "system_info.txt")
476487
elif model_platform_info_file:
477488
sys_info_file = model_platform_info_file
489+
478490
if sys_info_file:
479491
shutil.copy(sys_info_file, os.path.join(measurement_path, "system_info.txt"))
492+
else:
493+
if env.get('CM_GET_PLATFORM_DETAILS', '') == "yes":
494+
cm_input = {'action': 'run',
495+
'automation': 'script',
496+
'tags': 'get,platform,details',
497+
'env': {'CM_PLATFORM_DETAILS_FILE_PATH': os.path.join(measurement_path, "system_info.txt")},
498+
'quiet': True
499+
}
500+
r = cmind.access(cm_input)
501+
if r['return'] > 0:
502+
return r
480503

481504

482505
with open(system_file, "w") as fp:

0 commit comments

Comments
 (0)