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

[MKLDNN] NDArray reorder in C API and deconv #16265

Merged
merged 5 commits into from Sep 26, 2019

Conversation

TaoLv
Copy link
Member

@TaoLv TaoLv commented Sep 25, 2019

Description

Should fix #16143 .

  1. MXNDArrayGetData: reorder NDArray back to default layout before touching the elements of it;
  2. Deconv: reorder the grad to default layout before touching the elements of it.

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

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

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

@TaoLv
Copy link
Member Author

TaoLv commented Sep 25, 2019

@rondogency @matteosal @pengzhao-intel Please review. Thanks.

@matteosal
Copy link
Contributor

I can't actually review, I'm absolutely not familiar with the libraries' internals. But I can confirm that the related issues are fixed by these changes

Copy link
Contributor

@rondogency rondogency left a comment

Choose a reason for hiding this comment

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

LGTM! FYI the deconv fix has been verified on our end, so I think this PR is good to go

Copy link
Contributor

@pengzhao-intel pengzhao-intel left a comment

Choose a reason for hiding this comment

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

Thanks for the fix.

@pengzhao-intel pengzhao-intel merged commit 1a2da12 into apache:master Sep 26, 2019
@pengzhao-intel pengzhao-intel added this to In progress in CPU Performance and Quantization via automation Sep 26, 2019
@ZhennanQin
Copy link
Contributor

The reorder in c_api doesn't synchronized with engine, thus there's a risk that there's some computing working on this NDArray, resulting in unexpected result.

@TaoLv
Copy link
Member Author

TaoLv commented Sep 26, 2019

@ZhennanQin Thank you for reminding. I would expect the C API users can understand they need call MXNDArrayWaitToRead before touching the data of an output NDArray. Otherwise, even without this reorder fix, they might get unexpected result if they touch the data returned by MXNDArrayGetData immediately.

@szha any thoughts? Seems we don't have any document for C API?

@ZhennanQin
Copy link
Contributor

Another potential problem is, C API will be called in main thread, which doesn't have computing resource. All computing resource should be managed by engine. Ideally, we'd better to push this operation to engine, and wait to get the reordered result.

@pengzhao-intel
Copy link
Contributor

@TaoLv @ZhennanQin do we need another PR to enhance?

@TaoLv
Copy link
Member Author

TaoLv commented Sep 26, 2019

@ZhennanQin Would you mind contributing another PR towards your suggestion? Thanks.

drivanov pushed a commit to drivanov/incubator-mxnet that referenced this pull request Sep 26, 2019
* layout conversion in MXNDArrayGetData

* deconv: layout conversion for grad

* fix lint complain
larroy pushed a commit to larroy/mxnet that referenced this pull request Sep 28, 2019
* layout conversion in MXNDArrayGetData

* deconv: layout conversion for grad

* fix lint complain
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Failure of MKL-DNN Convolution from C API
5 participants