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


   ## Description ##
   Related issue: #19921
   
   When `group=0`, the `mxnet.gluon.nn.Conv1D(Conv2D, Conv3D)` will cause 
crashes(floating point exception)
   
   ```
   11396 Floating point exception(core dumped) python test-mxnet.py
   ```
   MxNet doesn't seem to have checked whether `group=0`. This pr adds check for 
group not equal zero in `src/operator/nn/convolution.cc`. Now the error message 
will be like this.
   
   ```
   Traceback (most recent call last):
     File "test-mxnet.py", line 14, in <module>
       nn.Conv3D(channels=1, kernel_size=1, groups=0)
     File "/mxnet/python/mxnet/gluon/nn/conv_layers.py", line 401, in __init__
       in_channels, activation, use_bias, weight_initializer, bias_initializer, 
**kwargs)
     File "/mxnet/python/mxnet/gluon/nn/conv_layers.py", line 115, in __init__
       wshapes = _infer_weight_shape(op_name, dshape, self._kwargs)
     File "/mxnet/python/mxnet/gluon/nn/conv_layers.py", line 38, in 
_infer_weight_shape
       return sym.infer_shape_partial()[0]
     File "/mxnetpython/mxnet/symbol/symbol.py", line 1068, in 
infer_shape_partial
       return self._infer_shape_impl(True, *args, **kwargs)
     File "/mxnet/python/mxnet/symbol/symbol.py", line 1126, in 
_infer_shape_impl
       ctypes.byref(complete)))
     File "/PARA/blsc365/wangjian/mxnet-1.4.1-sleep/python/mxnet/base.py", line 
252, in check_call
       raise MXNetError(py_str(_LIB.MXGetLastError()))
   mxnet.base.MXNetError: Error in operator conv1_convolution0: [17:48:51] 
src/operator/nn/convolution.cc:215: Check failed: param_.num_group != 0U (0 vs. 
0) num_group must be nonzero
   ```
   
   We can use the following code to test.
   
   ```
   import mxnet
   mxnet.gluon.nn.Conv1D(channels=1, kernel_size=1, groups=0)
   ```
   ```
   import mxnet
   mxnet.gluon.nn.Conv2D(channels=1, kernel_size=1, groups=0)
   ```
   ```
   import mxnet
   mxnet.gluon.nn.Conv3D(channels=1, kernel_size=1, groups=0)
   ```
   
   
   ## 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
   - [x] Code is well-documented
   
   ### 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
   


-- 
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]


Reply via email to