Skip to content

Commit 65fd84a

Browse files
author
kavyasrinet
authored
Updating Var_desc.md with the updated typing system in Fluid (#8462)
* Updating Var_desc.md with the updated typing system in Fluid * Added Channel to VarType
1 parent bd58bf3 commit 65fd84a

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

doc/design/var_desc.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## Background
22
PaddlePaddle divides the description of neural network computation into two stages: compile time and runtime. At compile time, the neural network computation is described as a `ProgramDesc` whereas at runtime an `Executor` interprets the `ProgramDesc` to compute the operations.
33

4-
PaddlePaddle use proto message to describe compile time program because
4+
PaddlePaddle uses proto message to describe compile time program because :
55

66
1. The computation program description must be serializable and saved in a file.
7-
1. During distributed training, the sreialized program will be sent to multiple workers. It should also be possible to break the program into different components, each of which can be executed on different workers.
7+
1. During distributed training, the serialized program will be sent to multiple workers. It should also be possible to break the program into different components, each of which can be executed on a different worker.
88

99
The computation `Program` consists of nested `Blocks`. Each `Block` will consist of data(i.e. `Variable`) and `Operations`. The concept to represent them is in the table below.
1010

@@ -14,40 +14,52 @@ The computation `Program` consists of nested `Blocks`. Each `Block` will consist
1414
|Operation|OpDesc(proto)|Operator(cpp)|
1515

1616

17-
## Definition of VarDesc
17+
## Definition of VarType
1818

19-
A VarDesc should have a name, and value. The are two kinds of variable type in compile time, they are `LoDTensor` and `SelectedRows`.
19+
A VarDesc should have a name, type and whether or not it is persistable. The are different kinds of variable types supported in PaddlePaddle, apart from the POD_Types like: `LOD_TENSOR`, `SELECTED_ROWS`, `FEED_MINIBATCH`, `FETCH_LIST`, `STEP_SCOPES`, `LOD_RANK_TABLE`, `LOD_TENSOR_ARRAY`, `PLACE_LIST`, `READER` and `CHANNEL`. These are declared inside `VarType`. A `VarDesc` then looks as the following:
2020

2121
```proto
2222
message VarDesc {
2323
required string name = 1;
24-
enum VarType {
25-
LOD_TENSOR = 0;
26-
SELECTED_ROWS = 1;
27-
}
2824
required VarType type = 2;
29-
optional LoDTensorDesc lod_desc = 3;
30-
optional TensorDesc selected_rows_desc = 4;
31-
optional bool persistable = 5 [ default = false ];
25+
optional bool persistable = 3 [ default = false ];
3226
}
3327
```
3428

3529
## Definition of TensorDesc
3630

3731
```proto
38-
enum DataType {
32+
message TensorDesc {
33+
// Should only be PODType. Is enforced in C++
34+
required Type data_type = 1;
35+
repeated int64 dims = 2; // [UNK, 640, 480] is saved as [-1, 640, 480]
36+
}
37+
```
38+
39+
The `Type` here comes from the enum defined inside of `VarType` :
40+
41+
```proto
42+
enum Type {
43+
// Pod Types
3944
BOOL = 0;
4045
INT16 = 1;
4146
INT32 = 2;
4247
INT64 = 3;
4348
FP16 = 4;
4449
FP32 = 5;
4550
FP64 = 6;
46-
}
4751
48-
message TensorDesc {
49-
required DataType data_type = 1;
50-
repeated int64 dims = 2; // [UNK, 640, 480] is saved as [-1, 640, 480]
52+
// Other types that may need additional descriptions
53+
LOD_TENSOR = 7;
54+
SELECTED_ROWS = 8;
55+
FEED_MINIBATCH = 9;
56+
FETCH_LIST = 10;
57+
STEP_SCOPES = 11;
58+
LOD_RANK_TABLE = 12;
59+
LOD_TENSOR_ARRAY = 13;
60+
PLACE_LIST = 14;
61+
READER = 15;
62+
CHANNEL = 16;
5163
}
5264
```
5365

@@ -58,7 +70,7 @@ A TensorDesc describes `SelectedRows` and `LoDTensor`. For details of `SelectedR
5870
```proto
5971
message LoDTensorDesc {
6072
required TensorDesc tensor = 1;
61-
optional int lod_level = 2;
73+
optional int32 lod_level = 2 [ default = 0 ];
6274
}
6375
```
6476

0 commit comments

Comments
 (0)