-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design of IfThenElse operator and layer #3119
Comments
need a
maybe
|
Tensorflow has a switch_op, and merge_op looks like this:
cond: a bool scalar In TF, it calls like this: x = tf.constant(2)
y = tf.constant(5)
def f1(): return tf.multiply(x, 17)
def f2(): return tf.add(y, 23)
r = tf.cond(tf.less(x, y), f1, f2) r is set to f1(). Since we are dynamic in Paddle, we need one more arguments input, the data to operate on
cond: a bool vector Our dynamic case |
That works fine. But I've no idea how to mark the inputs with the original orders, for example, in infer period, the Do every input instance need an order id? by which the outputs are sorted? |
It's possible that the true and false branches need different input, so the interface should be like: |
For the actual user interface, it should be possible to make it such that the user does not need to specify input or input_false. The framework can figure out the input of f_true and f_false automatically. |
Closed since |
After talking with @zchen0211 and @Canpio , here is the very early draft of the idea of
IfThenElse
operator and layer:A Simple Example
The Python Application Program
FC Layer as a Python Function
FC Operator as a C++ Class
The IfThenElse Layer and Operator
Another Example Using IfThenElse Layer
The IfThenElse Layer
The IfThenElseOp C++ Class
The text was updated successfully, but these errors were encountered: