-
Notifications
You must be signed in to change notification settings - Fork 0
/
trans_add.py
34 lines (29 loc) · 995 Bytes
/
trans_add.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import cupy
import numpy
import util
for xp in [cupy, numpy]:
for trans in [False, True]:
for size in [2 ** i for i in range(16)]:
if trans:
a = xp.ones((32, size), 'f').T
else:
a = xp.ones((size, 32), 'f')
b = xp.ones((size, 32), 'f')
def f():
a + b
head = "t" if trans else "n"
str = "cp" if xp is cupy else "np"
util.measure(f, "%s_add_%s, %5d" % (head, str, size))
for xp in [cupy, numpy]:
for trans in [False, True]:
for size in [2 ** i for i in range(16)]:
if trans:
a = xp.ones((32, size), 'f').T
else:
a = xp.ones((size, 32), 'f')
b = xp.ones((size, 32), 'f')
def f():
a ** b
head = "t" if trans else "n"
str = "cp" if xp is cupy else "np"
util.measure(f, "%s_pow_%s, %5d" % (head, str, size))