Skip to content

Commit 9218c77

Browse files
author
Olivia W Hsu
committed
Merge branch 'main' of github.com:tensor-compiler/array-programming-benchmarks into main
2 parents d1d653b + ad97df5 commit 9218c77

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

taco/bench.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,28 @@ taco::TensorBase loadImageTensor(std::string name, int num, taco::Format format,
8686
auto tensor = taco::read(constructImageTensorKey(num, variant, threshold), format, true);
8787
tensor.setName(name);
8888
return tensor;
89+
}
90+
91+
std::string constructMinMaxTensorKey(int order, int variant) {
92+
auto path = getTacoTensorPath();
93+
std::stringstream result;
94+
result << path;
95+
if (path[path.size() - 1] != '/') {
96+
result << "/";
97+
}
98+
result << "minmax/";
99+
if (variant == 0) {
100+
result << "minmax-" << order << ".tns";
101+
} else {
102+
result << "minmax-" << order << "-" << variant << ".tns";
103+
}
104+
return result.str();
105+
}
106+
107+
taco::TensorBase loadMinMaxTensor(std::string name, int order, taco::Format format, int variant) {
108+
// For now, just say that the python code must generate the random
109+
// tensor before use.
110+
auto tensor = taco::read(constructMinMaxTensorKey(order, variant), format, true);
111+
tensor.setName(name);
112+
return tensor;
89113
}

taco/bench.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ std::string getValidationOutputPath();
5151
std::string cleanPath(std::string path);
5252
taco::TensorBase loadRandomTensor(std::string name, std::vector<int> dims, float sparsity, taco::Format format, int variant=0);
5353
taco::TensorBase loadImageTensor(std::string name, int num, taco::Format format, float threshold, int variant=0);
54-
54+
taco::TensorBase loadMinMaxTensor(std::string name, int order, taco::Format format, int variant=0);
5555
template<typename T>
5656
taco::Tensor<T> castToType(std::string name, taco::Tensor<double> tensor) {
5757
taco::Tensor<T> result(name, tensor.getDimensions(), tensor.getFormat());

taco/minimax.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ 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;
49+
std::vector<ModeFormatPack> modes(order, Sparse);
50+
Format f(modes);
51+
taco::Tensor<int64_t> tensor = castToType<int64_t>("A", loadMinMaxTensor("A", order, f));
52+
4853
// This benchmark needs this hack activated to generate correct code.
4954
if(util::getFromEnv("TACO_CONCRETIZE_HACK", "0") == "0") {
5055
state.SkipWithError("must set TACO_CONCRETIZE_HACK=1");
@@ -66,7 +71,8 @@ static void bench_minimax(benchmark::State& state) {
6671
IndexVar("t"),
6772
};
6873

69-
std::vector<int> dims = {20, 20, 43, 43, 43, 43, 43};
74+
std::vector<int> dims = {20, 20, 43, 43, 43, 43, 43, 43, 43};
75+
dims.resize(order);
7076
// TODO (rohany, owhsu): We need to actually generate the input game state.
7177
Tensor<float> game("game", dims, Sparse);
7278
for (auto _ : state) {
@@ -76,6 +82,7 @@ static void bench_minimax(benchmark::State& state) {
7682
result.compile();
7783
std::cout << result.getSource() << std::endl;
7884
state.ResumeTiming();
85+
result.compute();
7986
}
8087
}
81-
TACO_BENCH(bench_minimax);
88+
TACO_BENCH(bench_minimax)->Arg(1)->Arg(3)->Arg(5)->Arg(7);

0 commit comments

Comments
 (0)