diff --git a/doc/design/functions_operators_layers.md b/doc/design/functions_operators_layers.md index e4f8d303e8b55d43ac06113296edc3e8d7243c5c..7a2e8fd0ace2e3f4462b15215de22c31e944b7cb 100644 --- a/doc/design/functions_operators_layers.md +++ b/doc/design/functions_operators_layers.md @@ -42,7 +42,7 @@ class FCOp : public OperatorBase { void Run(...) { add(mul(Input("X"), Input("W")), Input("b"); } -};d +}; REGISTER_OP(FCOp, "fc"); ``` @@ -52,17 +52,17 @@ Let's explain using an example. Suppose that we are going to compose the FC usi ```python def operator.mul(X1, X2): - O = Var + O = Var() paddle.cpp.create_operator("mul", input={X1, Y1], output=O) return O def operator.add(X1, X2): - O = Var + O = Var() paddle.cpp.create_operator("add", input={X1, X2], output=O) return O ``` -so that we can define +Above code snippets are automatically generated. Given them, users can define ```python def layer.fc(X): @@ -71,6 +71,19 @@ def layer.fc(X): return operator.add(operator.mul(X, W), b) ``` +If we don't have `operator.mul` and `operator.add`, the definiton of `layer.fc` would be complicated: + +```python +def layer.fc(X): + W = Var() + b = Var() + O1 = Var() + paddle.cpp.create_operator("mul", input=[X, W], output=O1) + O2 = Var() + paddle.cpp.create_operator("add", input=[O1, b], output=O2) + return O2 +``` + We'd like to have Python bindings to operators in package `paddle.operator`, and Python compositions of operators in package `paddle.layer`. So we have the following concepts in above illustrative example: ```