From 3aa8c86d956f59eda3d3f9318b539c8a44305025 Mon Sep 17 00:00:00 2001 From: David Hong Date: Fri, 3 Nov 2023 20:00:28 -0400 Subject: [PATCH] Split out MTTKRP benchmarks --- benchmark/benchmarks.jl | 2 ++ benchmark/gcp.jl | 20 +------------------- benchmark/mttkrp.jl | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 benchmark/mttkrp.jl diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index eae83a7..159c40c 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -1,5 +1,7 @@ using BenchmarkTools +BenchmarkTools.DEFAULT_PARAMETERS.seconds = 1 + const SUITE = BenchmarkGroup() module BenchmarkGCP diff --git a/benchmark/gcp.jl b/benchmark/gcp.jl index 68e01d0..af361c1 100644 --- a/benchmark/gcp.jl +++ b/benchmark/gcp.jl @@ -6,9 +6,7 @@ using Distributions const SUITE = BenchmarkGroup() -BenchmarkTools.DEFAULT_PARAMETERS.seconds = 1 - -bench_gcp = SUITE["gcp"] = BenchmarkGroup() +bench_gcp = SUITE # Benchmark least squares loss for sz in [(15, 20, 25), (30, 40, 50)], r in 1:2 @@ -42,19 +40,3 @@ for sz in [(15, 20, 25), (30, 40, 50)], r in 1:2 X = [rand(Bernoulli(M[I]/(M[I] + 1))) for I in CartesianIndices(size(M))] bench_gcp["bernoulliOdds-size(X)=$sz, rank(X)=$r"] = @benchmarkable gcp($X, $r, BernoulliOddsLoss()) end - - -# MTTKRP benchmarks -bench_mttkrp = SUITE["mttkrp"] = BenchmarkGroup() - -szs = [10,30,50,80,120,200] -shapes = [(sz, sz, sz) for sz in szs] -n = 1 -rs = 20:20:200 - -for sz in shapes, r in rs - Random.seed!(0) - X = randn(sz) - U = [randn(Ik,r) for Ik in sz] - bench_mttkrp["mttkrp-size(X)=$sz, rank(X)=$r"] = @benchmarkable GCPDecompositions.mttkrp($X, $U, $n) -end \ No newline at end of file diff --git a/benchmark/mttkrp.jl b/benchmark/mttkrp.jl new file mode 100644 index 0000000..453e968 --- /dev/null +++ b/benchmark/mttkrp.jl @@ -0,0 +1,20 @@ +using BenchmarkTools + +using Random +using GCPDecompositions + +const SUITE = BenchmarkGroup() + +bench_mttkrp = SUITE + +szs = [10,30,50,80,120,200] +shapes = [(sz, sz, sz) for sz in szs] +n = 1 +rs = 20:20:200 + +for sz in shapes, r in rs + Random.seed!(0) + X = randn(sz) + U = [randn(Ik,r) for Ik in sz] + bench_mttkrp["mttkrp-size(X)=$sz, rank(X)=$r"] = @benchmarkable GCPDecompositions.mttkrp($X, $U, $n) +end \ No newline at end of file