An actual Fluid example is described [here](https://github.com/PaddlePaddle/Paddle/blob/a91efdde6910ce92a78e3aa7157412c4c88d9ee8/python/paddle/v2/fluid/tests/test_while_op.py#L36-L44).
An actual Fluid example is described [here](https://github.com/PaddlePaddle/Paddle/blob/bde090a97564b9c61a6aaa38b72ccc4889d102d9/python/paddle/fluid/tests/unittests/test_while_op.py#L50-L58).
From the example, the Fluid programs look very similar to their PyTorch equivalent programs, except that Fluid's loop structure, wrapped with Python's `with` statement, could run much faster than just a Python loop.
@@ -101,7 +101,7 @@ In-place is a built-in attribute of an operator. Since we treat in-place and oth
#### contruct control flow graph
Following is the ProgramDesc protobuf of [machine translation](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/tests/book/test_machine_translation.py) example.
Following is the ProgramDesc protobuf of [machine translation](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/tests/book/test_machine_translation.py) example.
Please find the complete demo from [here](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/tests/book_distribute/notest_dist_fit_a_line.py).
Please find the complete demo from [here](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/tests/book_distribute/notest_dist_fit_a_line.py).
First `cd` into the folder that contains the `python` files. In this case:
```bash
cd /paddle/python/paddle/v2/fluid/tests/book_distribute
cd /paddle/python/paddle/fluid/tests/book_distribute
```
In parameter server node run the following in the command line:
- Variables: `x`, `y`, `y_predict`, `cost` and `avg_cost`. [Python](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/framework.py#)
- Layers: `fluid.layers.data`, `fluid.layers.fc` and `fluid.layers.mean` are layers. [Python](https://github.com/PaddlePaddle/Paddle/tree/develop/python/paddle/v2/fluid/layers)
- Variables: `x`, `y`, `y_predict`, `cost` and `avg_cost`. [Python](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/framework.py#)
- Layers: `fluid.layers.data`, `fluid.layers.fc` and `fluid.layers.mean` are layers. [Python](https://github.com/PaddlePaddle/Paddle/tree/develop/python/paddle/fluid/layers)
- Every Layer has one or more operators and variables/parameters
- All the operators are defined at [`paddle/operators/`](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/operators). Other worth-looking files:
- Base class: [`paddle/framework/operator.h`](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/framework/operator.h)
<p>An actual Fluid example is described <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/a91efdde6910ce92a78e3aa7157412c4c88d9ee8/python/paddle/v2/fluid/tests/test_while_op.py#L36-L44">here</a>.</p>
<p>An actual Fluid example is described <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/bde090a97564b9c61a6aaa38b72ccc4889d102d9/python/paddle/fluid/tests/unittests/test_while_op.py#L50-L58">here</a>.</p>
<p>From the example, the Fluid programs look very similar to their PyTorch equivalent programs, except that Fluid’s loop structure, wrapped with Python’s <codeclass="docutils literal"><spanclass="pre">with</span></code> statement, could run much faster than just a Python loop.</p>
<p>We have more examples of the <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/if_else_op.md"><codeclass="docutils literal"><spanclass="pre">if-then-else</span></code></a> structure of Fluid.</p>
<spanid="contruct-control-flow-graph"></span><h4>contruct control flow graph<aclass="headerlink"href="#contruct-control-flow-graph"title="Permalink to this headline">¶</a></h4>
<p>Following is the ProgramDesc protobuf of <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/tests/book/test_machine_translation.py">machine translation</a> example.</p>
<p>Following is the ProgramDesc protobuf of <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/tests/book/test_machine_translation.py">machine translation</a> example.</p>
<p>Let’s take <aclass="reference external"href="http://www.paddlepaddle.org/docs/develop/book/01.fit_a_line/index.html">Deep Learning 101</a>‘s first chapter: “fit a line” as an example.</p>
<p>The non-cluster version of this demo with fluid API is as follows:</p>
<spanid="e2e-demo"></span><h3>E2E demo<aclass="headerlink"href="#e2e-demo"title="Permalink to this headline">¶</a></h3>
<p>Please find the complete demo from <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/tests/book_distribute/notest_dist_fit_a_line.py">here</a>.
<p>Please find the complete demo from <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/tests/book_distribute/notest_dist_fit_a_line.py">here</a>.
First <codeclass="docutils literal"><spanclass="pre">cd</span></code> into the folder that contains the <codeclass="docutils literal"><spanclass="pre">python</span></code> files. In this case:</p>
<p>We can see that the most time-consuming function is the <codeclass="docutils literal"><spanclass="pre">built-in</span><spanclass="pre">method</span><spanclass="pre">run</span></code>, which is a C++ function in <codeclass="docutils literal"><spanclass="pre">libpaddle.so</span></code>. We will
...
...
@@ -257,9 +257,9 @@ Python function. We can click it to understand more about it:</p>
<spanid="paddlepaddle-fluid-source-code-overview"></span><h1>PaddlePaddle Fluid Source Code Overview<aclass="headerlink"href="#paddlepaddle-fluid-source-code-overview"title="Permalink to this headline">¶</a></h1>
<li>Layers: <codeclass="docutils literal"><spanclass="pre">fluid.layers.data</span></code>, <codeclass="docutils literal"><spanclass="pre">fluid.layers.fc</span></code> and <codeclass="docutils literal"><spanclass="pre">fluid.layers.mean</span></code> are layers. <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/tree/develop/python/paddle/fluid/layers">Python</a><ul>
<li>Every Layer has one or more operators and variables/parameters<ul>
<li>All the operators are defined at <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/operators"><codeclass="docutils literal"><spanclass="pre">paddle/operators/</span></code></a>. Other worth-looking files:<ul>
<li>The device handle are at <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/platform/device_context.h">paddle/platform/device_context.h</a></li>
An actual Fluid example is described [here](https://github.com/PaddlePaddle/Paddle/blob/a91efdde6910ce92a78e3aa7157412c4c88d9ee8/python/paddle/v2/fluid/tests/test_while_op.py#L36-L44).
An actual Fluid example is described [here](https://github.com/PaddlePaddle/Paddle/blob/bde090a97564b9c61a6aaa38b72ccc4889d102d9/python/paddle/fluid/tests/unittests/test_while_op.py#L50-L58).
From the example, the Fluid programs look very similar to their PyTorch equivalent programs, except that Fluid's loop structure, wrapped with Python's `with` statement, could run much faster than just a Python loop.
@@ -101,7 +101,7 @@ In-place is a built-in attribute of an operator. Since we treat in-place and oth
#### contruct control flow graph
Following is the ProgramDesc protobuf of [machine translation](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/tests/book/test_machine_translation.py) example.
Following is the ProgramDesc protobuf of [machine translation](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/tests/book/test_machine_translation.py) example.
- Variables: `x`, `y`, `y_predict`, `cost` and `avg_cost`. [Python](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/framework.py#)
- Layers: `fluid.layers.data`, `fluid.layers.fc` and `fluid.layers.mean` are layers. [Python](https://github.com/PaddlePaddle/Paddle/tree/develop/python/paddle/v2/fluid/layers)
- Variables: `x`, `y`, `y_predict`, `cost` and `avg_cost`. [Python](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/framework.py#)
- Layers: `fluid.layers.data`, `fluid.layers.fc` and `fluid.layers.mean` are layers. [Python](https://github.com/PaddlePaddle/Paddle/tree/develop/python/paddle/fluid/layers)
- Every Layer has one or more operators and variables/parameters
- All the operators are defined at [`paddle/operators/`](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/operators). Other worth-looking files:
- Base class: [`paddle/framework/operator.h`](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/framework/operator.h)
<p>An actual Fluid example is described <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/a91efdde6910ce92a78e3aa7157412c4c88d9ee8/python/paddle/v2/fluid/tests/test_while_op.py#L36-L44">here</a>.</p>
<p>An actual Fluid example is described <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/bde090a97564b9c61a6aaa38b72ccc4889d102d9/python/paddle/fluid/tests/unittests/test_while_op.py#L50-L58">here</a>.</p>
<p>From the example, the Fluid programs look very similar to their PyTorch equivalent programs, except that Fluid’s loop structure, wrapped with Python’s <codeclass="docutils literal"><spanclass="pre">with</span></code> statement, could run much faster than just a Python loop.</p>
<p>We have more examples of the <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/if_else_op.md"><codeclass="docutils literal"><spanclass="pre">if-then-else</span></code></a> structure of Fluid.</p>
<spanid="contruct-control-flow-graph"></span><h4>contruct control flow graph<aclass="headerlink"href="#contruct-control-flow-graph"title="永久链接至标题">¶</a></h4>
<p>Following is the ProgramDesc protobuf of <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/tests/book/test_machine_translation.py">machine translation</a> example.</p>
<p>Following is the ProgramDesc protobuf of <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/tests/book/test_machine_translation.py">machine translation</a> example.</p>
<li>Layers: <codeclass="docutils literal"><spanclass="pre">fluid.layers.data</span></code>, <codeclass="docutils literal"><spanclass="pre">fluid.layers.fc</span></code> and <codeclass="docutils literal"><spanclass="pre">fluid.layers.mean</span></code> are layers. <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/tree/develop/python/paddle/fluid/layers">Python</a><ul>
<li>Every Layer has one or more operators and variables/parameters<ul>
<li>All the operators are defined at <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/operators"><codeclass="docutils literal"><spanclass="pre">paddle/operators/</span></code></a>. Other worth-looking files:<ul>
<li>The device handle are at <aclass="reference external"href="https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/platform/device_context.h">paddle/platform/device_context.h</a></li>