Skip to content

Commit

Permalink
looks for file with precendence
Browse files Browse the repository at this point in the history
  • Loading branch information
anandhu-eng committed Nov 22, 2024
1 parent 1081135 commit f9db49a
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions script/generate-mlperf-inference-submission/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import json
import shutil
import cmind
import cmind
import sys
from tabulate import tabulate
import mlperf_utils
Expand Down Expand Up @@ -239,22 +239,6 @@ def generate_submission(env, state, inp, submission_division):
system_path = os.path.join(path_submission, "systems")
submission_system_path = system_path

if not os.path.isdir(measurement_path):
os.makedirs(measurement_path)

if env.get('CM_GET_PLATFORM_DETAILS', '') == "yes":
cm_input = {'action': 'run',
'automation': 'script',
'tags': 'get,platform,details',
'adr': '',
'print_deps': True,
'env': {'CM_PLATFORM_DETAILS_FILE_PATH':f"{measurement_path}/system_info.txt"},
'quiet': True
}
r = cmind.access(cm_input)
if r['return'] > 0:
return r

if not os.path.isdir(submission_system_path):
os.makedirs(submission_system_path)
system_file = os.path.join(submission_system_path, sub_res+".json")
Expand Down Expand Up @@ -288,6 +272,8 @@ def generate_submission(env, state, inp, submission_division):

print('* MLPerf inference model: {}'.format(model))
for scenario in scenarios:
# the system_info.txt is copied from the mode directory if found, else it would be looked under scenario directory
system_info_from_mode = False
results[model][scenario] = {}
result_scenario_path = os.path.join(result_model_path, scenario)
submission_scenario_path = os.path.join(submission_model_path, scenario)
Expand Down Expand Up @@ -424,7 +410,11 @@ def generate_submission(env, state, inp, submission_division):
files.append(f)
elif f in [ "README.md", "README-extra.md", "cm-version-info.json", "os_info.json", "cpu_info.json", "pip_freeze.json", "system_info.txt" ] and mode == "performance":
shutil.copy(os.path.join(result_mode_path, f), os.path.join(submission_measurement_path, f))
if f == "system_info.txt":
system_info_from_mode = True
if f == "system_info.txt" and not platform_info_file:
# the first system_info.txt would be taken as platform info file for a specific model to be placed in
# measurements-model folder when generating the final submission
platform_info_file = os.path.join(result_mode_path, f)
elif f in [ "console.out" ]:
shutil.copy(os.path.join(result_mode_path, f), os.path.join(submission_measurement_path, mode+"_"+f))
Expand All @@ -441,6 +431,10 @@ def generate_submission(env, state, inp, submission_division):
p_target = os.path.join(submission_results_path, f)
shutil.copy(os.path.join(result_mode_path, f), p_target)

if os.path.exists(os.path.join(result_scenario_path, "system_info.txt")) and not system_info_from_mode:
shutil.copy(os.path.join(result_scenario_path, "system_info.txt"), os.path.join(submission_measurement_path, f))
if not platform_info_file:
platform_info_file = os.path.join(result_scenario_path, "system_info.txt")

readme_file = os.path.join(submission_measurement_path, "README.md")
if not os.path.exists(readme_file):
Expand All @@ -455,24 +449,39 @@ def generate_submission(env, state, inp, submission_division):
with open(readme_file, mode='a') as f:
f.write(result_string)

#Copy system_info.txt to the submission measurements model folder if any scenario performance run has it
# Copy system_info.txt to the submission measurements model folder if any scenario performance run has it
sys_info_file = None
if os.path.exists(os.path.join(result_model_path, "system_info.txt")):
sys_info_file = os.path.join(result_model_path, "system_info.txt")
elif platform_info_file:
if platform_info_file:
sys_info_file = platform_info_file
elif os.path.exists(os.path.join(result_model_path, "system_info.txt")):
sys_info_file = os.path.join(result_model_path, "system_info.txt")

if sys_info_file:
model_platform_info_file = sys_info_file
# The first system_info file found would also be taken as the one for copying to SUT folder
if not model_platform_info_file:
model_platform_info_file = sys_info_file
shutil.copy(sys_info_file, os.path.join(measurement_model_path, "system_info.txt"))

#Copy system_info.txt to the submission measurements folder if any model performance run has it
sys_info_file = None
if os.path.exists(os.path.join(result_path, "system_info.txt")):
sys_info_file = os.path.join(result_path, "system_info.txt")
elif model_platform_info_file:
if model_platform_info_file:
sys_info_file = model_platform_info_file
elif os.path.exists(os.path.join(result_path, "system_info.txt")):
sys_info_file = os.path.join(result_path, "system_info.txt")

if sys_info_file:
shutil.copy(sys_info_file, os.path.join(measurement_path, "system_info.txt"))
else:
if env.get('CM_GET_PLATFORM_DETAILS', '') == "yes":
cm_input = {'action': 'run',
'automation': 'script',
'tags': 'get,platform,details',
'env': {'CM_PLATFORM_DETAILS_FILE_PATH': os.path.join(measurement_path, "system_info.txt")},
'quiet': True
}
r = cmind.access(cm_input)
if r['return'] > 0:
return r


with open(system_file, "w") as fp:
Expand Down

0 comments on commit f9db49a

Please sign in to comment.