[jit] Make ModuleLists a sugared value (#34320)

Summary:
Previously when emitting subscripts we only emitted actual values, but
now they may sometimes emit a `ModuleValue`, so it should stay as a
`SugaredValue`. This allows for the result of the subscript to be
treated as a real module (i.e. you can just do `self.modlist[1](inputs)`
instead of `self.modlist[1].forward(inputs)`)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34320

Pulled By: driazati

Differential Revision: D20345642

fbshipit-source-id: 2bedf9a454af747b704422f6bbb8370cbdf4bf61
This commit is contained in:
davidriazati
2020-03-09 15:32:23 -07:00
committed by Facebook Github Bot
parent c218963270
commit 2c0f3536b6
3 changed files with 27 additions and 14 deletions

View File

@ -227,7 +227,7 @@ SugaredValuePtr ModuleValue::getitem(
return getSugaredModuleDict(loc, m)->getModules()->getitem(loc, m, idx);
}
throw ErrorReport(loc)
<< "Only ModuleLists, Sequentials, and ModuleDict Modules are subscriptable";
<< "Only ModuleList, Sequential, and ModuleDict modules are subscriptable";
}
void checkInterface(