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 2019/12/19 23:19:42 UTC

[GitHub] [incubator-mxnet] szha opened a new pull request #17128: [DEBUG] enable custom error type

szha opened a new pull request #17128: [DEBUG] enable custom error type
URL: https://github.com/apache/incubator-mxnet/pull/17128
 
 
   ## Description ##
   enable throwing custom error type from backend
   
   With this patch, by prepending error messages with the error type, the frontend will automatically throw exception of that type if the type has been registered.
   
   <details>
   <summary>An example in a check in transpose and its effect</summary>
   
   ### Logging in C++
   
   ```cpp
       CHECK_EQ(axes_set.size(), axes.ndim()) << "ValueError: Repeated axis in transpose."
                                              << " param.axes = "
                                              << param.axes;
   ```
   
   ### Effect
   
   ```python
   In [1]: from mxnet import np
   
   In [2]: dat = np.random.normal(0, 1, (3, 4, 5))
   
   In [3]: dat.transpose((0, 0, 1))
   ---------------------------------------------------------------------------
   ValueError                                Traceback (most recent call last)
   <ipython-input-3-3ad259b4e371> in <module>
   ----> 1 dat.transpose((0, 0, 1))
   
   ~/mxnet-distro/mxnet-build/python/mxnet/numpy/multiarray.py in transpose(self, *axes)
      1460             elif axes[0] is None:
      1461                 axes = None
   -> 1462         return _mx_np_op.transpose(self, axes=axes)
      1463
      1464     def flip(self, *args, **kwargs):
   
   ~/mxnet-distro/mxnet-build/python/mxnet/ndarray/register.py in transpose(a, axes, out, name, **kwargs)
   
   ~/mxnet-distro/mxnet-build/python/mxnet/_ctypes/ndarray.py in _imperative_invoke(handle, ndargs, keys, vals, out, is_np_op, output_is_list)
       105         c_str_array(keys),
       106         c_str_array([str(s) for s in vals]),
   --> 107         ctypes.byref(out_stypes)))
       108
       109     create_ndarray_fn = _np_ndarray_cls if is_np_op else _ndarray_cls
   
   ~/mxnet-distro/mxnet-build/python/mxnet/base.py in check_call(ret)
       271     """
       272     if ret != 0:
   --> 273         raise get_last_ffi_error()
       274
       275
   
   ValueError: Traceback (most recent call last):
     File "src/operator/numpy/np_matrix_op.cc", line 77
   ValueError: Check failed: axes_set.size() == axes.ndim() (2 vs. 3) : Repeated axis in transpose. param.axes = [0,0,1]
   
   ```
   
   </details>
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [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)
   - [x] Code is well-documented: 
   - For new C++ functions in header files, their functionalities and arguments are documented. 
   - [x] To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [x] Auto-detection for exception type in error message
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be made.
   - Interesting edge cases to note here
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] szha merged pull request #17128: [DEBUG] enable custom error type

Posted by GitBox <gi...@apache.org>.
szha merged pull request #17128: [DEBUG] enable custom error type
URL: https://github.com/apache/incubator-mxnet/pull/17128
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services