Skip to content

Commit e223efe

Browse files
authored
Merge branch 'master' into anandhu-eng-patch-4
2 parents aba0857 + 6776245 commit e223efe

File tree

27 files changed

+242
-173
lines changed

27 files changed

+242
-173
lines changed

automotive/3d-object-detection/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,23 @@ You can also do `pip install mlc-scripts` and then use `mlcr` commands for downl
1818
> By default, the waymo dataset is downloaded from the mlcommons official drive. One has to accept the [MLCommons Waymo Open Dataset EULA](https://waymo.mlcommons.org/) to access the dataset files.
1919
2020
```
21-
mlcr get,ml-model,pointpainting --outdirname=<path_to_download> -j
21+
mlcr get,ml-model,pointpainting,_r2-downloader,_mlc --outdirname=<path_to_download> -j
2222
```
2323

2424
### Download dataset through MLCFlow Automation
2525

2626
> [!Note]
2727
> By default, the waymo dataset is downloaded from the mlcommons official drive. One has to accept the [MLCommons Waymo Open Dataset EULA](https://waymo.mlcommons.org/) to access the dataset files.
2828
29+
**Includes validation and calibration dataset**
2930
```
30-
mlcr get,dataset,waymo --outdirname=<path_to_download> -j
31+
mlcr get,dataset,waymo,_r2-downloader,_mlc --outdirname=<path_to_download> -j
32+
```
33+
34+
**Includes only calibration dataset**
35+
36+
```
37+
mlcr get,dataset,waymo,calibration,_r2-downloader,_mlc --outdirname=<path_to_download> -j
3138
```
3239

3340
## Downloading the dataset and model checkpoints
@@ -106,4 +113,4 @@ python accuracy_waymo.py --mlperf-accuracy-file <path to accuracy file>/mlperf_l
106113

107114
## Automated command for submission generation via MLCFlow
108115

109-
Please see the [new docs site](https://docs.mlcommons.org/inference/submission/) for an automated way to generate submission through MLCFlow.
116+
Please see the [new docs site](https://docs.mlcommons.org/inference/submission/) for an automated way to generate submission through MLCFlow.

compliance/TEST01/run_verification.py

Lines changed: 60 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -76,51 +76,68 @@ def main():
7676
output_dir = os.path.join(args.output_dir, "TEST01")
7777
unixmode = ""
7878
if args.unixmode:
79-
unixmode = " --unixmode"
80-
for binary in ["wc", "md5sum", "grep", "awk", "sed", "head", "tail"]:
79+
if os.name != "posix":
80+
print(
81+
"Warning: --unixmode not supported on this OS. Using Python fallback...")
82+
unixmode = ""
83+
else:
84+
unixmode = " --unixmode"
8185
missing_binary = False
82-
if shutil.which(binary) is None:
83-
print(
84-
"Error: This script requires the {:} commandline utility".format(
85-
binary
86+
for binary in ["wc", "md5sum", "grep",
87+
"awk", "sed", "head", "tail"]:
88+
if shutil.which(binary) is None:
89+
print(
90+
"Error: This script requires the {:} commandline utility".format(
91+
binary
92+
)
8693
)
87-
)
88-
missing_binary = True
89-
if missing_binary:
90-
exit()
94+
missing_binary = True
95+
if missing_binary:
96+
exit()
9197

9298
dtype = args.dtype
9399

94100
verify_accuracy_binary = os.path.join(
95101
os.path.dirname(__file__), "verify_accuracy.py"
96102
)
103+
104+
unixmode_str = unixmode if unixmode == "" else unixmode + " "
105+
97106
# run verify accuracy
98107
verify_accuracy_command = (
99-
"python3 "
108+
sys.executable + " "
100109
+ verify_accuracy_binary
101110
+ " --dtype "
102111
+ args.dtype
103-
+ unixmode
112+
+ unixmode_str
104113
+ " -r "
105-
+ results_dir
106-
+ "/accuracy/mlperf_log_accuracy.json"
114+
+ os.path.join(results_dir, "accuracy", "mlperf_log_accuracy.json")
107115
+ " -t "
108-
+ compliance_dir
109-
+ "/mlperf_log_accuracy.json | tee verify_accuracy.txt"
116+
+ os.path.join(compliance_dir, "mlperf_log_accuracy.json")
110117
)
111118
try:
112-
os.system(verify_accuracy_command)
119+
with open("verify_accuracy.txt", "w") as f:
120+
process = subprocess.Popen(
121+
verify_accuracy_command,
122+
stdout=subprocess.PIPE,
123+
stderr=subprocess.STDOUT,
124+
shell=True,
125+
text=True
126+
)
127+
# Write output to both console and file
128+
for line in process.stdout:
129+
print(line, end="")
130+
f.write(line)
131+
process.wait()
113132
except Exception:
114133
print(
115134
"Exception occurred trying to execute:\n " +
116135
verify_accuracy_command)
117136
# check if verify accuracy script passes
118137

119-
accuracy_pass_command = "grep PASS verify_accuracy.txt"
120138
try:
121-
accuracy_pass = "TEST PASS" in subprocess.check_output(
122-
accuracy_pass_command, shell=True
123-
).decode("utf-8")
139+
with open("verify_accuracy.txt", "r") as file:
140+
accuracy_pass = "TEST PASS" in file.read()
124141
except Exception:
125142
accuracy_pass = False
126143

@@ -129,28 +146,38 @@ def main():
129146
os.path.dirname(__file__), "verify_performance.py"
130147
)
131148
verify_performance_command = (
132-
"python3 "
149+
sys.executable + " "
133150
+ verify_performance_binary
134-
+ " -r "
135-
+ results_dir
136-
+ "/performance/run_1/mlperf_log_detail.txt"
137-
+ " -t "
138-
+ compliance_dir
139-
+ "/mlperf_log_detail.txt | tee verify_performance.txt"
151+
+ " -r"
152+
+ os.path.join(results_dir, "performance",
153+
"run_1", "mlperf_log_detail.txt")
154+
+ " -t"
155+
+ os.path.join(compliance_dir, "mlperf_log_detail.txt")
140156
)
157+
141158
try:
142-
os.system(verify_performance_command)
159+
with open("verify_performance.txt", "w") as f:
160+
process = subprocess.Popen(
161+
verify_performance_command,
162+
stdout=subprocess.PIPE,
163+
stderr=subprocess.STDOUT,
164+
text=True,
165+
shell=True,
166+
)
167+
# Write output to both console and file
168+
for line in process.stdout:
169+
print(line, end="")
170+
f.write(line)
171+
process.wait()
143172
except Exception:
144173
print(
145174
"Exception occurred trying to execute:\n " +
146175
verify_performance_command)
147176

148177
# check if verify performance script passes
149-
performance_pass_command = "grep PASS verify_performance.txt"
150178
try:
151-
performance_pass = "TEST PASS" in subprocess.check_output(
152-
performance_pass_command, shell=True
153-
).decode("utf-8")
179+
with open("verify_performance.txt", "r") as file:
180+
performance_pass = "TEST PASS" in file.read()
154181
except Exception:
155182
performance_pass = False
156183

compliance/TEST01/verify_accuracy.py

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import subprocess
2121
import sys
2222
import shutil
23+
import hashlib
24+
import re
2325

2426
sys.path.append(os.getcwd())
2527

@@ -161,15 +163,11 @@ def main():
161163
print("Error: This script requires Python v3.3 or later")
162164
exit()
163165

164-
get_perf_lines_cmd = "wc -l " + perf_log + "| awk '{print $1}'"
165-
num_perf_lines = int(
166-
subprocess.check_output(get_perf_lines_cmd, shell=True).decode("utf-8")
167-
)
166+
with open(perf_log, "r") as file:
167+
num_perf_lines = sum(1 for _ in file)
168168

169-
get_acc_lines_cmd = "wc -l " + acc_log + "| awk '{print $1}'"
170-
num_acc_lines = int(
171-
subprocess.check_output(get_acc_lines_cmd, shell=True).decode("utf-8")
172-
)
169+
with open(acc_log, "r") as file:
170+
num_acc_lines = sum(1 for _ in file)
173171

174172
num_acc_log_entries = num_acc_lines - 2
175173
num_perf_log_entries = num_perf_lines - 2
@@ -189,42 +187,38 @@ def main():
189187
continue
190188

191189
# calculate md5sum of line in perf mode accuracy_log
192-
perf_md5sum_cmd = (
193-
"head -n "
194-
+ str(perf_line + 1)
195-
+ " "
196-
+ perf_log
197-
+ "| tail -n 1| sed -r 's/,//g' | sed -r 's/\"seq_id\" : \\S+//g' | md5sum"
198-
)
199-
# print(perf_md5sum_cmd)
200-
perf_md5sum = subprocess.check_output(perf_md5sum_cmd, shell=True).decode(
201-
"utf-8"
202-
)
203-
204-
# get qsl idx
205-
get_qsl_idx_cmd = (
206-
"head -n "
207-
+ str(perf_line + 1)
208-
+ " "
209-
+ perf_log
210-
+ "| tail -n 1| awk -F\": |,\" '{print $4}'"
211-
)
212-
qsl_idx = (
213-
subprocess.check_output(get_qsl_idx_cmd, shell=True)
214-
.decode("utf-8")
215-
.rstrip()
216-
)
190+
# read the specific line
191+
with open(perf_log, "r") as f:
192+
for i, line in enumerate(f):
193+
if i == perf_line:
194+
line_content = line.strip()
195+
break
196+
197+
# remove commas and remove 'seq_id' key-value
198+
clean_line = line_content.replace(",", "")
199+
clean_line = re.sub(r'"seq_id"\s*:\s*\S+', '', clean_line)
200+
201+
# calculate md5sum
202+
perf_md5sum = hashlib.md5(clean_line.encode("utf-8")).hexdigest()
203+
204+
# extract qsl idx
205+
fields = re.split(r": |,", line_content)
206+
qsl_idx = fields[3].strip()
217207

218208
# calculate md5sum of line in acc mode accuracy_log
219-
acc_md5sum_cmd = (
220-
'grep "qsl_idx\\" : '
221-
+ qsl_idx
222-
+ '," '
223-
+ acc_log
224-
+ "| sed -r 's/,//g' | sed -r 's/\"seq_id\" : \\S+//g' | md5sum"
225-
)
226-
acc_md5sum = subprocess.check_output(
227-
acc_md5sum_cmd, shell=True).decode("utf-8")
209+
acc_matches = []
210+
with open(acc_log, "r") as f:
211+
for line in f:
212+
if f'"qsl_idx" : {qsl_idx},' in line:
213+
acc_matches.append(line.strip())
214+
215+
# join all matching lines together
216+
acc_line = "\n".join(acc_matches)
217+
218+
acc_line = acc_line.replace(",", "")
219+
acc_line = re.sub(r'"seq_id"\s*:\s*\S+', '', acc_line)
220+
221+
acc_md5sum = hashlib.md5(acc_line.encode("utf-8")).hexdigest()
228222

229223
if perf_md5sum != acc_md5sum:
230224
num_perf_log_data_mismatch += 1

compliance/TEST04/run_verification.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,38 @@ def main():
5858
os.path.dirname(__file__), "verify_performance.py"
5959
)
6060
verify_performance_command = (
61-
"python3 "
61+
sys.executable + " "
6262
+ verify_performance_binary
63-
+ " -r "
64-
+ results_dir
65-
+ "/performance/run_1/mlperf_log_summary.txt"
66-
+ " -t "
67-
+ compliance_dir
68-
+ "/mlperf_log_summary.txt | tee verify_performance.txt"
63+
+ " -r"
64+
+ os.path.join(results_dir, "performance",
65+
"run_1", "mlperf_log_summary.txt")
66+
+ " -t"
67+
+ os.path.join(compliance_dir, "mlperf_log_summary.txt")
6968
)
69+
7070
try:
71-
os.system(verify_performance_command)
71+
with open("verify_performance.txt", "w") as f:
72+
process = subprocess.Popen(
73+
verify_performance_command,
74+
stdout=subprocess.PIPE, # capture output
75+
stderr=subprocess.STDOUT,
76+
text=True, # decode output as text
77+
shell=True,
78+
)
79+
# Write output to both console and file
80+
for line in process.stdout:
81+
print(line, end="") # console
82+
f.write(line) # file
83+
process.wait()
7284
except Exception:
7385
print(
7486
"Exception occurred trying to execute:\n " +
7587
verify_performance_command)
7688

7789
# check if verify performance script passes
78-
performance_pass_command = "grep PASS verify_performance.txt"
7990
try:
80-
performance_pass = "TEST PASS" in subprocess.check_output(
81-
performance_pass_command, shell=True
82-
).decode("utf-8")
91+
with open("verify_performance.txt", "r") as file:
92+
performance_pass = "TEST PASS" in file.read()
8393
except Exception:
8494
performance_pass = False
8595

docs/benchmarks/automotive/3d_object_detection/get-pointpainting-data.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ The benchmark implementation run command will automatically download the preproc
1313

1414
=== "Validation"
1515

16-
### Get Validation Dataset
16+
### Get Validation and Calibration Dataset
1717
```
18-
mlcr get,dataset,waymo -j
18+
mlcr get,dataset,waymo,_r2-downloader,_mlc -j
1919
```
2020

2121
=== "Calibration"
2222

23-
### Get Calibration Dataset
23+
### Get Calibration Dataset only
2424
```
25-
mlcr get,dataset,waymo,calibration -j
25+
mlcr get,dataset,waymo,calibration,_r2-downloader,_mlc -j
2626
```
2727

2828
- `--outdirname=<PATH_TO_DOWNLOAD_WAYMO_DATASET>` could be provided to download the dataset to a specific location.
@@ -33,7 +33,7 @@ The benchmark implementation run command will automatically download the preproc
3333
The benchmark implementation run command will automatically download the model. In case you want to download only the PointPainting model, you can use the below command.
3434

3535
```bash
36-
mlcr get,ml-model,pointpainting -j
36+
mlcr get,ml-model,pointpainting,_r2-downloader,_mlc -j
3737
```
3838

3939
- `--outdirname=<PATH_TO_DOWNLOAD_POINTPAINTING_MODEL>` could be provided to download the model files to a specific location.

docs/benchmarks/graph/get-rgat-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Get the Official MLPerf R-GAT Model
4646

4747
### PyTorch
4848
```
49-
mlcr get,ml-model,rgat -j
49+
mlcr get,ml-model,rgat,_r2-downloader,_mlcommons -j
5050
```
5151

5252
- `--outdirname=<PATH_TO_DOWNLOAD_RGAT_MODEL>` could be provided to download the model to a specific location.

docs/benchmarks/image_classification/get-resnet50-data.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The benchmark implementation run command will automatically download the validat
1515

1616
### Get Validation Dataset
1717
```
18-
mlcr get,dataset,imagenet,validation -j
18+
mlcr get,dataset,imagenet,validation,_full -j
1919
```
2020
=== "Calibration"
2121
ResNet50 calibration dataset consist of 500 images selected from the Imagenet 2012 validation dataset. There are 2 alternative options for the calibration dataset.
@@ -32,7 +32,7 @@ The benchmark implementation run command will automatically download the validat
3232
### Get ResNet50 preprocessed dataset
3333

3434
```
35-
mlcr get,dataset,image-classification,imagenet,preprocessed,_pytorch -j
35+
mlcr get,dataset,image-classification,imagenet,preprocessed,_pytorch,_full-j
3636
```
3737

3838
- `--outdirname=<PATH_TO_DOWNLOAD_IMAGENET_DATASET>` could be provided to download the dataset to a specific location.
@@ -52,7 +52,7 @@ Get the Official MLPerf ResNet50 Model
5252

5353
### Onnx
5454
```
55-
mlcr get,ml-model,resnet50,_onnx -j
55+
mlcr get,ml-model,resnet50,image-classification,_onnx -j
5656
```
5757

5858
- `--outdirname=<PATH_TO_DOWNLOAD_RESNET50_MODEL>` could be provided to download the model to a specific location.

0 commit comments

Comments
 (0)