Skip to content

Commit b148d5c

Browse files
author
Olivia W Hsu
committed
Add in changes to minmax for lanka
1 parent 9218c77 commit b148d5c

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

numpy/minmax.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
from util import MinMaxPydataSparseTensorLoader
77

8-
@pytest.mark.parametrize("dims", [1, 3, 5, 7])
8+
@pytest.mark.parametrize("dims", [1, 3, 5])
99
def bench_pydata_minmax(tacoBench, dims):
1010
loader = MinMaxPydataSparseTensorLoader()
1111
dims_list = [20] + [20] + [43 for ele in range(dims)]

taco/minimax.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct Max {
3232
Func minOp("min", Min());
3333
Func maxOp("max", Max());
3434

35-
IndexExpr genMinMaxExpr(Tensor<float>& game, std::vector<IndexVar>& indexVars, int index) {
35+
IndexExpr genMinMaxExpr(Tensor<double>& game, std::vector<IndexVar>& indexVars, int index) {
3636
Func op = (index % 2 == 0) ? maxOp : minOp;
3737
if (index == (game.getOrder() - 1)) {
3838
std::vector<IndexVar> slice;
@@ -45,10 +45,18 @@ IndexExpr genMinMaxExpr(Tensor<float>& game, std::vector<IndexVar>& indexVars, i
4545
}
4646

4747
static void bench_minimax(benchmark::State& state) {
48-
int order = state.range(0) + 2;
48+
auto order_str = getEnvVar("MINMAX_ORDER");
49+
if (order_str == "") {
50+
state.error_occurred();
51+
return;
52+
}
53+
int order = std::stoi(order_str) + 2;
54+
55+
state.counters["order"] = order - 2;
56+
4957
std::vector<ModeFormatPack> modes(order, Sparse);
5058
Format f(modes);
51-
taco::Tensor<int64_t> tensor = castToType<int64_t>("A", loadMinMaxTensor("A", order, f));
59+
taco::Tensor<double> game = loadMinMaxTensor("A", order, f);
5260

5361
// This benchmark needs this hack activated to generate correct code.
5462
if(util::getFromEnv("TACO_CONCRETIZE_HACK", "0") == "0") {
@@ -71,18 +79,17 @@ static void bench_minimax(benchmark::State& state) {
7179
IndexVar("t"),
7280
};
7381

74-
std::vector<int> dims = {20, 20, 43, 43, 43, 43, 43, 43, 43};
82+
std::vector<int> dims = {20, 20, 43, 43, 43, 43, 43};
7583
dims.resize(order);
7684
// TODO (rohany, owhsu): We need to actually generate the input game state.
77-
Tensor<float> game("game", dims, Sparse);
7885
for (auto _ : state) {
7986
state.PauseTiming();
8087
Tensor<float> result("C");
8188
result = genMinMaxExpr(game, ivars, 0);
8289
result.compile();
83-
std::cout << result.getSource() << std::endl;
90+
// std::cout << result.getSource() << std::endl;
8491
state.ResumeTiming();
8592
result.compute();
8693
}
8794
}
88-
TACO_BENCH(bench_minimax)->Arg(1)->Arg(3)->Arg(5)->Arg(7);
95+
TACO_BENCH(bench_minimax);

0 commit comments

Comments
 (0)