Skip to content

Path string fix #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions script/app-mlperf-inference/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ def postprocess(i):

if mode == "accuracy" or mode == "compliance" and env[
'MLC_MLPERF_LOADGEN_COMPLIANCE_TEST'] == "TEST01":
out_baseline_accuracy_string = f"""> {os.path.join(output_dir, "accuracy", "baseline_accuracy.txt")} """
out_compliance_accuracy_string = f"""> {os.path.join(output_dir, "accuracy", "compliance_accuracy.txt")} """
out_baseline_accuracy_string = f"""> '{os.path.join(output_dir, "accuracy", "baseline_accuracy.txt")}' """
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @anandhu-eng we need to use a variable for adding quote as we should use ' for Unix shell and " for Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arjunsuresh , yes that's correct. Also are you aware whether the following works in windows:

python3 "/some/path/try.py"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in one of our GH actions we can export MLC_REPOS to a path containing space and test it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made the changes in resnet50 closed division itself so that we could test even the compliance also. But for that, this PR needs to be merged to trigger the workflow.

out_compliance_accuracy_string = f"""> '{os.path.join(output_dir, "accuracy", "compliance_accuracy.txt")}' """
if model == "resnet50":
accuracy_filename = "accuracy-imagenet.py"
accuracy_filepath = os.path.join(env['MLC_MLPERF_INFERENCE_CLASSIFICATION_AND_DETECTION_PATH'], "tools",
accuracy_filename)
dataset_args = " --imagenet-val-file " + \
os.path.join(env['MLC_DATASET_AUX_PATH'], "val.txt")
dataset_args = " --imagenet-val-file '" + \
os.path.join(env['MLC_DATASET_AUX_PATH'], "val.txt") + "' "
accuracy_log_file_option_name = " --mlperf-accuracy-file "
datatype_option = " --dtype " + env['MLC_IMAGENET_ACCURACY_DTYPE']

Expand All @@ -141,8 +141,8 @@ def postprocess(i):
accuracy_filename = "accuracy-openimages.py"
accuracy_filepath = os.path.join(env['MLC_MLPERF_INFERENCE_CLASSIFICATION_AND_DETECTION_PATH'], "tools",
accuracy_filename)
dataset_args = " --openimages-dir " + \
os.getcwd() # just to make the script happy
dataset_args = " --openimages-dir '" + \
os.getcwd() + "' " # just to make the script happy
accuracy_log_file_option_name = " --mlperf-accuracy-file "
datatype_option = ""

Expand All @@ -165,8 +165,8 @@ def postprocess(i):
env['MLC_DATASET_IGBH_SIZE'] + "'"
accuracy_log_file_option_name = " --mlperf-accuracy-file "
datatype_option = ""
out_baseline_accuracy_string = f""" --output-file {os.path.join(output_dir, "accuracy", "baseline_accuracy.txt")} """
out_compliance_accuracy_string = f""" --output-file {os.path.join(output_dir, "accuracy", "compliance_accuracy.txt")} """
out_baseline_accuracy_string = f""" --output-file '{os.path.join(output_dir, "accuracy", "baseline_accuracy.txt")}' """
out_compliance_accuracy_string = f""" --output-file '{os.path.join(output_dir, "accuracy", "compliance_accuracy.txt")}' """

elif 'stable-diffusion-xl' in model:
pass # No compliance check for now
Expand Down Expand Up @@ -499,9 +499,9 @@ def postprocess(i):
test,
"run_verification.py")
if test == "TEST06":
cmd = f"{env['MLC_PYTHON_BIN_WITH_PATH']} {SCRIPT_PATH} -c {COMPLIANCE_DIR} -o {OUTPUT_DIR} --scenario {scenario} --dtype int32"
cmd = f"{env['MLC_PYTHON_BIN_WITH_PATH']} '{SCRIPT_PATH}' -c '{COMPLIANCE_DIR}' -o '{OUTPUT_DIR}' --scenario {scenario} --dtype int32"
else:
cmd = f"{env['MLC_PYTHON_BIN_WITH_PATH']} {SCRIPT_PATH} -r {RESULT_DIR} -c {COMPLIANCE_DIR} -o {OUTPUT_DIR}"
cmd = f"{env['MLC_PYTHON_BIN_WITH_PATH']} '{SCRIPT_PATH}' -r '{RESULT_DIR}' -c '{COMPLIANCE_DIR}' -o '{OUTPUT_DIR}'"

print(cmd)
os.system(cmd)
Expand All @@ -524,8 +524,8 @@ def postprocess(i):
return {
'return': 1, 'error': 'TEST01 needs accuracy run to be completed first'}

cmd = "cd " + TEST01_DIR + " && bash " + SCRIPT_PATH + " " + os.path.join(ACCURACY_DIR, "mlperf_log_accuracy.json") + " " + \
os.path.join(COMPLIANCE_DIR, "mlperf_log_accuracy.json")
cmd = "cd '" + TEST01_DIR + "' && bash '" + SCRIPT_PATH + "' '" + os.path.join(ACCURACY_DIR, "mlperf_log_accuracy.json") + "' '" + \
os.path.join(COMPLIANCE_DIR, "mlperf_log_accuracy.json") + "' "
env['CMD'] = cmd
print(cmd)
r = automation.run_native_script(
Expand All @@ -544,8 +544,8 @@ def postprocess(i):

baseline_accuracy_file = os.path.join(
TEST01_DIR, "mlperf_log_accuracy_baseline.json")
CMD = "cd " + ACCURACY_DIR + " && " + env['MLC_PYTHON_BIN_WITH_PATH'] + ' ' + accuracy_filepath + accuracy_log_file_option_name + \
baseline_accuracy_file + ' ' + dataset_args + \
CMD = "cd '" + ACCURACY_DIR + "' && '" + env['MLC_PYTHON_BIN_WITH_PATH'] + "' '" + accuracy_filepath + "' " + accuracy_log_file_option_name + " '" + \
baseline_accuracy_file + "' " + dataset_args + \
datatype_option + out_baseline_accuracy_string

env['CMD'] = CMD
Expand All @@ -558,8 +558,8 @@ def postprocess(i):
return {'return': 1,
'error': f"{baseline_accuracy_file} is empty"}

CMD = "cd " + ACCURACY_DIR + " && " + env['MLC_PYTHON_BIN_WITH_PATH'] + ' ' + accuracy_filepath + accuracy_log_file_option_name + \
os.path.join(TEST01_DIR, "mlperf_log_accuracy.json") + \
CMD = "cd '" + ACCURACY_DIR + "' && '" + env['MLC_PYTHON_BIN_WITH_PATH'] + "' '" + accuracy_filepath + "' " + accuracy_log_file_option_name + " '" +\
os.path.join(TEST01_DIR, "mlperf_log_accuracy.json") + "' " + \
dataset_args + datatype_option + out_compliance_accuracy_string

env['CMD'] = CMD
Expand Down
Loading