Add flexible bilinear upsampling aspect ratio#1279
Add flexible bilinear upsampling aspect ratio#1279andrewgiessel wants to merge 64 commits intopytorch:masterfrom andrewgiessel:add-flexible-bilinear-upsampling-aspect-ratio
Conversation
Rename the static library "libnccl_static.a" to disambiguate from the dynamic libraries.
Add a static library target "staticlib" to the Makefile.
Broadcast tuning Better checking of inputs Copy/reduce code simplification
Qualify nullptr_t with std::
This enables support for systems with more than 9 GPUs attached to a single PCIe root complex.
Functions vFetch and vStore are not found by ADL with clang, so they need to be declared before usage in ReduceCopy.
Fix compilation error when compiling with 'clang -x cuda'.
Adding tests for tuple scaling factors, even and uneven
| if size is None and scale_factor is None: | ||
| raise ValueError('either size or scale_factor should be defined') | ||
| if scale_factor is not None: | ||
| if not isinstance(scale_factor, (Integral, tuple)): |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| if size is not None and not isinstance(size, tuple): | ||
| size = (size, size) | ||
| if scale_factor is not None and not isinstance(scale_factor, tuple): | ||
| scale_factor = (scale_factor, scale_factor) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| def __init__(self, size=None, scale_factor=None): | ||
| super(_UpsamplingBase, self).__init__() | ||
| super(UpsamplingNearest2d, self).__init__() |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/nn/modules/upsampling.py
Outdated
| [torch.FloatTensor of size 1x1x4x4] | ||
|
|
||
| """ | ||
| def __init__(self, size=None, scale_factor=None): |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Thanks for the comments @apaszke! also, the failed check is a linter error, I'll fix that right now. edit: Bah- some of the inline comments are outdated now, sorry about that. |
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Fixes #1225. Signed-off-by: Edward Z. Yang <ezyang@fb.com>
The type checking is split across the parent and child classes
Adding tests for tuple scaling factors, even and uneven
The type checking is split across the parent and child classes
…b.com:andrewgiessel/pytorch into add-flexible-bilinear-upsampling-aspect-ratio
|
@andrewgiessel instead of rebasing on master, looks like you tried to merge via master. Now this branch has 64 commits :) |
|
@fmassa UGH. I really tried... Suggestions? I can pop out the files that I've changed, delete, refork, and reopen the PR |
|
Ya, I think I'm going to open a new PR and reference this one for posterity. 91 files changed? 🙄 |
|
let's try this again... |
* Free output tensor on each pipeline stage for smaller memory footprint see: NVIDIA/Megatron-LM@057b086 * ref: NVIDIA/Megatron-LM@945ece9 * ref: NVIDIA/Megatron-LM@9a8b89a * remove position embedding group in destroy * pass deallocate_pipeline_outputs to backward_step * fix typo * missing deallocate_pipeline_outputs * fix typo: grad_ouptut -> grad_output * update tests * remove accessed todo * test with data parallel size of 2 if there's equal to or more than 8 gpus
This PR addresses #1257, which aims to add non-coupled scaling factors for bilinear 2d upsampling. I've added two new tests, and currently everything passes. This is a relatively simple change which only touches python code.
Some high level notes:
The largest changes refactor the Upsampling module (f2efeba) and functions (0760a41), moving everything from the base constructor down into the individual classes. I normally don't like removing that sort of abstraction, but I didn't see a good way to cleanly check the inputs for all cases at that higher level.
I changed
scale_factorto be a pair (tuple) of non-negative ints instead of a single int, and edited two lines in thefoward()ofUpsamplingBilinear2dto reflect this. If a single number is passed in for scaling, it is duplicated in the tuple.docstrings have been adjusted throughout
I added 2 tests. Not sure if this is sufficient, but given that nothing breaks, seems ok for now. As an aside, is there a way to run just one test?
Thanks, and input welcome. Tagging @soumith and @fmassa, who commented on the initial issue.