-
Notifications
You must be signed in to change notification settings - Fork 0
/
miniprelude.py
47 lines (42 loc) · 1.04 KB
/
miniprelude.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
"""
A minimal version of the Relay prelude containing only the definitions
we will actually use (i.e., no tensor array functions)
Based on the TVM prelude
"""
import tvm
class MiniPrelude:
def __init__(self, mod=None):
if mod is None:
mod = tvm.IRModule()
self.mod = mod
self.load_prelude()
def load_prelude(self):
self.mod.import_from_std("prelude.rly")
GLOBAL_DEFS = [
"id",
"compose",
"flip",
"hd",
"tl",
"nth",
"update",
"map",
"foldl",
"foldr",
"foldr1",
"concat",
"filter",
"zip",
"rev",
"map_accuml",
"map_accumr",
"unfoldl",
"unfoldr",
"sum",
"length",
"tmap",
"size",
"iterate",
]
for global_def in GLOBAL_DEFS:
setattr(self, global_def, self.mod.get_global_var(global_def))