Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

89 lines
2.8 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
import sys
import json
import argparse
def validate_json(data, labels, counts, depths):
expected = []
for litr, citr, ditr in zip(labels, counts, depths):
entry = []
_label = litr
if ditr > 0:
_label = "{}|_{}".format(" " * (ditr - 1), litr)
entry = [_label, citr, ditr]
expected.append(entry)
for ditr, eitr in zip(data, expected):
_prefix = ditr["prefix"]
_depth = ditr["depth"]
_count = ditr["entry"]["laps"]
_idx = _prefix.find(">>>")
if _idx is not None:
_prefix = _prefix[(_idx + 4) :]
if _prefix != eitr[0]:
raise RuntimeError(f"Mismatched prefix: {_prefix} vs. {eitr[0]}")
if _count != eitr[1]:
raise RuntimeError(f"Mismatched count for {_prefix}: {_count} vs. {eitr[1]}")
if _depth != eitr[2]:
raise RuntimeError(f"Mismatched depth for {_prefix}: {_depth} vs. {eitr[2]}")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--metric", type=str, help="JSON metric", required=True)
parser.add_argument(
"-l", "--labels", nargs="+", type=str, help="Expected labels", default=[]
)
parser.add_argument(
"-c", "--counts", nargs="+", type=int, help="Expected counts", default=[]
)
parser.add_argument(
"-d", "--depths", nargs="+", type=int, help="Expected depths", default=[]
)
parser.add_argument(
"-p", "--print", action="store_true", help="Print the processed perfetto data"
)
parser.add_argument("-i", "--input", type=str, help="Input file", required=True)
args = parser.parse_args()
if len(args.labels) != len(args.counts) or len(args.labels) != len(args.depths):
raise RuntimeError(
"The same number of labels, counts, and depths must be specified"
)
ret = 0
with open(args.input) as f:
data = json.load(f)
# demo display of data
if args.print:
for itr in data["timemory"][args.metric]["ranks"][0]["graph"]:
_prefix = itr["prefix"]
_depth = itr["depth"]
_count = itr["entry"]["laps"]
_idx = _prefix.find(">>>")
if _idx is not None:
_prefix = _prefix[(_idx + 4) :]
print("| {:40} | {:6} | {:6} |".format(_prefix, _count, _depth))
try:
validate_json(
data["timemory"][args.metric]["ranks"][0]["graph"],
args.labels,
args.counts,
args.depths,
)
except RuntimeError as e:
print(f"{e}")
ret = 1
if ret == 0:
print(f"{args.input} validated")
sys.exit(ret)