Fixed API compatibility on maxpool2d (with indices, empty args) functions #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The purpose of this PR is to address several test cases for
max_pool2d
andmax_pool2d_with_indices
that require accepting different combinations of a list versus an int for parameters such as kernel_size, stride, pooling, and dilation.Since there are a lot of combinations (16 for 4 parameters) we generate the appropriate bindings via recursive template instantiation. Essentially, a recursive template function generates 16 different combinations ofPyAnyTorchListOfTorchIntValue and PyTorch_IntValue for four arguments (kernel_size, stride, padding, dilation) to be accepted for max_pool2d_with_indices_ Ops.
In addition, by setting default argument type and values for the arguments to the Op, we allowed
max_pool2d
andmax_pool2d_with_indices
to omit some of the kwargs in use.Note that to avoid segfault, max_pool2d_with_indices() redefines default loc and ip before all casted arguments are passed into max_pool2d_with_indices_() ops function.
This passes an additional 6 tests.