Skip to content

taco,numpy: add a benchmark to see the scaling of fused ufuncs #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions numpy/ufuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ def bench():
C = ufunc(A, B)
tacoBench(bench)

@pytest.mark.parametrize("dim", [5000, 10000, 20000])
@pytest.mark.parametrize("dim", [1000, 2500, 5000, 10000, 20000, 40000])
def bench_pydata_ufunc_fused(tacoBench, dim):
loader = RandomPydataSparseTensorLoader()
matrix = safeCastPydataTensorToInts(loader.random((dim, dim), 0.01))
matrix1 = safeCastPydataTensorToInts(loader.random((dim, dim), 0.01, variant=1))
matrix2 = safeCastPydataTensorToInts(loader.random((dim, dim), 0.01, variant=2))
def bench():
result = numpy.logical_xor(numpy.logical_xor(matrix, matrix1), matrix2)
result = numpy.logical_and(numpy.logical_xor(matrix, matrix1), matrix2)
return result
tacoBench(bench)

Expand Down Expand Up @@ -153,7 +153,7 @@ def bench():
fusedFuncNames = [
"xorAndFused",
"xorOrFused",
#"xorXorFused",
"xorXorFused",
]
fusedFuncs = zip(fusedFuncs, fusedFuncNames)
@pytest.mark.parametrize("tensor", FROSTTTensors.getTensors())
Expand All @@ -163,7 +163,6 @@ def bench_pydata_frostt_fused_ufunc_sparse(tacoBench, tensor, func):
third = PydataTensorShifter().shiftLastMode(other)
def bench():
c = func[0](frTensor, other, third)
print("nnz = ", c.nnz)
return c
extra_info = dict()
extra_info['tensor_str'] = str(tensor)
Expand Down
6 changes: 4 additions & 2 deletions scripts/frostt_taco_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
#SBATCH -p lanka-v3
#SBATCH --exclusive

out=frostt-ufunc-bench/taco/
# out=frostt-ufunc-bench/taco/
out=frostt-fused-ufunc-bench/taco/

mkdir -p "$out"

for tensor in "nips" "uber-pickups" "chicago-crime" "enron" "nell-2" "vast"; do
csvout="$out/result-$tensor.csv"
LANKA=ON TACO_OUT="$csvout" make -j8 taco-bench BENCHES="bench_frostt_ufunc/$tensor*"
# LANKA=ON TACO_OUT="$csvout" make -j8 taco-bench BENCHES="bench_frostt_ufunc/$tensor*"
LANKA=ON TACO_OUT="$csvout" make -j8 taco-bench BENCHES="bench_frostt_ufunc_fused/$tensor*"
done
9 changes: 3 additions & 6 deletions taco/ufuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,16 @@ static void bench_ufunc_fused(benchmark::State& state, const Format& f) {
state.PauseTiming();
Tensor<int64_t> result("result", {dim, dim}, f);
IndexVar i("i"), j("j");
result(i, j) = nestedXorOp(matrix(i, j), matrix1(i, j), matrix2(i, j));
result.setAssembleWhileCompute(false);
result(i, j) = andOp(xorOp(matrix(i, j), matrix1(i, j)), matrix2(i, j));
result.setAssembleWhileCompute(true);
result.compile();
state.ResumeTiming();
result.assemble();
result.compute();
result = result.removeExplicitZeros(result.getFormat());

}
}
TACO_BENCH_ARGS(bench_ufunc_fused, csr, CSR)
->ArgsProduct({{5000, 10000, 20000}});
->ArgsProduct({{1000, 2500, 5000, 10000, 20000, 40000}});

// UfuncInputCache is a cache for the input to ufunc benchmarks. These benchmarks
// operate on a tensor loaded from disk and the same tensor shifted slightly. Since
Expand Down Expand Up @@ -467,7 +465,6 @@ static void bench_frostt_ufunc_fused(benchmark::State& state, std::string tnsPat
state.ResumeTiming();

result.compute();

}
}

Expand Down
1 change: 0 additions & 1 deletion taco/windowing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ enum WindowConfig {
__func__(Constant, Constant) \
__func__(ConstantFraction, ConstantFraction) \
__func__(AlmostWhole, AlmostWhole) \
__func__(Whole, Whole) \
__func__(NoWindowing, NoWindowing)

Tensor<double> windowedTensorOp(Tensor<double> input1, Tensor<double> input2, int dim, WindowConfig config, float sparsity) {
Expand Down