You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2021/09/01 09:11:21 UTC

[GitHub] [incubator-mxnet] agrabows opened a new pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

agrabows opened a new pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563


   ## Description ##
   Function reshape() from modules _mxnet.numpy_ and _mxnet.numpy_extension_ will now be executed by oneDNN primitives as it is done in module _mxnet.ndarray_.
   
   ## Checklist ##
   ### Essentials ###
   - [x] PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
   - [x] Changes are complete (i.e. I finished coding on this PR)
   - [x] All changes have test coverage
   
   ### Changes ###
   - [x] Add oneDNN execution attributes to NNVM_REGISTER_OP(_npx_reshape)
   
   ## Comments ##
   Using two NNVM_REGISTER_OP() functions (one for _mxnet.ndarray_, second for _mxnet.numpy_/_mxnet.numpy_extension_) instead of one with .add_alias() because special values in npx.reshape's and nd.reshape's new_shape/target_shape parameters have different functionality. For example:
   
   in nd.reshape():
   - "-3" use the product of two consecutive dimensions of the input shape as the output dimension.
   
   in npx.reshape():
   - "-3" will skip current dimension if and only if the current dim size is one.
   
   
   Performance comparison:
   ![image](https://user-images.githubusercontent.com/59651240/131477550-9f604e00-48d2-463e-a829-4d4d0b017381.png)
   
   
   - ~50% peformance speedup for mx.np.reshape() and mx.npx.reshape().
   - Slight loss of performance for mx.nd.reshape() is caused by adding 0-shape checks to oneDNN path (necessary for mx.np and mx.npx). It is a big deal only for small tensors.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-921622157


   Jenkins CI successfully triggered : [centos-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-912338707


   Jenkins CI successfully triggered : [edge]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mozga-intel commented on a change in pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mozga-intel commented on a change in pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#discussion_r699981653



##########
File path: src/operator/nn/mkldnn/mkldnn_convolution.cc
##########
@@ -39,7 +39,7 @@ DMLC_REGISTER_PARAMETER(MKLDNNConvParam);
 bool SupportMKLDNNConv(const ConvolutionParam& params, const NDArray& input) {
   if ((params.kernel.ndim() != 1) && (params.kernel.ndim() != 2) && (params.kernel.ndim() != 3))
     return false;
-  return SupportMKLDNNQuantize(input.dtype()) &&
+  return IsMKLDNNType(input.dtype()) &&
          ((input.shape().ndim() == 3) || (input.shape().ndim() == 4) ||

Review comment:
       BTW: It could be nice to change it, to get less comparison.
   ```suggestion
    input.shape().ndim() >= 3 && input.shape().ndim() <= 5
    ```

##########
File path: src/operator/nn/mkldnn/mkldnn_reshape.cc
##########
@@ -33,6 +33,13 @@
 namespace mxnet {
 namespace op {
 
+bool SupportMKLDNNReshape(const NDArray& input, const NDArray& output) {
+  const int input_ndims  = input.shape().ndim();
+  const int output_ndims = output.shape().ndim();
+  return input_ndims >= 1 && input_ndims <= 6 && output_ndims >= 1 && output_ndims <= 6 &&
+         IsMKLDNNType(input.dtype()) && input.shape().Size() > 0;

Review comment:
       The input is having its size checked at the end of this statement ~ if the Size() function returns the size of the input, then it could be better to place it at the beginning. 

##########
File path: src/operator/nn/mkldnn/mkldnn_convolution.cc
##########
@@ -39,7 +39,7 @@ DMLC_REGISTER_PARAMETER(MKLDNNConvParam);
 bool SupportMKLDNNConv(const ConvolutionParam& params, const NDArray& input) {
   if ((params.kernel.ndim() != 1) && (params.kernel.ndim() != 2) && (params.kernel.ndim() != 3))

Review comment:
       BTW: It could be nice to change it.
   ```suggestion
     if (params.kernel.ndim() > 3)) return false;
   ```
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-912358575


   Jenkins CI successfully triggered : [unix-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-921718900


   @mxnet-bot run ci [centos-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-919216821


   @mxnet-bot run ci [unix-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mozga-intel commented on a change in pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mozga-intel commented on a change in pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#discussion_r699981653



##########
File path: src/operator/nn/mkldnn/mkldnn_convolution.cc
##########
@@ -39,7 +39,7 @@ DMLC_REGISTER_PARAMETER(MKLDNNConvParam);
 bool SupportMKLDNNConv(const ConvolutionParam& params, const NDArray& input) {
   if ((params.kernel.ndim() != 1) && (params.kernel.ndim() != 2) && (params.kernel.ndim() != 3))
     return false;
-  return SupportMKLDNNQuantize(input.dtype()) &&
+  return IsMKLDNNType(input.dtype()) &&
          ((input.shape().ndim() == 3) || (input.shape().ndim() == 4) ||

Review comment:
       BTW: It could be nice to change it, to get less comparison.
   ```suggestion
    input.shape().ndim() >= 3 && input.shape().ndim() <= 5
    ```

##########
File path: src/operator/nn/mkldnn/mkldnn_reshape.cc
##########
@@ -33,6 +33,13 @@
 namespace mxnet {
 namespace op {
 
+bool SupportMKLDNNReshape(const NDArray& input, const NDArray& output) {
+  const int input_ndims  = input.shape().ndim();
+  const int output_ndims = output.shape().ndim();
+  return input_ndims >= 1 && input_ndims <= 6 && output_ndims >= 1 && output_ndims <= 6 &&
+         IsMKLDNNType(input.dtype()) && input.shape().Size() > 0;

Review comment:
       The input is having its size checked at the end of this statement ~ if the Size() function returns the size of the input, then it could be better to place it at the beginning. 

##########
File path: src/operator/nn/mkldnn/mkldnn_convolution.cc
##########
@@ -39,7 +39,7 @@ DMLC_REGISTER_PARAMETER(MKLDNNConvParam);
 bool SupportMKLDNNConv(const ConvolutionParam& params, const NDArray& input) {
   if ((params.kernel.ndim() != 1) && (params.kernel.ndim() != 2) && (params.kernel.ndim() != 3))

Review comment:
       BTW: It could be nice to change it.
   ```suggestion
     if (params.kernel.ndim() > 3)) return false;
   ```
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-909248377


   @mxnet-bot run ci [windows-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-921584240


   @mxnet-bot run ci [centos-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-909070405


   Hey @agrabows , Thanks for submitting the PR 
   All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands: 
   - To trigger all jobs: @mxnet-bot run ci [all] 
   - To trigger specific jobs: @mxnet-bot run ci [job1, job2] 
   *** 
   **CI supported jobs**: [centos-gpu, sanity, windows-cpu, edge, windows-gpu, centos-cpu, unix-gpu, clang, unix-cpu, website, miscellaneous]
   *** 
   _Note_: 
    Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin. 
   All CI tests must pass before the PR can be merged. 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-909248450


   Jenkins CI successfully triggered : [windows-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-919216924


   Jenkins CI successfully triggered : [unix-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-921584276


   Jenkins CI successfully triggered : [centos-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-912358503


   @mxnet-bot run ci [unix-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] akarbown merged pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
akarbown merged pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-909248377


   @mxnet-bot run ci [windows-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-909248377


   @mxnet-bot run ci [windows-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-921622094


   @mxnet-bot run ci [centos-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows removed a comment on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows removed a comment on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-920707808


   @mxnet-bot run ci [centos-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-909070405






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-912338655


   @mxnet-bot run ci [edge]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] agrabows commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
agrabows commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-920707808


   @mxnet-bot run ci [centos-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-921718940


   Jenkins CI successfully triggered : [centos-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20563: [FEATURE] Add oneDNN support for npx.reshape and np.reshape

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20563:
URL: https://github.com/apache/incubator-mxnet/pull/20563#issuecomment-909070405






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org