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

[MXNET-498] Test MKLDNN backward operators #11232

Merged
merged 39 commits into from
Jun 20, 2018

Conversation

azai91
Copy link
Contributor

@azai91 azai91 commented Jun 11, 2018

Description

add backwards C++ unit tests for mkldnn operators

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 the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Backwards activation can handle view/mkldnn input/output
  • add unit test for backwards copy
  • add unit test for backwards act
  • add unit test for backwards sum
  • remove initfn interface and merge InitDefaultArray/InitPosNegArray. always init fixture arrays with pos/negative values
  • Make TestOp function that can handle variable inputs / backwards

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@azai91 azai91 force-pushed the test/backwards-mkldnn branch 13 times, most recently from 60e1d0b to 28a7931 Compare June 18, 2018 16:54
@azai91 azai91 force-pushed the test/backwards-mkldnn branch 2 times, most recently from 73d7357 to bb941ae Compare June 18, 2018 21:46
@@ -93,40 +93,26 @@ TEST(MKLDNN_UTIL_FUNC, MemFormat) {

// Init arrays with the default layout.
static void InitDefaultArray(NDArray *arr, bool is_rand = false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you decide to remove this Init function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason to have two inits. We can just have one that covers negative and positives.

std::vector<OpReqType> req(1);
std::vector<DispatchMode> dispatches = attrs.dispatches;

TEST(MKLDNN_BASE, MKLDNNSum) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you move this test back to the end of the file? It's kind of hard for me to tell what you changed in the test.

@piiswrong piiswrong merged commit 12cb4b9 into apache:master Jun 20, 2018
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* add act backwards test

* use only verifyfn template

* fix param name

* update number of inputs

* fix assertion for act backwards

* limit rand num range

* change to assert

* wait to read on correct vector

* add writeinplace test

* fix params

* add copy backwards test

* add missing fixture

* fix lint

* add sum backwards verify

* use correct num of inputs for sum backwards

* switch input / output

* wait for both outputs

* limit input/output

* limit input/outputs for relu/sum

* fix var source

* reorder backwards if view

* add another entry to reqs in ttest

* uncomment write in place sumbackwards

* refactor testunary and testbinary into testop

* remove special testbackwardsop and use testop

* fill reqs vector with num of outputs

* change req size to num outputs

* create mulitple output ndarrays

* wait for all outputs

* remove unused comments

* remove redundant VerifyCopyResult method

* remove redundant VerifySumResult

* remove unused var

* use only InitDefaultArray

* move MKLDNNSum near copy test

* use fallback compute for backwards sum

* fix verifydefmem test

* fix lint

* move MKLDNNSum test back to bottom
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
* add act backwards test

* use only verifyfn template

* fix param name

* update number of inputs

* fix assertion for act backwards

* limit rand num range

* change to assert

* wait to read on correct vector

* add writeinplace test

* fix params

* add copy backwards test

* add missing fixture

* fix lint

* add sum backwards verify

* use correct num of inputs for sum backwards

* switch input / output

* wait for both outputs

* limit input/output

* limit input/outputs for relu/sum

* fix var source

* reorder backwards if view

* add another entry to reqs in ttest

* uncomment write in place sumbackwards

* refactor testunary and testbinary into testop

* remove special testbackwardsop and use testop

* fill reqs vector with num of outputs

* change req size to num outputs

* create mulitple output ndarrays

* wait for all outputs

* remove unused comments

* remove redundant VerifyCopyResult method

* remove redundant VerifySumResult

* remove unused var

* use only InitDefaultArray

* move MKLDNNSum near copy test

* use fallback compute for backwards sum

* fix verifydefmem test

* fix lint

* move MKLDNNSum test back to bottom
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.

None yet

3 participants