Skip to content

Commit e725ae7

Browse files
committed
Merge branch 'develop' into api
2 parents 44b6a5f + 968922b commit e725ae7

27 files changed

+134
-124
lines changed

benchmark/fluid/fluid_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def train_parallel(avg_loss, infer_prog, optimizer, train_reader, test_reader,
210210
# generate fake:
211211
if args.use_fake_data:
212212
for var in feed_var_list:
213-
v = startup_prog.global_block().clone_variable(var)
213+
v = startup_prog.global_block()._clone_variable(var)
214214
var.persistable = True
215215
v.persistable = True
216216

doc/fluid/design/modules/python_api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ class Block(objects):
9898
def append_operator(self, ...):
9999
self.ops.append(Operator(self, ...))
100100

101-
def prepend_operator(self, ...): # Parameter's ctor prepands initialize operators.
101+
def _prepend_operator(self, ...): # Parameter's ctor prepands initialize operators.
102102
self.ops.prepend(Operator(self, ...))
103103
```
104104

105105
`create_parameter` is necessary because parameters are global variables, defined in the global block, but can be created in some sub-blocks. For example, an FC layer in the step block of an RNN operator.
106106

107-
`prepend_operator` is necessary because the constructor of `Parameter` needs to create the initialize (or load) operator of the parameter, and would like to put it in the *preamble* of the global block.
107+
`_prepend_operator` is necessary because the constructor of `Parameter` needs to create the initialize (or load) operator of the parameter, and would like to put it in the *preamble* of the global block.
108108

109109
### Operator
110110

doc/fluid/howto/performance/error_clip.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def error_clip_callback(block, context):
7878
op_desc = block.desc.op(block.desc.op_size() - 1)
7979
for grad_n in filter(lambda n: grad_to_var.has_key(n),
8080
op_desc.output_arg_names()):
81-
fwd_var = block.var_recursive(grad_to_var[grad_n])
81+
fwd_var = block.__var_recursive(grad_to_var[grad_n])
8282
error_clip = getattr(fwd_var, "error_clip", None)
8383
if not (error_clip is None or isinstance(error_clip,
8484
BaseErrorClipAttr)):

doc/v2/build_and_install/build_from_source_cn.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,16 @@ PaddlePaddle需要使用Docker环境完成编译,这样可以免去单独安
3535
# 2. 可选步骤:源码中构建用于编译PaddlePaddle的Docker镜像
3636
docker build -t paddle:dev .
3737
# 3. 执行下面的命令编译CPU-Only的二进制
38-
docker run -it -v $PWD:/paddle -w /paddle -e "WITH_GPU=OFF" -e "WITH_TESTING=OFF" paddlepaddle/paddle_manylinux_devel:cuda8.0_cudnn5 ./paddle/scripts/paddle_build.sh build
38+
docker run -it -v $PWD:/paddle -w /paddle -e "PYTHON_ABI=cp27-cp27mu" -e "WITH_GPU=OFF" -e "WITH_TESTING=OFF" paddlepaddle/paddle_manylinux_devel:cuda8.0_cudnn5 ./paddle/scripts/paddle_build.sh build
3939
# 4. 或者也可以使用为上述可选步骤构建的镜像(必须先执行第2步)
4040
docker run -it -v $PWD:/paddle -w /paddle -e "WITH_GPU=OFF" -e "WITH_TESTING=OFF" paddle:dev ./paddle/scripts/paddle_build.sh build
4141
42-
注:上述命令把当前目录(源码树根目录)映射为 container 里的 :code:`/paddle` 目录。
42+
注:
43+
44+
- 上述命令把当前目录(源码树根目录)映射为 container 里的 :code:`/paddle` 目录。
45+
46+
- 如果您使用的是 manylinux 的镜像进行编译, 那么您需要通过环境变量 :code:`PYTHON_ABI` 来指定一个 `Python ABI <https://www.python.org/dev/peps/pep-0425/#id8>`__.
47+
PaddlePaddle目前支持的 Python ABI 有 :code:`cp27-cp27m` 和 :code:`cp27-cp27mu`.
4348

4449
编译完成后会在build/python/dist目录下生成输出的whl包,可以选在在当前机器安装也可以拷贝到目标机器安装:
4550

doc/v2/build_and_install/build_from_source_en.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ If you don't wish to use docker,you need to install several compile dependenci
3636
# 2. Optional: build development docker image from source
3737
docker build -t paddle:dev .
3838
# 3. Run the following command to build a CPU-Only binaries
39-
docker run -it -v $PWD:/paddle -w /paddle -e "WITH_GPU=OFF" -e "WITH_TESTING=OFF" paddlepaddle/paddle_manylinux_devel:cuda8.0_cudnn5 ./paddle/scripts/paddle_build.sh build
39+
docker run -it -v $PWD:/paddle -w /paddle -e "PYTHON_ABI=cp27-cp27mu" -e "WITH_GPU=OFF" -e "WITH_TESTING=OFF" paddlepaddle/paddle_manylinux_devel:cuda8.0_cudnn5 ./paddle/scripts/paddle_build.sh build
4040
# 4. Or, use your built Docker image to build PaddlePaddle (must run step 2)
4141
docker run -it -v $PWD:/paddle -w /paddle -e "WITH_GPU=OFF" -e "WITH_TESTING=OFF" paddle:dev ./paddle/scripts/paddle_build.sh build
4242
43-
NOTE: The above command try to mount the current working directory (root directory of source code)
43+
NOTE:
44+
45+
- The above command try to mount the current working directory (root directory of source code)
4446
into :code:`/paddle` directory inside docker container.
4547

48+
- You need to pass in the required environment variable :code:`PYTHON_ABI` to specify a `Python ABI <https://www.python.org/dev/peps/pep-0425/#id8>`__.
49+
Currently PaddlePaddle supported Python ABIs include :code:`cp27-cp27m` and :code:`cp27-cp27mu` .
50+
4651
When the compile finishes, you can get the output whl package under
4752
build/python/dist, then you can choose to install the whl on local
4853
machine or copy it to the target machine.

paddle/contrib/float16/float16_transpiler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def _remove_unused_var(self):
118118

119119
for var in self.block.vars.keys():
120120
if var not in args:
121-
self.block.remove_var(var)
121+
self.block._remove_var(var)
122122

123123
def _modify_feed_fetch(self):
124124
'''
@@ -165,7 +165,7 @@ def find_op(var):
165165
dtype=core.VarDesc.VarType.FP16,
166166
shape=var.shape,
167167
persistable=var.persistable)
168-
self.block.insert_op(
168+
self.block._insert_op(
169169
i + 1,
170170
type="cast",
171171
inputs={"X": var},
@@ -188,7 +188,7 @@ def find_op(var):
188188
persistable=var.persistable)
189189
find_op(var)
190190
var.op.rename_output(var_name, tmp_var_name)
191-
self.block.insert_op(
191+
self.block._insert_op(
192192
i,
193193
type="cast",
194194
inputs={"X": tmp_var},
@@ -253,4 +253,4 @@ def _should_be_converted(var):
253253

254254
# old var will be replaced by the fp16 var in program desc
255255
self.input_map[var.name] = fp16_var_name
256-
self.block.remove_var(var.name)
256+
self.block._remove_var(var.name)

paddle/fluid/pybind/protobuf.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ void BindBlockDesc(pybind11::module *m) {
145145
.def_property_readonly("id", &pd::BlockDesc::ID)
146146
.def_property_readonly("parent", &pd::BlockDesc::Parent)
147147
.def("get_forward_block_idx", &pd::BlockDesc::ForwardBlockID)
148-
.def("set_forward_block_idx", &pd::BlockDesc::SetForwardBlockID)
148+
.def("_set_forward_block_idx", &pd::BlockDesc::SetForwardBlockID)
149149
.def("append_op", &pd::BlockDesc::AppendOp,
150150
pybind11::return_value_policy::reference)
151-
.def("prepend_op", &pd::BlockDesc::PrependOp,
151+
.def("_prepend_op", &pd::BlockDesc::PrependOp,
152152
pybind11::return_value_policy::reference)
153-
.def("insert_op", &pd::BlockDesc::InsertOp,
153+
.def("_insert_op", &pd::BlockDesc::InsertOp,
154154
pybind11::return_value_policy::reference)
155-
.def("remove_op", &pd::BlockDesc::RemoveOp)
155+
.def("_remove_op", &pd::BlockDesc::RemoveOp)
156156
.def("var",
157157
[](pd::BlockDesc &self, pybind11::bytes byte_name) {
158158
std::string name = byte_name;
@@ -165,7 +165,7 @@ void BindBlockDesc(pybind11::module *m) {
165165
return self.HasVar(name);
166166
},
167167
pybind11::return_value_policy::reference)
168-
.def("rename_var",
168+
.def("_rename_var",
169169
[](pd::BlockDesc &self, const pybind11::bytes &byte_name,
170170
const pybind11::bytes &byte_name_new) {
171171
std::string name = byte_name;
@@ -189,7 +189,7 @@ void BindBlockDesc(pybind11::module *m) {
189189
return self.FindVarRecursive(name);
190190
},
191191
pybind11::return_value_policy::reference)
192-
.def("remove_var",
192+
.def("_remove_var",
193193
[](pd::BlockDesc &self, pybind11::bytes byte_name) {
194194
std::string name = byte_name;
195195
return self.RemoveVar(name);

python/paddle/fluid/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import recordio_writer
5757
import parallel_executor
5858
from parallel_executor import *
59+
from paddle.fluid.layers.math_op_patch import monkey_patch_variable
5960

6061
Tensor = LoDTensor
6162

@@ -138,5 +139,5 @@ def __bootstrap__():
138139

139140
# TODO(panyx0718): Avoid doing complex initialization logic in __init__.py.
140141
# Consider paddle.init(args) or paddle.main(args)
141-
layers.monkey_patch_variable()
142+
monkey_patch_variable()
142143
__bootstrap__()

python/paddle/fluid/backward.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def _append_backward_ops_(block,
328328
if op.has_attr("sub_block"):
329329
sub_block = program.block(op.block_attr("sub_block"))
330330
grad_sub_block = program.create_block()
331-
grad_sub_block.set_forward_block_idx(sub_block.idx)
331+
grad_sub_block._set_forward_block_idx(sub_block.idx)
332332
cb = _callback_lookup_(op)
333333
if cb is not None:
334334
if callbacks is None:
@@ -571,7 +571,7 @@ def append_backward(loss, parameter_list=None, no_grad_set=None,
571571
_append_backward_vars_(root_block, fwd_op_num, grad_to_var, grad_info_map)
572572

573573
program.current_block_idx = current_block_idx
574-
program.sync_with_cpp()
574+
program._sync_with_cpp()
575575
# FIXME(zcd): prevent loss.grad optimized by mem_opt.
576576
loss.block.var(_append_grad_suffix_(loss.name)).persistable = True
577577

@@ -744,7 +744,7 @@ def calc_gradient(targets, inputs, target_gradients=None, no_grad_set=None):
744744
_rename_grad_(block, fwd_op_num, grad_to_var, target_grad_map)
745745

746746
_append_backward_vars_(block, fwd_op_num, grad_to_var, grad_info_map)
747-
prog.sync_with_cpp()
747+
prog._sync_with_cpp()
748748

749749
grad_vars = []
750750
for input_var in inputs:

python/paddle/fluid/clip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def error_clip_callback(block, context):
8282
op_desc = block.desc.op(block.desc.op_size() - 1)
8383
for grad_n in filter(lambda n: grad_to_var.has_key(n),
8484
op_desc.output_arg_names()):
85-
fwd_var = block.var_recursive(grad_to_var[grad_n])
85+
fwd_var = block._var_recursive(grad_to_var[grad_n])
8686
error_clip = getattr(fwd_var, "error_clip", None)
8787
if not (error_clip is None or isinstance(error_clip,
8888
BaseErrorClipAttr)):

0 commit comments

Comments
 (0)