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

Add large tensor support binary arithmetic #15785

Merged
merged 9 commits into from
Aug 13, 2019

Conversation

ChaiBapchya
Copy link
Contributor

@ChaiBapchya ChaiBapchya commented Aug 7, 2019

Description

Added 11 binary arithmetic operators - add, sub, rsub, neg, mul, div, rdiv, mod, rmod, imod, pow

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Code is well-documented:
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Design choice

Choice of operator to call

I had a choice between
__op__ vs op_symbol vs mx.nd.op

Since x.__add__(y) <=> x+y <=> mx.nd.add(x, y)

However, due to cases like these

mod : x.__mod__(y) <=> x%y <=> mx.nd.modulo(x, y)
rmod: x.__rmod__(y) <=> y%x <=> mx.nd.modulo(y, x)

I chose to stick with the __op__ so that the function is consistent.

Choice 2

I chose to have separate functions because
a. Easier to debug & test separate operators
b. No 100% 1-to-1 correlation
Divide ops are different
__div__ in MXNet vs __truediv__

create_2d_tensor vs nd.ones

Chose nd.ones due to performance reasons.
After monitoring multiple runs of test_large_array
Upon running the entire file, it would crash due to lack of memory error.
480Gig machine (dedicated for this one task) - p3.16xl

Reworked the code to ensure
a. variables are reused
b. in-house MXNet function (mx.nd.ones) used over the previous method (create_2d_tensor uses combination of functions from numpy and mxnet)
c. arange is not really needed to test if the function works for large tensor

Copy link
Contributor

@apeforest apeforest left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the quick action.

@apeforest apeforest merged commit 11ce2a2 into apache:master Aug 13, 2019
@ChaiBapchya ChaiBapchya deleted the lts_binary_arithmetic branch August 14, 2019 16:20
anirudhacharya pushed a commit to anirudhacharya/mxnet that referenced this pull request Aug 20, 2019
* test rdiv

* floating_point exception handle

* add 10 other ops

* added rpow and made numpy consistent

* attempt to solve memory issue

* linting fix

* Trigger notification

* lint
access2rohit pushed a commit to access2rohit/incubator-mxnet that referenced this pull request Sep 25, 2019
* test rdiv

* floating_point exception handle

* add 10 other ops

* added rpow and made numpy consistent

* attempt to solve memory issue

* linting fix

* Trigger notification

* lint
access2rohit pushed a commit to access2rohit/incubator-mxnet that referenced this pull request Sep 25, 2019
* test rdiv

* floating_point exception handle

* add 10 other ops

* added rpow and made numpy consistent

* attempt to solve memory issue

* linting fix

* Trigger notification

* lint
access2rohit pushed a commit to access2rohit/incubator-mxnet that referenced this pull request Sep 25, 2019
* test rdiv

* floating_point exception handle

* add 10 other ops

* added rpow and made numpy consistent

* attempt to solve memory issue

* linting fix

* Trigger notification

* lint
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants