Skip to content

Commit 0c7d6eb

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into port_python3_syntax
2 parents 3107318 + ec4c6e1 commit 0c7d6eb

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

paddle/fluid/framework/block_desc.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ class BlockDesc {
8888
OpDesc *InsertOp(size_t index);
8989

9090
/*
91-
* Remove Op and its input/output variables.
92-
* Note that for either input or output variable, if it is also an input or
93-
* output variable of other ops, we should remain it.
91+
* Only remove op itself,
92+
* do nothing to its input and output variables
9493
*/
9594
void RemoveOp(size_t s, size_t e);
9695

paddle/fluid/platform/cudnn_helper.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,12 @@ inline const char* cudnnGetErrorString(cudnnStatus_t status) {
5959
#define CUDNN_VERSION_MIN(major, minor, patch) \
6060
(CUDNN_VERSION >= ((major)*1000 + (minor)*100 + (patch)))
6161

62-
#define CUDNN_ENFORCE(condition) \
63-
do { \
64-
cudnnStatus_t status = condition; \
65-
if (status != CUDNN_STATUS_SUCCESS) { \
66-
VLOG(1) << ::paddle::platform::cudnnGetErrorString(status); \
67-
PADDLE_THROW("cuDNN call failed"); \
68-
} \
62+
#define CUDNN_ENFORCE(condition) \
63+
do { \
64+
cudnnStatus_t status = condition; \
65+
if (UNLIKELY(status != CUDNN_STATUS_SUCCESS)) { \
66+
PADDLE_THROW(::paddle::platform::cudnnGetErrorString(status)); \
67+
} \
6968
} while (false)
7069

7170
enum class DataLayout { // Not use

python/paddle/fluid/framework.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,12 @@ def prune(self, targets):
15551555

15561556
def inference_optimize(self):
15571557
"""
1558-
This method will create a new program and change the :code:`is_test`
1558+
This method will create a new program and do following adjustments on it:
1559+
1. Remove all reader variables and their creator ops if exist.
1560+
1561+
2. Remove the :code:`read_op` if exists.
1562+
1563+
3. change the :code:`is_test`
15591564
attribute of operators to :code:`True`. All the :code:`Parameter`
15601565
information will be lost.
15611566
@@ -1569,6 +1574,22 @@ def inference_optimize(self):
15691574
# core.inference_optimize being fixed.
15701575
res = Program()
15711576
res.desc = core.ProgramDesc(self.desc)
1577+
1578+
# remove all readers and the read_op if exist
1579+
read_op_idx = 0
1580+
root_block = res.desc.block(0)
1581+
while True:
1582+
if read_op_idx >= root_block.op_size() or root_block.op(
1583+
read_op_idx).type() == 'read':
1584+
break
1585+
read_op_idx += 1
1586+
if read_op_idx < root_block.op_size():
1587+
root_block._remove_op(0, read_op_idx + 1)
1588+
for var in root_block.all_vars():
1589+
if var.type() == core.VarDesc.VarType.READER:
1590+
root_block._remove_var(var.name())
1591+
1592+
# change all `is_test` attributes to True
15721593
for i in range(res.desc.num_blocks()):
15731594
block = res.desc.block(i)
15741595
for j in range(block.op_size()):

python/paddle/fluid/layers/io.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,6 @@ def random_data_generator(low, high, shapes, lod_levels, for_parallel=True):
443443
main_prog_var = _copy_reader_var_(default_main_program().current_block(),
444444
startup_var)
445445

446-
if for_parallel:
447-
main_prog_var = parallel(reader=main_prog_var)
448-
449446
return monkey_patch_reader_methods(main_prog_var)
450447

451448

0 commit comments

Comments
 (0)