Skip to content

Commit 813eb3b

Browse files
committed
Add kitchen-sink base test
1 parent 90e78bc commit 813eb3b

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/base.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import torch
2+
from torch.autograd import Variable
3+
import torch.nn as nn
4+
import torch.nn.functional as F
5+
6+
import os
7+
import uuid
8+
import torch2c
9+
10+
11+
def base_test():
12+
13+
fc1 = nn.Linear(10,20)
14+
fc1.weight.data.normal_(0.0,1.0)
15+
fc1.bias.data.normal_(0.0,1.0)
16+
17+
fc2 = nn.Linear(20,2)
18+
fc2.weight.data.normal_(0.0,1.0)
19+
fc2.bias.data.normal_(0.0,1.0)
20+
21+
model_0 = lambda x: F.log_softmax(fc2(F.relu(fc1(x))))
22+
23+
fc3 = nn.Linear(10,2)
24+
fc3.weight.data.normal_(0.0,1.0)
25+
fc3.bias.data.normal_(0.0,1.0)
26+
27+
model_1 = lambda x: F.softmax(F.relu(fc3(x)))
28+
29+
data = Variable(torch.rand(10,10))
30+
31+
out = model_0(data) + model_1(data) + 1
32+
33+
out_path = 'out'
34+
if not os.path.isdir(out_path):
35+
os.mkdir(out_path)
36+
uid = str(uuid.uuid4())
37+
38+
torch2c.compile(out,'base',os.path.join(out_path,uid),compile_test=True)
39+
40+
41+
if __name__=='__main__':
42+
43+
base_test()
44+

0 commit comments

Comments
 (0)