apeforest opened a new pull request #15041: Fix crash in random.shuffle operator
URL: https://github.com/apache/incubator-mxnet/pull/15041
 
 
   ## Description ##
   This PR fix https://github.com/apache/incubator-mxnet/issues/15029
   The rootcause of the problem is when NDArray is 1-d and the platform is GNU 
Linux, the backend implementation uses `__gnu_parallel:random_shuffle()` See: 
https://github.com/apache/incubator-mxnet/blob/master/src/operator/random/shuffle_op.cc#L53.
 This explains why crash did not happen in MacOS.
   
   The random_shuffle template defined in gcc 
(https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/parallel/random_shuffle.h#L384)
 is passing in `std::numeric_limits<uint32_t>::max()` to the __rng() function 
to generate random seed. Therefore, in our rng() function 
(https://github.com/apache/incubator-mxnet/blob/master/src/operator/random/shuffle_op.cc#L49)
 we cannot use our self defined data type `index_t` and have to use `uint32_t` 
to avoid integer overflow.
   
   Why this bug was not detected in our unit test? Because our unit test of 
shuffle only tests 2-D shape, which did not use parallel_shuffle in backend.
   
   
   
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [X] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to 
the relevant [JIRA issue](https://issues.apache.org/jira/projects/MXNET/issues) 
created (except PRs with tiny changes)
   - [X] Changes are complete (i.e. I finished coding on this PR)
   - [X] 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)
   - [X] 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
   - [X] To the my best knowledge, examples are either not affected by this 
change, or have been fixed to be compatible with this change

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to