Skip to content

Commit 5725658

Browse files
committed
WIP on outputting tensors from taco into file for pytest along with example data file that is incorrect
1 parent a9a824c commit 5725658

5 files changed

+36
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
A (10x10) ({dense},{compressed}; 0,1):
2+
dense (0):
3+
[10]
4+
compressed (1):
5+
[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
6+
[6]
7+
[1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
B (10x10) ({dense},{compressed}; 0,1):
2+
dense (0):
3+
[10]
4+
compressed (1):
5+
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
6+
[2, 7]
7+
[1, 1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
C (10x10) ({dense},{compressed}; 0,1):
2+
dense (0):
3+
[10]
4+
compressed (1):
5+
[0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3]
6+
[2, 6, 7]
7+
[1, 1, 1]

numpy/ufuncs.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ def import_tensor(filename, dim):
3939
lines = f.readlines()
4040

4141
count = 0
42-
indptr = 0
43-
indices = 0
44-
data = 0
4542
for line in lines:
4643
count += 1
4744
if count == 5:
@@ -62,7 +59,13 @@ def import_tensor(filename, dim):
6259
def get_ufunc_str(ufunc):
6360
if ufunc == numpy.logical_xor:
6461
return "xor"
65-
@pytest.mark.parametrize("dim", [250, 500, 750, 1000, 2500, 5000, 7500, 8000])
62+
if ufunc == numpy.right_shift:
63+
return ">>"
64+
if ufunc == numpy.ldexp:
65+
return "2^"
66+
67+
#@pytest.mark.parametrize("dim", [250, 500, 750, 1000, 2500, 5000, 7500, 8000])
68+
@pytest.mark.parametrize("dim", [10])
6669
@pytest.mark.parametrize("ufunc", [numpy.logical_xor])
6770
def bench_pydata_import_ufunc_sparse(tacoBench, dim, ufunc):
6871
filenameA = "./data/bench_ufunc_sparse_"

taco/ufuncs.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ static void bench_ufunc_sparse(benchmark::State& state, ExtraArgs&&... extra_arg
120120
A.pack(); B.pack();
121121

122122
// Output tensors to file
123+
// FIXME (owhsu): Why for dim == 10, does the CSR dense mode repeat indices?
124+
// This is causing a problem for the format of csr_matrix(...) in pytest
125+
// See <repo>/data/* for examples
123126
printTensor(A, "./data", __FUNCTION__ , dim, extra_args...);
124127
printTensor(B, "./data", __FUNCTION__ , dim, extra_args...);
125128

@@ -135,11 +138,14 @@ static void bench_ufunc_sparse(benchmark::State& state, ExtraArgs&&... extra_arg
135138

136139
// The actual computation.
137140
result.compute();
141+
state.PauseTiming();
142+
printTensor(result, "./data", __FUNCTION__, dim, extra_args...);
143+
state.ResumeTiming();
138144
}
139145
}
140146
static void applyBenchSizes(benchmark::internal::Benchmark* b) {
141-
b->ArgsProduct({{250, 500, 750, 1000, 2500, 5000, 7500, 8000}});
142-
//b->ArgsProduct({{2, 4, 10}});
147+
// b->ArgsProduct({{250, 500, 750, 1000, 2500, 5000, 7500, 8000}});
148+
b->ArgsProduct({{10}});
143149
}
144150

145151
TACO_BENCH_ARGS(bench_ufunc_sparse, xor_0.01, 0.01, "xor")->Apply(applyBenchSizes);

0 commit comments

Comments
 (0)