pfnet-research / chainer-compiler

Experimental toolchain to compile and run Chainer models
MIT License
112 stars 23 forks source link

Fixate type of list in a program #817

Closed momohatt closed 4 years ago

momohatt commented 4 years ago

Currently, a type of a list changes in a program when updated.

x = [1, 2, 3] # x : [int, int, int]
x.append(4)   # x : int list

(cf. https://github.com/pfnet-research/chainer-compiler/compare/master...momohatt:list-invariant?expand=1#diff-5c356c79d973908cc78cef75c3d6ed41L526-L527 ) However, because Python lists are mutable, such changes to types can ruin the soundness when alias analysis is not present. This PR fixes this problem by fixating the type of lists in a program as follows.

x = [1, 2, 3] # x : int list <- not '[int, int, int]'
x.append(4)   # x : int list

y = [1,2]      # y : optional(int) list
y.append(None) # y : optional(int) list
shinh commented 4 years ago

/test

pfn-ci-bot commented 4 years ago

Successfully created a job for commit 066a9c8: