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/03/05 03:13:03 UTC

[GitHub] [incubator-mxnet] lanking520 commented on issue #11926: segfault in native code while trying to use CustomOp

lanking520 commented on issue #11926: segfault in native code while trying to use CustomOp
URL: https://github.com/apache/incubator-mxnet/issues/11926#issuecomment-469519405
 
 
   After some tests, your problem can be solved through this:
   ```
     Operator.register("constant", new ConstantOpProp())
     Operator.register("constant2", new ConstantOpProp())
   
     val value1 = NDArray.array(Array(-10f), Shape(1))
     val value2 = NDArray.array(Array(10f), Shape(1))
   
     val const1 = Symbol.Custom("constant-1")()(
       Map("id" -> 1, "op_type" -> "constant", "value" -> String.copyValueOf(value1.serialize().map(_.toChar)),
         "aaa" -> "aaa"
       )
     )
     val const2 = Symbol.Custom("constant-2")()(
       Map("id" -> 2, "op_type" -> "constant2", "value" -> String.copyValueOf(value2.serialize().map(_.toChar)),
         "bbb" -> "bbb"
       )
     )
   ```
   It will actually bring you the right result you need. The weird thing is the Custom Operator that being registered is an object shared along in the same state. The state is used in the Symbolic graph as you used in here. When you have two ops are defined in the same state, they will share the same kwargs as the Engine would thought they are the same since they all registered to the same op. The weird thing with Symbolic graph, it will only be analysed at the end in order to produce the best way to execute. That cause the overwrite problem you have. The same problem is not reproducible in sequential execution with NDArray.

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