Skip to content

Commit

Permalink
Fixes for MLPerf results table
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsuresh committed Feb 14, 2024
1 parent b67bcc2 commit 578d483
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
13 changes: 13 additions & 0 deletions cm-mlops/script/app-mlperf-inference/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ def postprocess(i):
shutil.copy(env['CM_MLPERF_USER_CONF'], 'user.conf')

result = mlperf_utils.get_result_from_log(env['CM_MLPERF_LAST_RELEASE'], model, scenario, output_dir, mode)
power = None
power_efficiency = None
if mode == performance:
result_split = result.split(",")
if len(result_split) > 2: #power results are there
power = result_split[1]
power_efficiency = result_split[2]

if not state.get('CM_MLPERF_RESULTS'):
state['CM_MLPERF_RESULTS'] = {}
if not state['CM_MLPERF_RESULTS'].get(state['CM_SUT_CONFIG_NAME']):
Expand All @@ -213,6 +221,11 @@ def postprocess(i):
if not state['CM_MLPERF_RESULTS'][state['CM_SUT_CONFIG_NAME']][model].get(scenario):
state['CM_MLPERF_RESULTS'][state['CM_SUT_CONFIG_NAME']][model][scenario] = {}
state['CM_MLPERF_RESULTS'][state['CM_SUT_CONFIG_NAME']][model][scenario][mode] = result
if power:
state['CM_MLPERF_RESULTS'][state['CM_SUT_CONFIG_NAME']][model][scenario]['power'] = power
if power_efficiency:
state['CM_MLPERF_RESULTS'][state['CM_SUT_CONFIG_NAME']][model][scenario]['power_efficiency'] = power_efficiency


# Record basic host info
host_info = {
Expand Down
18 changes: 11 additions & 7 deletions cm-mlops/script/get-mlperf-inference-utils/mlperf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ def get_result_from_log(version, model, scenario, result_path, mode):
result = ''
if mode == "performance":
has_power = os.path.exists(os.path.join(result_path, "power"))
result = str(checker.get_performance_metric(config, mlperf_model, result_path, scenario, None, None, has_power))
result_ = checker.get_performance_metric(config, mlperf_model, result_path, scenario, None, None, has_power)
result = str(round(result_, 3)
if has_power:
is_valid, power_metric, scenario, avg_power_efficiency = checker.get_power_metric(config, scenario, result_path, True, result)
result += f",{power_metric},{avg_power_efficiency*1000} "
is_valid, power_metric, scenario, avg_power_efficiency = checker.get_power_metric(config, scenario, result_path, True, result_)
result += f",{power_metric},{avg_power_efficiency}"


elif mode == "accuracy" and os.path.exists(os.path.join(result_path, 'accuracy.txt')):

Expand All @@ -32,9 +34,10 @@ def get_result_from_log(version, model, scenario, result_path, mode):
result = str(round(float(acc_results[acc]), 5))
else:
result = '('
result_list = []
for i, acc in enumerate(acc_results):
result += str(round(float(acc_results[acc]), 5))
result += ")"
result_list.append(str(round(float(acc_results[acc]), 5)))
result += ", ".join(result_list) + ")"

return result

Expand Down Expand Up @@ -129,7 +132,7 @@ def get_result_string(version, model, scenario, result_path, has_power, sub_res)
performance_result_ = performance_result / 1000000 #convert to milliseconds
else:
performance_result_ = performance_result
result['performance'] = performance_result_
result['performance'] = round(performance_result_, 3)

if scenario != effective_scenario:
inferred, inferred_result = checker.get_inferred_result(scenario, effective_scenario, performance_result, mlperf_log, config, False)
Expand Down Expand Up @@ -170,7 +173,7 @@ def get_result_string(version, model, scenario, result_path, has_power, sub_res)
if len(accuracy_results) == 1:
accuracy_result = accuracy_results[0]
else:
accuracy_result = "(" + ",".join(accuracy_results)+")"
accuracy_result = "(" + ", ".join(accuracy_results)+")"
result['accuracy'] = accuracy_result

result_string = f"\n\n## Results\n"
Expand Down Expand Up @@ -217,4 +220,5 @@ def get_result_table(results):
if results[model][scenario].get('power_efficiency','') != '':
row.append(results[model][scenario]['power_efficiency'])
table.append(row)

return table, headers

0 comments on commit 578d483

Please sign in to comment.