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 2018/07/10 00:40:28 UTC
[GitHub] piiswrong commented on a change in pull request #11566: [MXNET-626]
Add while_loop
piiswrong commented on a change in pull request #11566: [MXNET-626] Add while_loop
URL: https://github.com/apache/incubator-mxnet/pull/11566#discussion_r201175882
##########
File path: python/mxnet/ndarray/contrib.py
##########
@@ -191,3 +191,128 @@ def check_input(inputs, in_type, msg):
if not_data_list and len(outputs) == 1:
outputs = outputs[0]
return (outputs, states)
+
+
+def while_loop(loop_vars, cond, func, max_iterations):
+ """Run a while loop with user-defined computation and loop condition.
+
+ This operator simulates a while loop which iterately does customized computation
+ as long as the condition is satisfied.
+
+ `loop_vars` is a list of NDArrays on which the computation uses.
+
+ `cond` is a user-defined function as the loop condition.
+ It consumes `loop_vars`, and produces a scalar MXNet NDArray,
+ indicating the termination of the loop.
+ The loop ends when `cond` returns false (zero).
+ The `cond` is variadic, and its signature should be
+ `cond(*loop_vars) => NDArray`.
+
+ `func` is a user-defined function as the loop body.
+ It also consumes `loop_vars`, and produces `step_output` and `new_loop_vars` at each step.
+ The number of elements, shape, dtype of each element in `step_output` should be consistent.
Review comment:
what does consistent mean?
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services