Skip to content

Commit 26c230d

Browse files
authored
Merge pull request #2144 from Canpio/develop
add brief explanation about DDim usage in Majel
2 parents 16976b0 + 5af777d commit 26c230d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

paddle/majel/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ typedef boost::variant<
9393

9494
Because `variant` may be thought of as "multi-type, single value", we can utilize it to implement unified interfaces for PaddlePaddle.
9595

96+
`DDim` plays two kinds of roles in Majel. First, it is used to indicate the size of a tensor. For example, we can construct a new `DArray` by following way:
97+
98+
```c++
99+
DArray arr = make_darray(make_ddim({2,3}), 0.0f);
100+
```
101+
It means that `arr` will be a two-dimension tensor, or a matrix. The size of its first dimension is 2 and the second is 3. All the element value of `arr` will be initialized as 0.0 .
102+
103+
The second meaning of `DDim` is tensor index. For example, if we want to access the value in the 1st row and 2nd column of `arr` and set it to 1.0, we can do like this:
104+
105+
```c++
106+
arr[make_ddim({0, 1})] = 1.0;
107+
```
108+
96109
## implement Tensor in Paddle
97110

98111
Before writing code, please make sure you already look through Majel Source Code and grabbed the design philosophy of `DArray` in Majel.
@@ -113,7 +126,7 @@ To assign subtasks to our colleagues, we have to discuss how to divide it to ind
113126
114127
- [ ] 3. Re-implement `Dim`.
115128

116-
`Dim` is an excellent implementation in Majel.
129+
`Dim` is an excellent implementation in Majel.
117130

118131
> ???
119132

0 commit comments

Comments
 (0)