Skip to content

Commit

Permalink
Update google benchmark to 1.8.3. (#19734)
Browse files Browse the repository at this point in the history
Update google benchmark to 1.8.3.
Update deps_update_and_upload.py script to make it easier to use.
  • Loading branch information
edgchen1 authored Mar 1, 2024
1 parent ed550b5 commit 5672cde
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cgmanifests/generated/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "361e8d1cfe0c6c36d30b39f1b61302ece5507320",
"commitHash": "344117638c8ff7e239044fd0fa7085839fc03021",
"repositoryUrl": "https://github.com/google/benchmark.git"
},
"comments": "google_benchmark"
Expand Down
2 changes: 1 addition & 1 deletion cmake/deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ eigen;https://gitlab.com/libeigen/eigen/-/archive/e7248b26a1ed53fa030c5c459f7ea0
flatbuffers;https://github.com/google/flatbuffers/archive/refs/tags/v1.12.0.zip;ba0a75fd12dbef8f6557a74e611b7a3d0c5fe7bf
fp16;https://github.com/Maratyszcza/FP16/archive/0a92994d729ff76a58f692d3028ca1b64b145d91.zip;b985f6985a05a1c03ff1bb71190f66d8f98a1494
fxdiv;https://github.com/Maratyszcza/FXdiv/archive/63058eff77e11aa15bf531df5dd34395ec3017c8.zip;a5658f4036402dbca7cebee32be57fb8149811e1
google_benchmark;https://github.com/google/benchmark/archive/refs/tags/v1.7.0.zip;e97c368b176e8614e3f1bf13dd9abcf6a7ad9908
google_benchmark;https://github.com/google/benchmark/archive/refs/tags/v1.8.3.zip;bf9870756ee3f8d2d3b346b24ee3600a41c74d3d
google_nsync;https://github.com/google/nsync/archive/refs/tags/1.26.0.zip;5e7c00ef6bf5b787386fc040067903ec774e2752
googletest;https://github.com/google/googletest/archive/530d5c8c84abd2a46f38583ee817743c9b3a42b4.zip;5e3a61db2aa975cfd0f97ba92c818744e7fa7034
googlexnnpack;https://github.com/google/XNNPACK/archive/0da379fc4808f9601faef392352018c741c0f297.zip;663883491e380b628e0a5b162b5f2658032fae73
Expand Down
135 changes: 94 additions & 41 deletions cmake/deps_update_and_upload.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,109 @@
# in case deps.txt is updated, run this file to update and upload the dependencies so that CI can use them.
# Before running the script, increase the version number found at:
# If deps.txt is updated, run this file to update and upload the dependencies so that CI can use them.
#
# Before running the script, find the latest version number at:
# https://aiinfra.visualstudio.com/Lotus/_artifacts/feed/Lotus/UPack/onnxruntime_build_dependencies/versions
# Increment it to obtain a new version number to use.
#
# Run without --do-upload once to verify downloading. Use --do-upload when you are ready to publish.
# python cmake/deps_update_and_upload.py --root-path C:/temp/onnxruntime_deps --version 1.0.82 --do-upload
# update version number in tools\ci_build\github\azure-pipelines\templates\download-deps.yml
# E.g.:
# python cmake/deps_update_and_upload.py --root-path C:/temp/onnxruntime_deps --version 1.0.82
# # check contents of C:/temp/onnxruntime_deps
# python cmake/deps_update_and_upload.py --root-path C:/temp/onnxruntime_deps --version 1.0.82 --no-download --do-upload
#
# Next, update the version number in tools/ci_build/github/azure-pipelines/templates/download-deps.yml.

import argparse
import contextlib
import pathlib
import re
import subprocess
import os
import argparse
import tempfile

script_dir = pathlib.Path(__file__).parent

parser = argparse.ArgumentParser(description="Update dependencies and publish to Azure Artifacts")
parser.add_argument(
"--root-path", type=str, default=tempfile.gettempdir(), help="Target root path for downloaded files"
"--root-path",
type=pathlib.Path,
help="Target root path for downloaded files. If not provided, a temporary directory is used.",
)
parser.add_argument(
"--version",
type=str,
help="Package version to publish",
)
parser.add_argument(
"--do-upload",
action="store_true",
dest="upload",
help="Upload the package to Azure Artifacts",
)
parser.add_argument(
"--no-download",
action="store_false",
dest="download",
help="Skip downloading the dependency files. "
"Use with '--do-upload' and '--root-path' to upload the package from existing dependency files.",
)
parser.add_argument("--version", type=str, default="1.0.82", help="Package version to publish")
parser.add_argument("--do-upload", action="store_true", help="Upload the package to Azure Artifacts")
args = parser.parse_args()

