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
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
# Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import os
|
|
|
|
import matplotlib.pyplot as plt
|
|
import msgpack
|
|
import numpy as np
|
|
from PIL import Image
|
|
|
|
|
|
def loadMatrix(fname):
|
|
with open(fname, "rb") as f:
|
|
x = msgpack.load(f)
|
|
# Since the array is written as column major but Numpy is row-major,
|
|
# 1. The order of the sizes is backwards compared to what is expected here.
|
|
# 2. In order to plot the data in a way that looks right, we then need to
|
|
# transpose the matrix.
|
|
data = np.array(x["data"]).reshape(list(reversed(x["sizes"]))).T
|
|
return data
|
|
|
|
|
|
def showMatrix(fname, cmap="plasma", aspect="auto", **kwargs):
|
|
data = loadMatrix(fname)
|
|
|
|
fig, ax = plt.subplots(1, 1, figsize=(20, 10))
|
|
fig.suptitle(os.path.splitext(os.path.basename(fname))[0])
|
|
colormap = ax.matshow(data, aspect=aspect, cmap=cmap, **kwargs)
|
|
fig.colorbar(colormap)
|
|
return fig
|
|
|
|
|
|
def writeNumpyToImage(data, m, n, image_file, empty=-1, **kwargs):
|
|
imgData = np.zeros([m, n, 3], dtype=np.uint8)
|
|
max = np.max(data)
|
|
for i in range(m):
|
|
for j in range(n):
|
|
index = i * n + j
|
|
if data[index] == empty:
|
|
imgData[i, j] = [0, 0, 255]
|
|
else:
|
|
imgData[i, j] = [int((data[index] / max) * 255), 255, 0]
|
|
with Image.fromarray(imgData) as img:
|
|
img.save(image_file, **kwargs)
|
|
print(f"Wrote {image_file}")
|