samskalicky commented on a change in pull request #17034: Dynamic subgraph 
property
URL: https://github.com/apache/incubator-mxnet/pull/17034#discussion_r363558616
 
 

 ##########
 File path: example/extensions/lib_subgraph/test_subgraph.py
 ##########
 @@ -39,22 +39,38 @@
 b = mx.sym.var('b')
 c = a + b
 d = mx.sym.exp(c)
-ret = mx.sym.log(d)
+sym = mx.sym.log(d)
 
-op_names = ['exp','log']
-out = SymbolHandle()
+#execute in MXNet
+print('-------------------------------')
+print('Testing regular MXNet execution')
+exe = sym.bind(ctx=mx.cpu(), args={'a':mx.nd.ones((3,2)), 
'b':mx.nd.ones((3,2))})
+out = exe.forward()
+print(out)
 
-check_call(_LIB.MXBuildSubgraphByOpNames(ret.handle,
-                                         c_str('default'),
-                                         mx_uint(len(op_names)),
-                                         c_str_array(op_names),
-                                         ctypes.byref(out)))
-partitioned_sym = mx.sym.Symbol(out)
-json_sym = partitioned_sym.tojson()
+# with propogating shapes/types
+print('-------------------------------')
+print('Testing partitioning with shapes/types')
+arg_array = [mx.nd.ones((3,2),dtype='float32'), 
mx.nd.ones((3,2),dtype='float32')]
+mysym2 = sym.optimize_for("myProp",arg_array)
+print(mysym2.tojson())
+exe2 = mysym2.bind(ctx=mx.cpu(), args={'a':mx.nd.ones((3,2)), 
'b':mx.nd.ones((3,2))})
+out2 = exe2.forward()
+print(out2)
 
-mystr = json_sym.replace("_CachedOp","_custom_subgraph_op")
-mysym = mx.sym.load_json(mystr)
+# with propogating shapes/types, rejecting subgraph
+print('-------------------------------')
+print('Testing partitioning with shapes/types - rejecting subgraph')
+arg_array = [mx.nd.ones((3,2),dtype='float32'), 
mx.nd.ones((3,2),dtype='float32')]
+mysym2 = sym.optimize_for("myProp", arg_array, reject=True)
 
 Review comment:
   The same thing that will happen if you register two subgraph backends in 
MXNet today. One will overwrite the other (its a map).

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