File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -717,12 +717,17 @@ class _ConstSequential(_ConstModuleList):
717717 def __init__ (self , mods ):
718718 super (_ConstSequential , self ).__init__ (mods ._modules .values ())
719719
720- @script_method
721- def forward (self , input ):
722- for m in self :
723- input = m (input )
724- return input
725-
720+ # we define the forward method via self.define rather than
721+ # making it a direct class member (with a @script) annotation
722+ # because, in optimized runtime environments where only .pyc files
723+ # are shipped, we cant retrieve the source code.
724+ # TODO: find a workaround for this and remove this hack
725+ self .define ("""
726+ def forward(self, input):
727+ for m in self:
728+ input = m(input)
729+ return input
730+ """ )
726731
727732if not torch ._C ._jit_init ():
728733 raise RuntimeError ("JIT initialization failed" )
You can’t perform that action at this time.
0 commit comments