Skip to content

Commit 4073077

Browse files
author
Olivia W Hsu
committed
Add in some changes to get benchmarks working
1 parent 7fc6c7e commit 4073077

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

numpy/conftest.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import pytest
22
@pytest.fixture
33
def tacoBench(benchmark):
4-
def f(func, extra_info = None):
4+
def f(func, extra_info = None, save_ret_val = False):
55
# Take statistics based on 10 rounds.
66
if extra_info is not None:
77
for k, v in extra_info.items():
88
benchmark.extra_info[k] = v
9+
if save_ret_val:
10+
benchmark.extra_info["return"] = func()
911
benchmark.pedantic(func, rounds=10, iterations=1, warmup_rounds=1)
1012
return f
1113

numpy/minmax.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ def bench_pydata_minmax(tacoBench, dims):
1414
# and not just sparse uniform sampling
1515

1616
matrix = loader.tensor(dims_list)
17+
extra_info = dict()
18+
extra_info["nnz"] = matrix.nnz
1719
def bench():
1820
reduced = matrix
1921
for m in range(len(dims_list)):
2022
if m % 2 == 0:
2123
reduced = np.max(reduced, -1)
2224
else:
2325
reduced = np.min(reduced, -1)
24-
print(reduced)
2526
return reduced
26-
tacoBench(bench)
27-
red = bench()
28-
print("reduced value for", dims, "is", red)
27+
tacoBench(bench, extra_info, True)
2928

29+
@pytest.mark.skip(reason="Only to get matrix statistics")
3030
@pytest.mark.parametrize("dims", [1, 3, 5])
3131
def bench_minmax_statistics(tacoBench, dims):
3232
loader = MinMaxPydataSparseTensorLoader()

numpy/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def construct_minmax_tensor_key(dims, variant=None):
450450
return os.path.join(path, name, key)
451451

452452
def generate_crds_helper(shape, level, crds):
453-
sampling = 0.4
453+
sampling = 0.1
454454
num = 4
455455
std = 2
456456

scripts/minimax_runner.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ mkdir -p "data/minmax"
1515

1616
jsonout="$out/statistics-numpy.json"
1717

18-
LANKA=ON NUMPY_JSON="$jsonout" make python-bench BENCHES="numpy/minmax.py::bench_minmax_statistics"
18+
LANKA=ON NUMPY_JSON="$jsonout" make python-bench BENCHES="numpy/minmax.py::bench_pydata_minmax"

taco/minimax.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static void bench_minimax(benchmark::State& state) {
8181

8282
std::vector<int> dims = {20, 20, 43, 43, 43, 43, 43};
8383
dims.resize(order);
84+
double return_value;
8485
// TODO (rohany, owhsu): We need to actually generate the input game state.
8586
for (auto _ : state) {
8687
state.PauseTiming();
@@ -91,8 +92,9 @@ static void bench_minimax(benchmark::State& state) {
9192
// std::cout << result.getSource() << std::endl;
9293
state.ResumeTiming();
9394
result.compute();
94-
// state.PauseTiming();
95-
// cout << "Reduced value" << result << endl;
95+
state.PauseTiming();
96+
return_value = result();
9697
}
98+
state.counters["return"] = return_value;
9799
}
98100
TACO_BENCH(bench_minimax);

0 commit comments

Comments
 (0)