Skip to content

Commit a59c3b7

Browse files
author
Yang Yang(Tony)
authored
change dynamic graph folder (#11451)
* change dynamic to tape * update readme link
1 parent d827c6e commit a59c3b7

File tree

10 files changed

+25
-19
lines changed

10 files changed

+25
-19
lines changed

paddle/contrib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
#
1515

1616
add_subdirectory(inference)
17-
add_subdirectory(dynamic)
17+
add_subdirectory(tape)

paddle/contrib/dynamic/README.md renamed to paddle/contrib/tape/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# Dynamic Graph on Fluid
22

3-
PaddlePaddle Fluid is targeting the autodiff without tape, which, however, is very challenging and we are still way from there. DyNet and PyTorch provide a good design idea, the *tape*, that significantly eases the challenge. Also, DyNet provides a C++ API that is as convenient as Python but with higher efficiency and could conveniently integrate with industrial/production systems. This package, `tape`, combines the good of
3+
PaddlePaddle Fluid is targeting the autodiff without tape, which, however, is very
4+
challenging and we are still way from there. DyNet and PyTorch provide a good design
5+
idea, the *tape*, that significantly eases the challenge. Also, DyNet provides
6+
a C++ API that is as convenient as Python but with higher efficiency and could
7+
conveniently integrate with industrial/production systems. This package, `tape`,
8+
combines the good of
49

510
1. tape from PyTorch and DyNet
611
2. C++ API and core from DyNet
712
3. rich set of operators from PaddlePaddle
813

914
## Overview
1015

11-
We can implement Dynet-like Tape(See this survey) by wrapping Paddle Fluid's `Operator`
12-
and `Variable`.
16+
We can implement Dynet-like Tape(See this [survey](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/survey/dynamic_graph.md))
17+
by wrapping Paddle Fluid's `Operator` and `Variable`.
1318

1419
The user API is straight forward since
1520

@@ -121,13 +126,14 @@ paddle::tape::SGD sgd(0.001);
121126
// Data Feeder
122127
paddle::tape::Fill data_feeder(...);
123128
VariableHandle input(new paddle::tape::Variable("input"));
129+
VariableHandle label(new paddle::tape::Variable("label"));
124130

125131
for (int i = 0; i < 2; ++i) {
126132
reset_global_tape();
127133

128-
data_feeder(input);
134+
data_feeder(input, label);
129135

130-
auto loss = mean(linear2(linear1(input))); // compile time InferShape & InferVarType
136+
auto loss = softmax(linear2(linear1(input)), label); // compile time InferShape & InferVarType
131137
LOG(INFO) << loss.value(); // Run forward up to loss
132138

133139
// Run backward, store gradient of w at w->Grad()
@@ -209,7 +215,7 @@ digraph G {
209215
}
210216
</details>
211217
212-
![Image](https://github.com/tonyyang-svail/Paddle/blob/cpp_tap/paddle/contrib/dynamic/computation_graph.png)
218+
![Image](https://github.com/tonyyang-svail/Paddle/blob/cpp_tap/paddle/contrib/tape/computation_graph.png)
213219
214220
## Code Reuse
215221

paddle/contrib/dynamic/function.h renamed to paddle/contrib/tape/function.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
#include <string>
1818

19-
#include "paddle/contrib/dynamic/tape.h"
20-
#include "paddle/contrib/dynamic/variable.h"
19+
#include "paddle/contrib/tape/tape.h"
20+
#include "paddle/contrib/tape/variable.h"
2121
#include "paddle/fluid/framework/type_defs.h"
2222

2323
namespace paddle {
24-
namespace dynamic {
24+
namespace tape {
2525

2626
class Function {};
2727

paddle/contrib/dynamic/tape.cc renamed to paddle/contrib/tape/tape.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "paddle/contrib/dynamic/tape.h"
15+
#include "paddle/contrib/tape/tape.h"
1616

1717
#include <list>
1818
#include <map>
@@ -29,7 +29,7 @@
2929
#include "paddle/fluid/pybind/pybind.h"
3030

3131
namespace paddle {
32-
namespace dynamic {
32+
namespace tape {
3333

3434
// borrowed from
3535
// https://stackoverflow.com/questions/874134/find-if-string-ends-with-another-string-in-c

paddle/contrib/dynamic/tape.h renamed to paddle/contrib/tape/tape.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#include <string>
1919
#include <vector>
2020

21-
#include "paddle/contrib/dynamic/variable.h"
21+
#include "paddle/contrib/tape/variable.h"
2222

2323
namespace paddle {
24-
namespace dynamic {
24+
namespace tape {
2525

2626
using VariableHandleMap = std::map<std::string, std::vector<VariableHandle>>;
2727

paddle/contrib/dynamic/test_tape.cc renamed to paddle/contrib/tape/test_tape.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
// limitations under the License.
1414

1515
#include "gtest/gtest.h"
16-
#include "paddle/contrib/dynamic/function.h"
16+
#include "paddle/contrib/tape/function.h"
1717

18-
using namespace paddle::dynamic;
18+
using namespace paddle::tape;
1919

2020
TEST(Tape, TestMLP) {
2121
LOG(INFO) << "TestMLP";

paddle/contrib/dynamic/variable.cc renamed to paddle/contrib/tape/variable.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "paddle/contrib/dynamic/variable.h"
15+
#include "paddle/contrib/tape/variable.h"
1616

1717
namespace paddle {
18-
namespace dynamic {
18+
namespace tape {
1919

2020
void Variable::InitializeVariable() {
2121
LOG(INFO) << "Initialzing " << desc_.Name() << " as " << desc_.GetType();

paddle/contrib/dynamic/variable.h renamed to paddle/contrib/tape/variable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "paddle/fluid/framework/variable.h"
2121

2222
namespace paddle {
23-
namespace dynamic {
23+
namespace tape {
2424

2525
class Variable;
2626
using VariableHandle = std::shared_ptr<Variable>;

0 commit comments

Comments
 (0)