with open("cmake/deps.txt") as file:
if args.upload:
assert args.version is not None, "'--version' must be specified if uploading."

if args.upload != args.download:
assert args.root_path is not None, "'--root-path' must be specified if only downloading or uploading."

deps_path = script_dir / "deps.txt"
with open(deps_path) as file:
text = file.read()

lines = [line for line in text.split("\n") if not line.startswith("#") and ";" in line]

root_path = args.root_path

for line in lines:
url = re.sub("^[^;]+?;https://([^;]+?);.*", r"https://\1", line)
filename = re.sub("^[^;]+?;https://([^;]+?);.*", r"\1", line)
full_path = os.path.join(root_path, filename)
subprocess.run(["curl", "-sSL", "--create-dirs", "-o", full_path, url]) # noqa: PLW1510

package_name = "onnxruntime_build_dependencies"
version = args.version

# Check if the user is logged in to Azure
result = subprocess.run("az account show", shell=True, capture_output=True, text=True) # noqa: PLW1510
if "No subscriptions found" in result.stderr:
# Prompt the user to log in to Azure
print("You are not logged in to Azure. Please log in to continue.")
subprocess.run("az login", shell=True) # noqa: PLW1510

# Publish the package to Azure Artifacts if --no-upload is not specified

cmd = f'az artifacts universal publish --organization https://dev.azure.com/onnxruntime --feed onnxruntime --name {package_name} --version {version} --description "onnxruntime build time dependencies" --path {root_path}'
if args.do_upload:
subprocess.run(cmd, shell=True) # noqa: PLW1510
else:
print("would have run: " + cmd)

cmd = f'az artifacts universal publish --organization https://dev.azure.com/aiinfra --feed Lotus --name {package_name} --version {version} --description "onnxruntime build time dependencies" --path {root_path}'
if args.do_upload:
subprocess.run(cmd, shell=True) # noqa: PLW1510
else:
print("would have run: " + cmd)
with contextlib.ExitStack() as context_stack:
if args.root_path is not None:
root_path = args.root_path.resolve()
root_path.mkdir(parents=True, exist_ok=True)
else:
temp_dir_name = context_stack.enter_context(tempfile.TemporaryDirectory())
root_path = pathlib.Path(temp_dir_name)

if args.download:
print(f"Downloading dependencies to directory: {root_path}")

dep_pattern = re.compile(r"^[^;]+;https://([^;]+);.*$")

for line in lines:
match = dep_pattern.fullmatch(line)
if match is None:
continue

dep_path = match[1]
url = f"https://{dep_path}"
full_path = root_path / dep_path

subprocess.run(["curl", "-sSL", "--create-dirs", "-o", str(full_path), url], check=True)

package_name = "onnxruntime_build_dependencies"
version = args.version if args.version is not None else "VERSION_PLACEHOLDER"

if args.upload:
# Check if the user is logged in to Azure
result = subprocess.run("az account show", shell=True, capture_output=True, text=True, check=False)
if "No subscriptions found" in result.stderr:
# Prompt the user to log in to Azure
print("You are not logged in to Azure. Please log in to continue.")
subprocess.run("az login", shell=True, check=True)

# Publish the package to Azure Artifacts if --do-upload is specified

cmd = f'az artifacts universal publish --organization https://dev.azure.com/onnxruntime --feed onnxruntime --name {package_name} --version {version} --description "onnxruntime build time dependencies" --path {root_path}'
if args.upload:
subprocess.run(cmd, shell=True, check=True)
else:
print("would have run: " + cmd)

cmd = f'az artifacts universal publish --organization https://dev.azure.com/aiinfra --feed Lotus --name {package_name} --version {version} --description "onnxruntime build time dependencies" --path {root_path}'
if args.upload:
subprocess.run(cmd, shell=True, check=True)
else:
print("would have run: " + cmd)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
packageType: upack
feed: '/7424c8e4-5c62-490e-95c4-79446f31017c'
definition: '517c4f6f-5437-4392-a70d-4f15ec5be2f0'
version: 1.0.133
version: 1.0.134
downloadPath: $(Build.BinariesDirectory)/deps

# The private ADO project
Expand All @@ -22,7 +22,7 @@ steps:
packageType: upack
feed: '/4c7631f5-24c0-4307-8822-1aa8f180c325'
definition: 'fd9dd5ad-b73e-4678-890e-edcf680dbc1a'
version: 1.0.133
version: 1.0.134
downloadPath: $(Build.BinariesDirectory)/deps

# You can add more ADO accounts at here.

0 comments on commit 5672cde

Please sign in to comment.