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 2018/10/25 09:33:35 UTC

[GitHub] wkcn opened a new pull request #12972: Support np.longlong on Linux and Fix issue #12843

wkcn opened a new pull request #12972: Support np.longlong on Linux and Fix issue #12843
URL: https://github.com/apache/incubator-mxnet/pull/12972
 
 
   ## Description ##
   On Linux x64, `str(numpy.longlong)` is "<class 'numpy.int64'>", however `numpy.longlong != numpy.int64`.
   Their in-build numpy types are different.
   
   `np.int64 == np.longlong` is True on Windows, False on Linux.
   `np.dtype(np.longlong).char` is 'q' on Windows x64 and Linux x64.
   `np.dtype(np.int64).char` is 'q' on Windows x64, 'l' on Linux x64.
   
   In fact, the C types of `np.longlong` and `np.int64` are the same.
   
   For the following code,
   ```python
   import mxnet as mx
   import numpy as np
   a = mx.nd.array([1,2,3], dtype=np.longlong)
   print (a, a.dtype)
   ```
   MXNet will raise the exception:
   ```
     File "/home/wkcn/proj/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 139, in _new_alloc_handle
       ctypes.c_int(int(_DTYPE_NP_TO_MX[np.dtype(dtype).type])),
   KeyError: <type 'numpy.int64'>
   ```
   
   I use `np.dtype(data_type).name` to get the name of C type to solve the problem.
   
   ## 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](https://issues.apache.org/jira/projects/MXNET/issues) 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)
   - [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
   - [ ] To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [x] Adding `_TYPE_NAME_NP_TO_MX`
   - [x] Adding the related unit-test

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services