Skip to content

Commit 3b48602

Browse files
authored
Change LoDTensorArray to DenseTensorArray (#6946)
1 parent 70a1456 commit 3b48602

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

docs/api/paddle/static/nn/while_loop_cn.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ ____________________________________
1616
:::::::::
1717

1818
- **cond** (callable) - 返回 boolean 类型 Tensor 的可调用函数,用以判断循环是否继续执行。``cond`` 的参数和 ``loop_vars`` 相对应。
19-
- **body** (callable) - 循环执行的结构体。其返回一个包含 tensor 或 LoDTensorArray 的列表或元组,且这些 tensor 或 LoDTensorArray 的长度,结构,类型和 ``loop_vars`` 中的相同。且``body`` 的参数与 ``loop_vars`` 相对应。
20-
- **loop_vars** (list|tuple) - 包含 tensor 或 LoDTensorArray 的列表或是元组,将其传入至 ``cond`` 和 ``body`` 中,得到循环条件和输出值。
19+
- **body** (callable) - 循环执行的结构体。其返回一个包含 tensor 或 DenseTensorArray 的列表或元组,且这些 tensor 或 DenseTensorArray 的长度,结构,类型和 ``loop_vars`` 中的相同。且``body`` 的参数与 ``loop_vars`` 相对应。
20+
- **loop_vars** (list|tuple) - 包含 tensor 或 DenseTensorArray 的列表或是元组,将其传入至 ``cond`` 和 ``body`` 中,得到循环条件和输出值。
2121
- **is_test** (bool,可选) - 用于表明是否在测试阶段执行,默认值为 False。
2222
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
2323

docs/design/concepts/python_data_feeding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ In the former implementation of Paddle Fluid, there are two ways to feed data:
66

77
- Feed data directly using `DataFeeder.feed()` in Python codes. It is more flexible than the first way. Many kinds of preprocessing steps can be performed before feeding using Python or any other languages, instead of adding many uncommon `operators` in C++ side. But this method is less efficient: the program cannot read the next mini-batch data before `Executor::Run()` ends. Moreover, `decorated_readers` such as `double_buffer_reader` cannot be used for better performance.
88

9-
In this document, we design a Python Data Feeding process combining the efficiency of the first way and the flexibility of the second way. A data queue `LoDTensorBlockingQueue` is designed to be shared by the Python and C++ side, while `LoDTensorArray` is pushed into the queue in Python side and `reader_op` in C++ side reads out the data from the queue.
9+
In this document, we design a Python Data Feeding process combining the efficiency of the first way and the flexibility of the second way. A data queue `LoDTensorBlockingQueue` is designed to be shared by the Python and C++ side, while `DenseTensorArray` is pushed into the queue in Python side and `reader_op` in C++ side reads out the data from the queue.
1010

1111

1212
## Design of LoDTensorBlockingQueue

docs/design/concurrent/channel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fluid.channel_close(ch)
4141
### Send data to a channel
4242

4343
Sends a variable to a channel. Currently, variables of dtype `LoDTensor`,
44-
`LoDRankTable`, `LoDTensorArray`, `SelectedRows`, `ReaderHolder`, and
44+
`LoDRankTable`, `DenseTensorArray`, `SelectedRows`, `ReaderHolder`, and
4545
`ChannelHolder` are supported.
4646

4747
By default, the data of the Variable is moved from the sender to the receiver,

docs/guides/jit/case_analysis_cn.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,12 @@ out = convert_ifelse(paddle.mean(x) > 5.0, true_fn_0, false_fn_0, (x,), (x,), (o
344344
```
345345

346346

347-
### 8.1 list 与 LoDTensorArray
347+
### 8.1 list 与 DenseTensorArray
348348

349349
当控制流中,出现了 ``list.append`` 类似语法时,情况会有一点点特殊。
350350

351351
Paddle 框架中的 ``cond_op`` 和 [``while_loop``](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/static/nn/while_loop_cn.html#while-loop) 对输入和返回类型有一个要求:
352-
> 输入或者返回类型必须是:LoDTensor 或者 LoDTensorArray <br><br>
352+
> 输入或者返回类型必须是:LoDTensor 或者 DenseTensorArray <br><br>
353353
> 即:不支持其他非 LoDTensor 类型
354354

355355
因此控制流中类似:
@@ -370,7 +370,7 @@ def forward(self, x):
370370

371371
def forward(x):
372372
bs = paddle.shape(x)[0] # <---- bs 是个静态图 Variable, shape = (1, )
373-
outs = paddle.tensor.create_array(dtype='float32') # <--- list 转为 LoDTensorArray
373+
outs = paddle.tensor.create_array(dtype='float32') # <--- list 转为 DenseTensorArray
374374
i = 0
375375

376376
def for_loop_condition_0(outs, bs, i, x):
@@ -391,8 +391,8 @@ def forward(x):
391391

392392
关于 控制流中包含 ``list`` 相关操作的几点说明:
393393

394-
+ **并非所有**list 都会转为 ``LoDTensorArray``
395-
> 只有在此控制流语句是依赖 ``Tensor`` 时,才会触发 ``list`` &rarr; ``LoDTensorArray`` 的转换
394+
+ **并非所有**list 都会转为 ``DenseTensorArray``
395+
> 只有在此控制流语句是依赖 ``Tensor`` 时,才会触发 ``list`` &rarr; ``DenseTensorArray`` 的转换
396396

397397
+ 暂不支持依赖 Tensor 的控制流中,使用多层嵌套的 ``list.append`` 操作
398398

@@ -407,7 +407,7 @@ def forward(x):
407407
return outs
408408
```
409409

410-
> 因为框架底层的 ``LoDTensorArray = std::vector< LoDTensor >`` ,不支持两层以上 ``vector`` 嵌套
410+
> 因为框架底层的 ``DenseTensorArray = std::vector< LoDTensor >`` ,不支持两层以上 ``vector`` 嵌套
411411

412412

413413
### 8.2 x.shape 与 paddle.shape(x)

0 commit comments

Comments
 (0)