Skip to content

Add flexible bilinear upsampling aspect ratio#1279

Closed
andrewgiessel wants to merge 64 commits intopytorch:masterfrom
andrewgiessel:add-flexible-bilinear-upsampling-aspect-ratio
Closed

Add flexible bilinear upsampling aspect ratio#1279
andrewgiessel wants to merge 64 commits intopytorch:masterfrom
andrewgiessel:add-flexible-bilinear-upsampling-aspect-ratio

Conversation

@andrewgiessel
Copy link
Contributor

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_factor to be a pair (tuple) of non-negative ints instead of a single int, and edited two lines in the foward() of UpsamplingBilinear2d to 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.

sjeaugey and others added 26 commits October 7, 2016 12:42
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.

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.

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.

[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.

@andrewgiessel
Copy link
Contributor Author

andrewgiessel commented Apr 18, 2017

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.

@soumith
Copy link
Collaborator

soumith commented Apr 20, 2017

@andrewgiessel instead of rebasing on master, looks like you tried to merge via master. Now this branch has 64 commits :)

@andrewgiessel
Copy link
Contributor Author

@fmassa UGH. I really tried... Suggestions? I can pop out the files that I've changed, delete, refork, and reopen the PR

@andrewgiessel
Copy link
Contributor Author

Ya, I think I'm going to open a new PR and reference this one for posterity. 91 files changed? 🙄

@andrewgiessel
Copy link
Contributor Author

let's try this again...

hubertlu-tw pushed a commit to hubertlu-tw/pytorch that referenced this pull request Nov 1, 2022
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.