-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpass_test.py
58 lines (41 loc) · 1.33 KB
/
pass_test.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import numpy as np
from common import ArkoudaJITTest
from context import arkouda as ak
# helper to test auto compilation/inlining
def sqr(A):
return A*A
class PassTests(ArkoudaJITTest):
"""Test JITed pdarray set operations"""
def test_cse(self):
"""Common subexpression elimination"""
def calc1():
A = ak.arange(10)
B = A*A + A*A
return B
def calc2():
A = ak.arange(10)
B = A*A
B += A*A
return B
assert self.verify(locals(), passes=("cse",))
assert self.counts[(calc1, 'binop', True)] == 2
assert self.counts[(calc2, 'binop', True)] == 1
def test_auto_inline(self):
"""Inline functions to enable CSE"""
def calc1():
A = ak.arange(10)
B = sqr(A) + A*A
return B
def calc2():
A = ak.arange(10)
B = A*A + sqr(A)
return B
def calc3():
A = ak.arange(10)
B = A*A + sqr(A)
return B
assert self.verify(locals(), passes=("auto", "cse",))
assert self.counts[(calc1, 'binop', False)] == 3
assert self.counts[(calc1, 'binop', True)] == 2
assert self.counts[(calc2, 'binop', True)] == 2
assert self.counts[(calc3, 'binop', True)] == 2