Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
65 changes: 33 additions & 32 deletions loadgen/version_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def generate_loadgen_version_definitions_sha1(ofile, loadgen_root):
full_fn = loadgen_root + fn
if not os.path.isfile(full_fn):
continue
file_data = open(full_fn, "rb").read()
with open(full_fn, "rb") as f:
file_data = f.read()
sha1s += hashlib.sha1(file_data).hexdigest() + " " + fn + "\n"

ofile.write(func_def("Sha1OfFiles", make_raw_string(sha1s[0:-1])))
Expand All @@ -98,37 +99,37 @@ def generate_loadgen_version_definitions(cc_filename, loadgen_root):
except OSError as exc:
if exc.errno != errno.EEXIST:
raise
ofile = open(cc_filename, "w")
ofile.write("// DO NOT EDIT: Autogenerated by version_generator.py.\n\n")
ofile.write("#include <string>\n\n")
ofile.write("namespace mlperf {\n\n")
# Open and read the VERSION.txt file
with open(os.path.join(loadgen_root, "VERSION.txt"), "r") as version_file:
# Read and strip any extra whitespace/newlines
version_contents = version_file.read().strip()

# Write the version into the function definition
ofile.write(func_def("Version", f"\"{version_contents}\""))

date_time_now_local = datetime.datetime.now().isoformat()
date_time_now_utc = datetime.datetime.utcnow().isoformat()
ofile.write(func_def("BuildDateLocal", '"' + date_time_now_local + '"'))
ofile.write(func_def("BuildDateUtc", '"' + date_time_now_utc + '"'))

git_dir = '--git-dir="' + loadgen_root + '/../.git" '
git_work_tree = '--work-tree="' + loadgen_root + '/.." '
git_command = "git " + git_dir + git_work_tree
git_status = os.popen(git_command + "status")
git_status.read()
is_git_repo = git_status.close() is None
if is_git_repo:
generate_loadgen_version_definitions_git(ofile, git_command)
else:
generate_loadgen_verstion_definitions_git_stubs(ofile)
generate_loadgen_version_definitions_sha1(ofile, loadgen_root)

ofile.write("} // namespace mlperf\n")
ofile.close()

with open(cc_filename, "w") as ofile:
ofile.write("// DO NOT EDIT: Autogenerated by version_generator.py.\n\n")
ofile.write("#include <string>\n\n")
ofile.write("namespace mlperf {\n\n")
# Open and read the VERSION.txt file
with open(os.path.join(loadgen_root, "VERSION.txt"), "r") as version_file:
# Read and strip any extra whitespace/newlines
version_contents = version_file.read().strip()

# Write the version into the function definition
ofile.write(func_def("Version", f"\"{version_contents}\""))

date_time_now_local = datetime.datetime.now().isoformat()
date_time_now_utc = datetime.datetime.utcnow().isoformat()
ofile.write(func_def("BuildDateLocal", '"' + date_time_now_local + '"'))
ofile.write(func_def("BuildDateUtc", '"' + date_time_now_utc + '"'))

git_dir = '--git-dir="' + loadgen_root + '/../.git" '
git_work_tree = '--work-tree="' + loadgen_root + '/.." '
git_command = "git " + git_dir + git_work_tree
git_status = os.popen(git_command + "status")
git_status.read()
is_git_repo = git_status.close() is None
if is_git_repo:
generate_loadgen_version_definitions_git(ofile, git_command)
else:
generate_loadgen_verstion_definitions_git_stubs(ofile)
generate_loadgen_version_definitions_sha1(ofile, loadgen_root)

ofile.write("} // namespace mlperf\n")


def main():
Expand Down
2 changes: 1 addition & 1 deletion vision/medical_imaging/3d-unet-kits19/global_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
TARGET_CASES = json.load(f)
with open(CALIBRATION_CASE_FILE, "r") as f:
CALIB_CASES = json.load(f)

# constants used preprocessing images as well as sliding window inference
MEAN_VAL = 101.0
STDDEV_VAL = 76.9
Expand Down
Loading