New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infer types for arguments of methods not invoked directly by monkeytype #57202
Conversation
💊 CI failures summary and remediationsAs of commit 7d826ba (more details on the Dr. CI page): ✅ None of the CI failures appear to be your fault 💚
🚧 1 fixed upstream failure:These were probably caused by upstream breakages that were already fixed.
Please rebase on the
|
e292056
to
4e4fd4e
Compare
Codecov Report
@@ Coverage Diff @@
## master #57202 +/- ##
===========================================
+ Coverage 57.46% 77.68% +20.22%
===========================================
Files 596 1954 +1358
Lines 76343 194572 +118229
===========================================
+ Hits 43872 151160 +107288
- Misses 32471 43412 +10941 |
e902c97
to
bfedd5b
Compare
@@ -851,7 +851,8 @@ def call_prepare_scriptable_func(obj): | |||
memo: Dict[int, torch.nn.Module] = {} | |||
return call_prepare_scriptable_func_impl(obj, memo) | |||
|
|||
def _script_pdt(obj, optimize=None, _frames_up=0, _rcb=None, example_inputs: Optional[List[Tuple]] = None): | |||
def _script_pdt(obj, optimize=None, _frames_up=0, _rcb=None, | |||
example_inputs: Union[List[Tuple], Dict[Callable, List[Tuple]], None] = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a task in asana for you about creating a docstring for _script_pdt
since its usage is sort of complex now.
…r_types_methods
…r_types_methods
scripted_pdt_model = torch.jit._script_pdt(outer_pdt_model, example_inputs={inner_pdt_model: inner_input, | ||
outer_pdt_model: outer_input, }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inner_pdt_model: inner_input
should not be needed here. Thus we should be able to pass in outer_input
in simple format of List[Tuple]
. Simple format input can be used in following few test cases as well.
@nikithamalgifb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@nikithamalgifb merged this pull request in 9063cb0. |
…pe (pytorch#57202) Summary: Support adding type annotations for class methods and nn.Module methods which are not invoked under the hood of MonkeyType ** Changes ** * This PR involves a slight change in how the example inputs are passed while scripting `class` and `nn.Module` objects. * The example inputs passed to `_script_pdt` is of the following format: - example_inputs= [(obj.method1, (arg_list)), (obj.method2, (arg_list)),] * For nn.Modules, to infer types for `forward` methods, example_inputs can be passed in two ways: - example_inputs= [(obj.forward, (arg_list, ))] - example_inputs = [(obj, (arg_list, ) )] Pull Request resolved: pytorch#57202 Reviewed By: desertfire Differential Revision: D28382827 Pulled By: nikithamalgifb fbshipit-source-id: 5481467f3e909493bf3f439ee312056943508534
Support adding type annotations for class methods and nn.Module methods which are not invoked under the hood of MonkeyType
** Changes **
class
andnn.Module
objects._script_pdt
is of the following format:forward
methods, example_inputs can be passed in two ways: