Skip to content

Commit 1605f9b

Browse files
author
Olivia W Hsu
committed
Add in scripts for running image benchmarks on lanka
1 parent 0bc607e commit 1605f9b

File tree

4 files changed

+67
-36
lines changed

4 files changed

+67
-36
lines changed

numpy/image.py

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,10 @@
22
import cv2
33
import os
44
import pytest
5-
import matplotlib.pyplot as plt
65
import sparse
7-
from util import ImagePydataSparseTensorLoader, safeCastPydataTensorToInts, TnsFileDumper
8-
9-
10-
# plot_image plots the given original, binned, xor, and sparse xor images
11-
# for the numpy/image.py. Used for debugging only with the --plot flag
12-
def plot_image(img, img1, img2, xor_img, sparse_xor_img, t1, t2, window=None):
13-
f, ax = plt.subplots(2, 3)
14-
ax[0, 0].imshow(img1, 'gray')
15-
ax[0, 0].title.set_text("Binned Image 1. t1 = " + str(t1))
16-
17-
ax[0, 1].imshow(img2, 'gray')
18-
ax[0, 1].title.set_text("Binned Image 2. t2 = " + str(t2))
19-
20-
ax[1, 0].imshow(img, 'gray')
21-
ax[1, 0].title.set_text("Saturdated Image")
22-
23-
ax[1, 1].imshow(xor_img, 'gray')
24-
ax[1, 1].title.set_text("XOR Image")
25-
26-
ax[1, 2].imshow(sparse_xor_img, 'gray')
27-
ax[1, 2].title.set_text("Sparse XOR Image")
28-
29-
if window is not None:
30-
ax[0, 2].imshow(window, 'gray')
31-
ax[0, 2].title.set_text("Fused Window Image")
32-
33-
f.tight_layout()
34-
plt.show()
6+
from util import ImagePydataSparseTensorLoader, safeCastPydataTensorToInts, TnsFileDumper #plot_image
357

8+
# import matplotlib.pyplot as plt
369

3710
@pytest.mark.parametrize("num", list(range(1, 99)))
3811
@pytest.mark.parametrize("pt1", [0.5])
@@ -68,7 +41,7 @@ def dense_bench():
6841
sparse_xor_img = sparse_xor_img.todense()
6942
t1 = round(loader.max[num]*pt1, 2)
7043
t2 = round(loader.max[num]*(pt1 + 0.05), 2)
71-
plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2)
44+
#plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2)
7245

7346
@pytest.mark.parametrize("num", list(range(1, 99)))
7447
@pytest.mark.parametrize("pt1", [0.5])
@@ -121,7 +94,7 @@ def dense_bench():
12194
sparse_xor_img = sparse_xor_img.todense()
12295
t1 = round(loader.max[num]*pt1, 2)
12396
t2 = round(loader.max[num]*(pt1 + 0.05), 2)
124-
plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2, bin_window)
97+
#plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2, bin_window)
12598

12699
assert(sparse_xor_img.nnz == np.sum(xor_img != 0))
127100

@@ -190,7 +163,7 @@ def dense_bench():
190163
t1 = round(loader.max[num]*pt1, 2)
191164
t2 = round(loader.max[num]*(pt1 + 0.05), 2)
192165
print(xor_img)
193-
plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2)
166+
#plot_image(loader.img[num], bin_img1, bin_img2, xor_img, sparse_xor_img, t1, t2)
194167

195168
assert(sparse_xor_img.nnz == np.sum(xor_img != 0))
196169

@@ -260,7 +233,3 @@ def dense_bench():
260233
print("Sparse xor NNF = ", sparse_xor_img.nnz, "\t", "Dense xor NNF = ", np.sum(xor_img != int(f)))
261234
print("Dense xor NNZ = ", np.sum(xor_img != 0))
262235
assert(sparse_xor_img.nnz == np.sum(xor_img != 1))
263-
264-
if __name__=="__main__":
265-
main()
266-

numpy/util.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,30 @@ def dense_window(self, num):
407407
result_np[m0-3*dm0:m0-dm0, m1-3*dm1:m1-dm1] = 1
408408
result_np[m0+dm0:m0+3*dm0, m1-3*dm1:m1-dm1] = 1
409409
return result_np
410+
411+
# plot_image plots the given original, binned, xor, and sparse xor images
412+
# for the numpy/image.py. Used for debugging only with the --plot flag
413+
# def plot_image(img, img1, img2, xor_img, sparse_xor_img, t1, t2, window=None):
414+
# f, ax = plt.subplots(2, 3)
415+
# ax[0, 0].imshow(img1, 'gray')
416+
# ax[0, 0].title.set_text("Binned Image 1. t1 = " + str(t1))
417+
#
418+
# ax[0, 1].imshow(img2, 'gray')
419+
# ax[0, 1].title.set_text("Binned Image 2. t2 = " + str(t2))
420+
#
421+
# ax[1, 0].imshow(img, 'gray')
422+
# ax[1, 0].title.set_text("Saturdated Image")
423+
#
424+
# ax[1, 1].imshow(xor_img, 'gray')
425+
# ax[1, 1].title.set_text("XOR Image")
426+
#
427+
# ax[1, 2].imshow(sparse_xor_img, 'gray')
428+
# ax[1, 2].title.set_text("Sparse XOR Image")
429+
#
430+
# if window is not None:
431+
# ax[0, 2].imshow(window, 'gray')
432+
# ax[0, 2].title.set_text("Fused Window Image")
433+
#
434+
# f.tight_layout()
435+
# plt.show()
436+

scripts/image_runner.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
#SBATCH -N 1
3+
#SBATCH --mem 120000
4+
#SBATCH -p lanka-v3
5+
#SBATCH --exclusive
6+
7+
set -u
8+
9+
source /data/scratch/rohany/array-programming-benchmarks/venv/bin/activate
10+
11+
out=image-bench/numpy
12+
13+
mkdir -p "$out"
14+
mkdir -p "data/image/tensors"
15+
16+
jsonout="$out/result-numpy.json"
17+
18+
LANKA=ON NUMPY_JSON="$jsonout" make python-bench BENCHES="numpy/image.py"

scripts/image_taco_runner.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
#SBATCH -N 1
3+
#SBATCH --mem 120000
4+
#SBATCH -p lanka-v3
5+
#SBATCH --exclusive
6+
7+
set -u
8+
9+
out=image-bench/taco
10+
11+
mkdir -p "$out"
12+
13+
for i in {1..98}
14+
do
15+
csvout="$out/result-taco-img$i.csv"
16+
LANKA=ON IMAGE_NUM="$i" TACO_TENSOR_PATH="data/" TACO_OUT="$csvout" make -j8 taco-bench BENCHES="bench_image"
17+
done

0 commit comments

Comments
 (0)