Skip to content

Commit 38eadac

Browse files
committed
Add benchmarks for gmm
1 parent c1af1e4 commit 38eadac

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from benchmarks.numpy.common import Benchmark
2+
from benchmarks.utils import sync
3+
from benchmarks.utils.helper import parameterize
4+
5+
import cupy
6+
7+
from .gmm import train_gmm
8+
9+
10+
@sync
11+
@parameterize([('num', [100, 500000]),
12+
('dim', [2]),
13+
('max_iter', [30])])
14+
class GMM(Benchmark):
15+
def setup(self, num, dim, max_iter):
16+
normal = cupy.random.normal
17+
scale = cupy.ones(dim)
18+
train1 = normal(1, scale, size=(num, dim)).astype(cupy.float32)
19+
train2 = normal(-1, scale, size=(num, dim)).astype(cupy.float32)
20+
mean1 = normal(1, scale, size=dim)
21+
mean2 = normal(-1, scale, size=dim)
22+
self.X_train = cupy.r_[train1, train2]
23+
self.means = cupy.stack([mean1, mean2])
24+
self.covariances = cupy.random.rand(2, dim)
25+
self.tol = 0.001
26+
27+
def time_gmm(self, num, dim, max_iter):
28+
train_gmm(self.X_train, max_iter, self.tol,
29+
self.means, self.covariances)

0 commit comments

Comments
 (0)