eric-haibin-lin commented on a change in pull request #10451: [MXNET-432] Add
Foreach
URL: https://github.com/apache/incubator-mxnet/pull/10451#discussion_r189713523
##########
File path: python/mxnet/symbol/contrib.py
##########
@@ -91,3 +98,176 @@ def rand_zipfian(true_classes, num_sampled, range_max):
expected_prob_sampled = ((sampled_cls_fp64 + 2.0) / (sampled_cls_fp64 +
1.0)).log() / log_range
expected_count_sampled = expected_prob_sampled * num_sampled
return sampled_classes, expected_count_true, expected_count_sampled
+
+def _get_graph_inputs(subg):
+ num_handles = ctypes.c_int(1000)
+ handles = c_array(SymbolHandle, [SymbolHandle(0) for i in range(1000)])
+ check_call(_LIB.MXSymbolGetInputSymbols(subg.handle, handles,
ctypes.byref(num_handles)))
+
+ syms = []
+ for i in range(num_handles.value):
+ s = Symbol(handles[i])
+ syms.append(s)
+ return syms
+
+def foreach(func, data, init_states, name="foreach"):
+ """Run a for loop with user-defined computation over NDArrays on dimension
0.
Review comment:
NDArrays -> Symbols?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services