Created
February 8, 2018 20:39
-
-
Save jamesr66a/702e72b6e83114791d69c4dcae811b5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_script_fibb(self): | |
cu = torch.jit._jit_script_compile(''' | |
def test_while(lim) -> (third): | |
first = 1 | |
second = 1 | |
i = 1 | |
somenum = 5 | |
dontmutateme = 3 | |
third = 0 # TODO: python lexical scoping | |
while i < lim: | |
third = first + second | |
first = second | |
second = third | |
i = i + dontmutateme | |
j = 0 | |
while j < 10: | |
somenum *= 2 | |
''') | |
self.assertExpected(str(cu.get_graph('test_while'))) | |
graph(%lim : UNKNOWN_TYPE) { | |
%first : UNKNOWN_TYPE = Constant[value={1}]() | |
%first1 : UNKNOWN_TYPE = Constant[value={1}]() | |
%i : UNKNOWN_TYPE = Constant[value={1}]() | |
%somenum : UNKNOWN_TYPE = Constant[value={5}]() | |
%dontmutateme : UNKNOWN_TYPE = Constant[value={3}]() | |
%third : UNKNOWN_TYPE = Constant[value={0}]() | |
%7 : UNKNOWN_TYPE = lt(%i, %lim) | |
%8 : UNKNOWN_TYPE = Loop() | |
block0() { | |
%second1 : UNKNOWN_TYPE = add[alpha={1}](%first, %first1) | |
%i1 : UNKNOWN_TYPE = add[alpha={1}](%i, %dontmutateme) | |
%j : UNKNOWN_TYPE = Constant[value={0}]() | |
%12 : UNKNOWN_TYPE = Constant[value={10}]() | |
%13 : UNKNOWN_TYPE = lt(%j, %12) | |
%14 : UNKNOWN_TYPE = Loop() | |
block0() { | |
%15 : UNKNOWN_TYPE = Constant[value={2}]() | |
%somenum1 : UNKNOWN_TYPE = mul(%somenum, %15) | |
-> () | |
} | |
-> () | |
} | |
return (%second1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment