Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[MXNET-891] Support tuple of scales in upsample operator #15811

Open
wants to merge 91 commits into
base: master
Choose a base branch
from

Conversation

benhe2011
Copy link

@benhe2011 benhe2011 commented Aug 8, 2019

Description

This PR adds the option to specify different scales for different dimensions.

Ref: #12602

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes).
  • Changes are complete (i.e. I finished coding on this PR).
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator).
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore).
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL).
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable.
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change.

Changes

  • Change scale to tuple
  • Add custom nearest neighbor implementation
  • Allow same scales for bilinear upsampling

Comments

  • ONNX import/export for Upsampling operator is added in @vandanavk's PR #15994
  • Fix for bilinear upsampling documentation and test are at #14305
  • Performance of this operator was tested against the original implementation using a simple test script from @huangzhiyuan--the results of the test on my machine were as follows:
OP scale time cost (s) s/call calls
Upsampling (origin) 2 3.763051 0.037630 100
Upsampling (with this fix) 2 3.741265 0.037413 100
Upsampling (with this fix) (2, 3) 5.613855 0.056139 100
  • Currently does not support floating point values for the scales, but can be added in the future.

tests/python/unittest/test_operator.py Outdated Show resolved Hide resolved
tests/python/unittest/test_operator.py Outdated Show resolved Hide resolved
src/operator/nn/upsampling-inl.h Outdated Show resolved Hide resolved
src/operator/nn/upsampling-inl.h Outdated Show resolved Hide resolved
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py Outdated Show resolved Hide resolved
python/mxnet/contrib/onnx/mx2onnx/_op_translations.py Outdated Show resolved Hide resolved
@samskalicky
Copy link
Contributor

Is there a test somewhere that you test upsample using a scalar instead of a tuple?

Copy link
Contributor

@samskalicky samskalicky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benhe2011
Copy link
Author

Is there a test somewhere that you test upsample using a scalar instead of a tuple?

Yes, in tests/python/unittest/test_operator.py line 1615

@apeforest
Copy link
Contributor

Ping @huangzhiyuan for review.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ONNX Operator pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants