Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2e8a95c8
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2e8a95c8
编写于
9月 04, 2018
作者:
X
Xin Pan
提交者:
GitHub
9月 04, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13179 from velconia/015_for_prelu_local
Port release 0.15.0 code to Python3.5
上级
24f5bc39
fb1a9fc6
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
76 addition
and
54 deletion
+76
-54
paddle/fluid/framework/ir/graph_test.cc
paddle/fluid/framework/ir/graph_test.cc
+3
-1
paddle/scripts/paddle_build.sh
paddle/scripts/paddle_build.sh
+6
-1
python/paddle/fluid/tests/unittests/CMakeLists.txt
python/paddle/fluid/tests/unittests/CMakeLists.txt
+1
-0
python/paddle/fluid/tests/unittests/dist_transformer.py
python/paddle/fluid/tests/unittests/dist_transformer.py
+20
-14
python/paddle/fluid/tests/unittests/test_desc_clone.py
python/paddle/fluid/tests/unittests/test_desc_clone.py
+12
-12
python/paddle/fluid/tests/unittests/test_dist_transpiler.py
python/paddle/fluid/tests/unittests/test_dist_transpiler.py
+1
-0
python/paddle/fluid/tests/unittests/test_prelu_op.py
python/paddle/fluid/tests/unittests/test_prelu_op.py
+17
-15
python/paddle/fluid/transpiler/distribute_transpiler.py
python/paddle/fluid/transpiler/distribute_transpiler.py
+7
-7
tools/check_ctest_hung.py
tools/check_ctest_hung.py
+3
-1
tools/print_signatures.py
tools/print_signatures.py
+3
-1
tools/timeline.py
tools/timeline.py
+3
-2
未找到文件。
paddle/fluid/framework/ir/graph_test.cc
浏览文件 @
2e8a95c8
...
@@ -200,9 +200,11 @@ TEST(GraphTest, WriteAfterWrite) {
...
@@ -200,9 +200,11 @@ TEST(GraphTest, WriteAfterWrite) {
ASSERT_TRUE
(
ir
::
IsControlDepVar
(
*
n
->
inputs
[
1
]));
ASSERT_TRUE
(
ir
::
IsControlDepVar
(
*
n
->
inputs
[
1
]));
control_dep2
=
n
->
inputs
[
1
];
control_dep2
=
n
->
inputs
[
1
];
ASSERT_EQ
(
n
->
inputs
.
size
(),
2
);
ASSERT_EQ
(
n
->
inputs
.
size
(),
2
);
ASSERT_EQ
(
control_dep1
,
control_dep2
);
}
}
}
}
ASSERT_NE
(
control_dep1
,
nullptr
);
ASSERT_NE
(
control_dep2
,
nullptr
);
ASSERT_EQ
(
control_dep1
,
control_dep2
);
}
}
}
// namespace framework
}
// namespace framework
}
// namespace paddle
}
// namespace paddle
paddle/scripts/paddle_build.sh
浏览文件 @
2e8a95c8
...
@@ -330,6 +330,11 @@ function assert_api_not_changed() {
...
@@ -330,6 +330,11 @@ function assert_api_not_changed() {
source
.env/bin/activate
source
.env/bin/activate
pip
install
${
PADDLE_ROOT
}
/build/python/dist/
*
whl
pip
install
${
PADDLE_ROOT
}
/build/python/dist/
*
whl
python
${
PADDLE_ROOT
}
/tools/print_signatures.py paddle.fluid
>
new.spec
python
${
PADDLE_ROOT
}
/tools/print_signatures.py paddle.fluid
>
new.spec
if
[
"
$1
"
==
"cp35-cp35m"
]
;
then
# Use sed to make python2 and python3 sepc keeps the same
sed
-i
's/arg0: str/arg0: unicode/g'
new.spec
sed
-i
"s/
\(
.*Transpiler.*
\)
.__init__ ArgSpec(args=
\[
'self'].*/
\1
.__init__ /g"
new.spec
fi
python
${
PADDLE_ROOT
}
/tools/diff_api.py
${
PADDLE_ROOT
}
/paddle/fluid/API.spec new.spec
python
${
PADDLE_ROOT
}
/tools/diff_api.py
${
PADDLE_ROOT
}
/paddle/fluid/API.spec new.spec
deactivate
deactivate
...
@@ -623,7 +628,7 @@ function main() {
...
@@ -623,7 +628,7 @@ function main() {
gen_capi_package
gen_capi_package
gen_fluid_inference_lib
gen_fluid_inference_lib
test_fluid_inference_lib
test_fluid_inference_lib
assert_api_not_changed
assert_api_not_changed
${
PYTHON_ABI
:-
""
}
;;
;;
*
)
*
)
print_usage
print_usage
...
...
python/paddle/fluid/tests/unittests/CMakeLists.txt
浏览文件 @
2e8a95c8
...
@@ -64,6 +64,7 @@ if(WITH_DISTRIBUTE)
...
@@ -64,6 +64,7 @@ if(WITH_DISTRIBUTE)
endif
()
endif
()
py_test_modules
(
test_parallel_executor_crf MODULES test_parallel_executor_crf SERIAL
)
py_test_modules
(
test_parallel_executor_crf MODULES test_parallel_executor_crf SERIAL
)
py_test_modules
(
test_parallel_executor_fetch_feed MODULES test_parallel_executor_fetch_feed SERIAL
)
py_test_modules
(
test_parallel_executor_fetch_feed MODULES test_parallel_executor_fetch_feed SERIAL
)
set_tests_properties
(
test_parallel_executor_fetch_feed PROPERTIES TIMEOUT 150
)
py_test_modules
(
test_dist_transformer MODULES test_dist_transformer SERIAL
)
py_test_modules
(
test_dist_transformer MODULES test_dist_transformer SERIAL
)
py_test_modules
(
test_dist_se_resnext MODULES test_dist_se_resnext SERIAL
)
py_test_modules
(
test_dist_se_resnext MODULES test_dist_se_resnext SERIAL
)
py_test_modules
(
test_parallel_executor_transformer MODULES test_parallel_executor_transformer SERIAL
)
py_test_modules
(
test_parallel_executor_transformer MODULES test_parallel_executor_transformer SERIAL
)
...
...
python/paddle/fluid/tests/unittests/dist_transformer.py
浏览文件 @
2e8a95c8
...
@@ -36,6 +36,7 @@ import paddle.fluid as fluid
...
@@ -36,6 +36,7 @@ import paddle.fluid as fluid
import
paddle.fluid.layers
as
layers
import
paddle.fluid.layers
as
layers
from
paddle.fluid
import
core
from
paddle.fluid
import
core
from
test_dist_base
import
TestDistRunnerBase
,
runtime_main
from
test_dist_base
import
TestDistRunnerBase
,
runtime_main
import
paddle.compat
as
cpt
from
paddle.compat
import
long_type
from
paddle.compat
import
long_type
import
hashlib
import
hashlib
...
@@ -315,8 +316,9 @@ def pad_batch_data(insts,
...
@@ -315,8 +316,9 @@ def pad_batch_data(insts,
"""
"""
return_list
=
[]
return_list
=
[]
max_len
=
max
(
len
(
inst
)
for
inst
in
insts
)
max_len
=
max
(
len
(
inst
)
for
inst
in
insts
)
num_token
=
reduce
(
lambda
x
,
y
:
x
+
y
,
num_token
=
six
.
moves
.
reduce
(
[
len
(
inst
)
for
inst
in
insts
])
if
return_num_token
else
0
lambda
x
,
y
:
x
+
y
,
[
len
(
inst
)
for
inst
in
insts
])
if
return_num_token
else
0
# Any token included in dict can be used to pad, since the paddings' loss
# Any token included in dict can be used to pad, since the paddings' loss
# will be masked out by weights and make no effect on parameter gradients.
# will be masked out by weights and make no effect on parameter gradients.
inst_data
=
np
.
array
(
inst_data
=
np
.
array
(
...
@@ -328,7 +330,7 @@ def pad_batch_data(insts,
...
@@ -328,7 +330,7 @@ def pad_batch_data(insts,
return_list
+=
[
inst_weight
.
astype
(
"float32"
).
reshape
([
-
1
,
1
])]
return_list
+=
[
inst_weight
.
astype
(
"float32"
).
reshape
([
-
1
,
1
])]
else
:
# position data
else
:
# position data
inst_pos
=
np
.
array
([
inst_pos
=
np
.
array
([
range
(
1
,
len
(
inst
)
+
1
)
+
[
0
]
*
(
max_len
-
len
(
inst
))
list
(
range
(
1
,
len
(
inst
)
+
1
)
)
+
[
0
]
*
(
max_len
-
len
(
inst
))
for
inst
in
insts
for
inst
in
insts
])
])
return_list
+=
[
inst_pos
.
astype
(
"int64"
).
reshape
([
-
1
,
1
])]
return_list
+=
[
inst_pos
.
astype
(
"int64"
).
reshape
([
-
1
,
1
])]
...
@@ -385,10 +387,11 @@ def prepare_batch_input(insts, data_input_names, src_pad_idx, trg_pad_idx,
...
@@ -385,10 +387,11 @@ def prepare_batch_input(insts, data_input_names, src_pad_idx, trg_pad_idx,
return_num_token
=
True
)
return_num_token
=
True
)
data_input_dict
=
dict
(
data_input_dict
=
dict
(
zip
(
data_input_names
,
[
list
(
src_word
,
src_pos
,
src_slf_attn_bias
,
trg_word
,
trg_pos
,
zip
(
data_input_names
,
[
trg_slf_attn_bias
,
trg_src_attn_bias
,
lbl_word
,
lbl_weight
src_word
,
src_pos
,
src_slf_attn_bias
,
trg_word
,
trg_pos
,
]))
trg_slf_attn_bias
,
trg_src_attn_bias
,
lbl_word
,
lbl_weight
])))
return
data_input_dict
,
np
.
asarray
([
num_token
],
dtype
=
"float32"
)
return
data_input_dict
,
np
.
asarray
([
num_token
],
dtype
=
"float32"
)
...
@@ -561,7 +564,7 @@ def train_loop(exe, train_progm, dev_count, sum_cost, avg_cost, lr_scheduler,
...
@@ -561,7 +564,7 @@ def train_loop(exe, train_progm, dev_count, sum_cost, avg_cost, lr_scheduler,
np
.
log
(
TrainTaskConfig
.
label_smooth_eps
/
(
np
.
log
(
TrainTaskConfig
.
label_smooth_eps
/
(
ModelHyperParams
.
trg_vocab_size
-
1
)
+
1e-20
))
ModelHyperParams
.
trg_vocab_size
-
1
)
+
1e-20
))
init
=
False
init
=
False
for
pass_id
in
xrange
(
TrainTaskConfig
.
pass_num
):
for
pass_id
in
six
.
moves
.
xrange
(
TrainTaskConfig
.
pass_num
):
pass_start_time
=
time
.
time
()
pass_start_time
=
time
.
time
()
for
batch_id
,
data
in
enumerate
(
train_data
()):
for
batch_id
,
data
in
enumerate
(
train_data
()):
if
batch_id
>=
5
:
if
batch_id
>=
5
:
...
@@ -587,11 +590,11 @@ def train_loop(exe, train_progm, dev_count, sum_cost, avg_cost, lr_scheduler,
...
@@ -587,11 +590,11 @@ def train_loop(exe, train_progm, dev_count, sum_cost, avg_cost, lr_scheduler,
ModelHyperParams
.
eos_idx
,
ModelHyperParams
.
n_head
,
ModelHyperParams
.
eos_idx
,
ModelHyperParams
.
n_head
,
ModelHyperParams
.
d_model
)
ModelHyperParams
.
d_model
)
total_num_token
+=
num_token
total_num_token
+=
num_token
feed_kv_pairs
=
data_input_dict
.
items
(
)
feed_kv_pairs
=
list
(
data_input_dict
.
items
()
)
if
TrainTaskConfig
.
local
:
if
TrainTaskConfig
.
local
:
feed_kv_pairs
+=
{
feed_kv_pairs
+=
list
(
{
lr_scheduler
.
learning_rate
.
name
:
lr_rate
lr_scheduler
.
learning_rate
.
name
:
lr_rate
}.
items
()
}.
items
()
)
feed_list
.
append
(
dict
(
feed_kv_pairs
))
feed_list
.
append
(
dict
(
feed_kv_pairs
))
if
not
init
:
if
not
init
:
...
@@ -873,6 +876,7 @@ class DataReader(object):
...
@@ -873,6 +876,7 @@ class DataReader(object):
f
=
tarfile
.
open
(
fpaths
[
0
],
"r"
)
f
=
tarfile
.
open
(
fpaths
[
0
],
"r"
)
for
line
in
f
.
extractfile
(
tar_fname
):
for
line
in
f
.
extractfile
(
tar_fname
):
line
=
cpt
.
to_text
(
line
)
fields
=
line
.
strip
(
"
\n
"
).
split
(
self
.
_field_delimiter
)
fields
=
line
.
strip
(
"
\n
"
).
split
(
self
.
_field_delimiter
)
if
(
not
self
.
_only_src
and
len
(
fields
)
==
2
)
or
(
if
(
not
self
.
_only_src
and
len
(
fields
)
==
2
)
or
(
self
.
_only_src
and
len
(
fields
)
==
1
):
self
.
_only_src
and
len
(
fields
)
==
1
):
...
@@ -882,8 +886,9 @@ class DataReader(object):
...
@@ -882,8 +886,9 @@ class DataReader(object):
if
not
os
.
path
.
isfile
(
fpath
):
if
not
os
.
path
.
isfile
(
fpath
):
raise
IOError
(
"Invalid file: %s"
%
fpath
)
raise
IOError
(
"Invalid file: %s"
%
fpath
)
with
open
(
fpath
,
"r"
)
as
f
:
with
open
(
fpath
,
"r
b
"
)
as
f
:
for
line
in
f
:
for
line
in
f
:
line
=
cpt
.
to_text
(
line
)
fields
=
line
.
strip
(
"
\n
"
).
split
(
self
.
_field_delimiter
)
fields
=
line
.
strip
(
"
\n
"
).
split
(
self
.
_field_delimiter
)
if
(
not
self
.
_only_src
and
len
(
fields
)
==
2
)
or
(
if
(
not
self
.
_only_src
and
len
(
fields
)
==
2
)
or
(
self
.
_only_src
and
len
(
fields
)
==
1
):
self
.
_only_src
and
len
(
fields
)
==
1
):
...
@@ -892,8 +897,9 @@ class DataReader(object):
...
@@ -892,8 +897,9 @@ class DataReader(object):
@
staticmethod
@
staticmethod
def
load_dict
(
dict_path
,
reverse
=
False
):
def
load_dict
(
dict_path
,
reverse
=
False
):
word_dict
=
{}
word_dict
=
{}
with
open
(
dict_path
,
"r"
)
as
fdict
:
with
open
(
dict_path
,
"r
b
"
)
as
fdict
:
for
idx
,
line
in
enumerate
(
fdict
):
for
idx
,
line
in
enumerate
(
fdict
):
line
=
cpt
.
to_text
(
line
)
if
reverse
:
if
reverse
:
word_dict
[
idx
]
=
line
.
strip
(
"
\n
"
)
word_dict
[
idx
]
=
line
.
strip
(
"
\n
"
)
else
:
else
:
...
@@ -1034,7 +1040,7 @@ def multi_head_attention(queries,
...
@@ -1034,7 +1040,7 @@ def multi_head_attention(queries,
# size of the input as the output dimension size.
# size of the input as the output dimension size.
return
layers
.
reshape
(
return
layers
.
reshape
(
x
=
trans_x
,
x
=
trans_x
,
shape
=
map
(
int
,
[
0
,
0
,
trans_x
.
shape
[
2
]
*
trans_x
.
shape
[
3
]]
))
shape
=
list
(
map
(
int
,
[
0
,
0
,
trans_x
.
shape
[
2
]
*
trans_x
.
shape
[
3
]])
))
def
scaled_dot_product_attention
(
q
,
k
,
v
,
attn_bias
,
d_model
,
dropout_rate
):
def
scaled_dot_product_attention
(
q
,
k
,
v
,
attn_bias
,
d_model
,
dropout_rate
):
"""
"""
...
...
python/paddle/fluid/tests/unittests/test_desc_clone.py
浏览文件 @
2e8a95c8
...
@@ -27,6 +27,7 @@ import unittest
...
@@ -27,6 +27,7 @@ import unittest
from
multiprocessing
import
Process
from
multiprocessing
import
Process
import
os
import
os
import
signal
import
signal
import
six
import
collections
import
collections
SEED
=
1
SEED
=
1
...
@@ -55,7 +56,8 @@ def cnn_model(data):
...
@@ -55,7 +56,8 @@ def cnn_model(data):
# TODO(dzhwinter) : refine the initializer and random seed settting
# TODO(dzhwinter) : refine the initializer and random seed settting
SIZE
=
10
SIZE
=
10
input_shape
=
conv_pool_2
.
shape
input_shape
=
conv_pool_2
.
shape
param_shape
=
[
reduce
(
lambda
a
,
b
:
a
*
b
,
input_shape
[
1
:],
1
)]
+
[
SIZE
]
param_shape
=
[
six
.
moves
.
reduce
(
lambda
a
,
b
:
a
*
b
,
input_shape
[
1
:],
1
)
]
+
[
SIZE
]
scale
=
(
2.0
/
(
param_shape
[
0
]
**
2
*
SIZE
))
**
0.5
scale
=
(
2.0
/
(
param_shape
[
0
]
**
2
*
SIZE
))
**
0.5
predict
=
fluid
.
layers
.
fc
(
predict
=
fluid
.
layers
.
fc
(
...
@@ -108,7 +110,7 @@ def get_transpiler(trainer_id, main_program, pserver_endpoints, trainers):
...
@@ -108,7 +110,7 @@ def get_transpiler(trainer_id, main_program, pserver_endpoints, trainers):
def
operator_equal
(
a
,
b
):
def
operator_equal
(
a
,
b
):
for
k
,
v
in
a
.
__dict__
.
iteritems
(
):
for
k
,
v
in
six
.
iteritems
(
a
.
__dict__
):
if
isinstance
(
v
,
fluid
.
framework
.
Program
)
or
\
if
isinstance
(
v
,
fluid
.
framework
.
Program
)
or
\
isinstance
(
v
,
fluid
.
framework
.
Block
):
isinstance
(
v
,
fluid
.
framework
.
Block
):
continue
continue
...
@@ -118,8 +120,8 @@ def operator_equal(a, b):
...
@@ -118,8 +120,8 @@ def operator_equal(a, b):
raise
ValueError
(
"In operator_equal not equal:{0}
\n
"
.
format
(
k
))
raise
ValueError
(
"In operator_equal not equal:{0}
\n
"
.
format
(
k
))
elif
isinstance
(
v
,
collections
.
OrderedDict
):
elif
isinstance
(
v
,
collections
.
OrderedDict
):
v0
=
sorted
(
v
.
iteritems
(
),
key
=
lambda
x
:
x
[
0
])
v0
=
sorted
(
list
(
six
.
iteritems
(
v
)
),
key
=
lambda
x
:
x
[
0
])
v1
=
sorted
(
b
.
__dict__
[
k
].
iteritems
(
),
key
=
lambda
x
:
x
[
0
])
v1
=
sorted
(
list
(
six
.
iteritems
(
b
.
__dict__
[
k
])
),
key
=
lambda
x
:
x
[
0
])
if
v0
!=
v1
:
if
v0
!=
v1
:
raise
ValueError
(
"In operator_equal not equal:{0}
\n
"
.
format
(
k
))
raise
ValueError
(
"In operator_equal not equal:{0}
\n
"
.
format
(
k
))
...
@@ -131,23 +133,21 @@ def operator_equal(a, b):
...
@@ -131,23 +133,21 @@ def operator_equal(a, b):
def
block_equal
(
a
,
b
):
def
block_equal
(
a
,
b
):
for
k
,
v
in
a
.
__dict__
.
iteritems
(
):
for
k
,
v
in
six
.
iteritems
(
a
.
__dict__
):
if
isinstance
(
v
,
core
.
ProgramDesc
)
or
isinstance
(
if
isinstance
(
v
,
core
.
ProgramDesc
)
or
isinstance
(
v
,
fluid
.
framework
.
Program
)
or
isinstance
(
v
,
core
.
BlockDesc
):
v
,
fluid
.
framework
.
Program
)
or
isinstance
(
v
,
core
.
BlockDesc
):
continue
continue
elif
k
==
"ops"
:
elif
k
==
"ops"
:
assert
(
len
(
a
.
ops
)
==
len
(
b
.
ops
))
for
i
in
range
(
0
,
len
(
a
.
ops
)):
for
i
in
range
(
0
,
len
(
a
.
ops
)):
if
not
operator_equal
(
a
.
ops
[
i
],
b
.
ops
[
i
]):
if
not
operator_equal
(
a
.
ops
[
i
],
b
.
ops
[
i
]):
raise
ValueError
(
"In block_equal not equal:{0}
\n
"
.
format
(
k
))
raise
ValueError
(
"In block_equal not equal:{0}
\n
"
.
format
(
k
))
assert
(
len
(
a
.
ops
)
==
len
(
b
.
ops
))
elif
isinstance
(
v
,
collections
.
OrderedDict
):
elif
isinstance
(
v
,
collections
.
OrderedDict
):
v0
=
sorted
(
v
.
iteritems
(),
key
=
lambda
x
:
x
[
0
])
for
key
,
value
in
six
.
iteritems
(
v
):
v1
=
sorted
(
b
.
__dict__
[
k
].
iteritems
(),
key
=
lambda
x
:
x
[
0
])
if
str
(
value
)
!=
str
(
b
.
__dict__
[
k
][
key
]):
raise
ValueError
(
"In block_equal not equal:{0}
\n
"
.
format
(
k
))
if
v0
!=
v1
:
raise
ValueError
(
"In block_equal not equal:{0}
\n
"
.
format
(
k
))
elif
(
v
!=
b
.
__dict__
[
k
]):
elif
(
v
!=
b
.
__dict__
[
k
]):
raise
ValueError
(
"In block_equal not equal:{0}
\n
"
.
format
(
k
))
raise
ValueError
(
"In block_equal not equal:{0}
\n
"
.
format
(
k
))
...
@@ -156,7 +156,7 @@ def block_equal(a, b):
...
@@ -156,7 +156,7 @@ def block_equal(a, b):
def
program_equal
(
a
,
b
):
def
program_equal
(
a
,
b
):
for
k
,
v
in
a
.
__dict__
.
iteritems
(
):
for
k
,
v
in
six
.
iteritems
(
a
.
__dict__
):
if
isinstance
(
v
,
core
.
ProgramDesc
):
if
isinstance
(
v
,
core
.
ProgramDesc
):
continue
continue
...
...
python/paddle/fluid/tests/unittests/test_dist_transpiler.py
浏览文件 @
2e8a95c8
...
@@ -21,6 +21,7 @@ import paddle.fluid as fluid
...
@@ -21,6 +21,7 @@ import paddle.fluid as fluid
from
paddle.fluid.transpiler.distribute_transpiler
import
delete_ops
from
paddle.fluid.transpiler.distribute_transpiler
import
delete_ops
import
traceback
import
traceback
import
collections
import
collections
import
six
class
TranspilerTest
(
unittest
.
TestCase
):
class
TranspilerTest
(
unittest
.
TestCase
):
...
...
python/paddle/fluid/tests/unittests/test_prelu_op.py
浏览文件 @
2e8a95c8
...
@@ -16,6 +16,7 @@ from __future__ import print_function
...
@@ -16,6 +16,7 @@ from __future__ import print_function
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
import
six
from
op_test
import
OpTest
from
op_test
import
OpTest
...
@@ -51,29 +52,30 @@ class PReluTest(OpTest):
...
@@ -51,29 +52,30 @@ class PReluTest(OpTest):
def
test_check_output
(
self
):
def
test_check_output
(
self
):
self
.
check_output
()
self
.
check_output
()
def
test_check_grad
(
self
):
def
test_check_grad_1_ignore_x
(
self
):
self
.
check_grad
([
'X'
,
'Alpha'
],
'Out'
)
def
test_check_grad_ignore_x
(
self
):
self
.
check_grad
([
'Alpha'
],
'Out'
,
no_grad_set
=
set
(
'X'
))
self
.
check_grad
([
'Alpha'
],
'Out'
,
no_grad_set
=
set
(
'X'
))
def
test_check_grad_ignore_alpha
(
self
):
def
test_check_grad_2
(
self
):
self
.
check_grad
([
'X'
,
'Alpha'
],
'Out'
)
def
test_check_grad_3_ignore_alpha
(
self
):
self
.
check_grad
([
'X'
],
'Out'
,
no_grad_set
=
set
(
'Alpha'
))
self
.
check_grad
([
'X'
],
'Out'
,
no_grad_set
=
set
(
'Alpha'
))
class
TestCase1
(
PReluTest
):
# TODO(minqiyang): Resume these test cases after fixing Python3 CI job issues
def
initTestCase
(
self
):
if
six
.
PY2
:
self
.
attrs
=
{
'mode'
:
"all"
}
class
TestCase1
(
PReluTest
):
def
initTestCase
(
self
):
self
.
attrs
=
{
'mode'
:
"all"
}
class
TestCase2
(
PReluTest
):
class
TestCase2
(
PReluTest
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
attrs
=
{
'mode'
:
"channel"
}
self
.
attrs
=
{
'mode'
:
"channel"
}
class
TestCase3
(
PReluTest
):
class
TestCase3
(
PReluTest
):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
attrs
=
{
'mode'
:
"element"
}
self
.
attrs
=
{
'mode'
:
"element"
}
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
python/paddle/fluid/transpiler/distribute_transpiler.py
浏览文件 @
2e8a95c8
...
@@ -293,7 +293,7 @@ class DistributeTranspiler(object):
...
@@ -293,7 +293,7 @@ class DistributeTranspiler(object):
input_deps
=
grad_name_to_send_dummy_out
.
values
()
input_deps
=
grad_name_to_send_dummy_out
.
values
()
program
.
global_block
().
append_op
(
program
.
global_block
().
append_op
(
type
=
"send_barrier"
,
type
=
"send_barrier"
,
inputs
=
{
"X"
:
input_deps
},
inputs
=
{
"X"
:
list
(
input_deps
)
},
outputs
=
{
"Out"
:
send_barrier_out
},
outputs
=
{
"Out"
:
send_barrier_out
},
attrs
=
{
attrs
=
{
"endpoints"
:
pserver_endpoints
,
"endpoints"
:
pserver_endpoints
,
...
@@ -394,7 +394,7 @@ class DistributeTranspiler(object):
...
@@ -394,7 +394,7 @@ class DistributeTranspiler(object):
Args:
Args:
recv_vars (list): Variable list to recv for current trainer_id
recv_vars (list): Variable list to recv for current trainer_id
eplist (list): A list of strings indicating
eplist (list): A list of strings indicating
Returns:
Returns:
Program: trainer side startup program.
Program: trainer side startup program.
...
@@ -404,7 +404,7 @@ class DistributeTranspiler(object):
...
@@ -404,7 +404,7 @@ class DistributeTranspiler(object):
# FIXME(gongwb): delete not need ops.
# FIXME(gongwb): delete not need ops.
# note that: some parameter is not trainable and those ops can't be deleted.
# note that: some parameter is not trainable and those ops can't be deleted.
for
varname
,
splited_var
in
s
elf
.
param_var_mapping
.
iteritems
(
):
for
varname
,
splited_var
in
s
ix
.
iteritems
(
self
.
param_var_mapping
):
# Get the eplist of recv vars
# Get the eplist of recv vars
eps
=
[]
eps
=
[]
for
var
in
splited_var
:
for
var
in
splited_var
:
...
@@ -443,12 +443,12 @@ class DistributeTranspiler(object):
...
@@ -443,12 +443,12 @@ class DistributeTranspiler(object):
RPC_OP_ROLE_ATTR_NAME
:
RPC_OP_ROLE_ATTR_VALUE
RPC_OP_ROLE_ATTR_NAME
:
RPC_OP_ROLE_ATTR_VALUE
})
})
for
varname
,
splited_var
in
s
elf
.
param_var_mapping
.
iteritems
(
):
for
varname
,
splited_var
in
s
ix
.
iteritems
(
self
.
param_var_mapping
):
#add concat ops to merge splited parameters received from parameter servers.
#add concat ops to merge splited parameters received from parameter servers.
if
len
(
splited_var
)
<=
1
:
if
len
(
splited_var
)
<=
1
:
continue
continue
# NOTE: if enable memory optimization, origin vars maybe removed.
# NOTE: if enable memory optimization, origin vars maybe removed.
if
startup_program
.
global_block
().
vars
.
has_key
(
varname
)
:
if
varname
in
startup_program
.
global_block
().
vars
:
orig_param
=
startup_program
.
global_block
().
vars
[
varname
]
orig_param
=
startup_program
.
global_block
().
vars
[
varname
]
else
:
else
:
origin_param_var
=
self
.
origin_program
.
global_block
().
vars
[
origin_param_var
=
self
.
origin_program
.
global_block
().
vars
[
...
@@ -677,7 +677,7 @@ class DistributeTranspiler(object):
...
@@ -677,7 +677,7 @@ class DistributeTranspiler(object):
Args:
Args:
endpoint (str): current pserver endpoint.
endpoint (str): current pserver endpoint.
Returns:
Returns:
tuple: (main_program, startup_program), of type "Program"
tuple: (main_program, startup_program), of type "Program"
"""
"""
...
@@ -700,7 +700,7 @@ class DistributeTranspiler(object):
...
@@ -700,7 +700,7 @@ class DistributeTranspiler(object):
endpoint (str): current pserver endpoint.
endpoint (str): current pserver endpoint.
pserver_program (Program): deprecated, call get_pserver_program first.
pserver_program (Program): deprecated, call get_pserver_program first.
startup_program (Program): deprecated, should pass startup_program
startup_program (Program): deprecated, should pass startup_program
when initalizing
when initalizing
Returns:
Returns:
Program: parameter server side startup program.
Program: parameter server side startup program.
...
...
tools/check_ctest_hung.py
浏览文件 @
2e8a95c8
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
from
__future__
import
print_function
import
sys
import
sys
import
re
import
re
...
@@ -46,7 +48,7 @@ Diff: set(['test_parallel_executor_crf'])
...
@@ -46,7 +48,7 @@ Diff: set(['test_parallel_executor_crf'])
start_parts
=
escape
(
l
).
split
(
" "
)
start_parts
=
escape
(
l
).
split
(
" "
)
m
=
re
.
search
(
"Start\s+[0-9]+\:\s([a-z0-9_]+)"
,
escape
(
l
))
m
=
re
.
search
(
"Start\s+[0-9]+\:\s([a-z0-9_]+)"
,
escape
(
l
))
started
.
add
(
m
.
group
(
1
))
started
.
add
(
m
.
group
(
1
))
print
"Diff: "
,
started
-
passed
print
(
"Diff: "
,
started
-
passed
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
tools/print_signatures.py
浏览文件 @
2e8a95c8
...
@@ -17,6 +17,8 @@ Print all signature of a python module in alphabet order.
...
@@ -17,6 +17,8 @@ Print all signature of a python module in alphabet order.
Usage:
Usage:
./print_signature "paddle.fluid" > signature.txt
./print_signature "paddle.fluid" > signature.txt
"""
"""
from
__future__
import
print_function
import
importlib
import
importlib
import
inspect
import
inspect
import
collections
import
collections
...
@@ -64,4 +66,4 @@ def visit_all_module(mod):
...
@@ -64,4 +66,4 @@ def visit_all_module(mod):
visit_all_module
(
importlib
.
import_module
(
sys
.
argv
[
1
]))
visit_all_module
(
importlib
.
import_module
(
sys
.
argv
[
1
]))
for
name
in
member_dict
:
for
name
in
member_dict
:
print
name
,
member_dict
[
name
]
print
(
name
,
member_dict
[
name
])
tools/timeline.py
浏览文件 @
2e8a95c8
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
import
argparse
import
argparse
import
json
import
json
import
six
import
sys
import
sys
import
unittest
import
unittest
...
@@ -124,7 +125,7 @@ class Timeline(object):
...
@@ -124,7 +125,7 @@ class Timeline(object):
return
cur_pid
return
cur_pid
def
_allocate_pids
(
self
):
def
_allocate_pids
(
self
):
for
k
,
profile_pb
in
s
elf
.
_profile_dict
.
iteritems
(
):
for
k
,
profile_pb
in
s
ix
.
iteritems
(
self
.
_profile_dict
):
for
event
in
profile_pb
.
events
:
for
event
in
profile_pb
.
events
:
if
event
.
type
==
profiler_pb2
.
Event
.
CPU
:
if
event
.
type
==
profiler_pb2
.
Event
.
CPU
:
if
(
k
,
event
.
device_id
,
"CPU"
)
not
in
self
.
_devices
:
if
(
k
,
event
.
device_id
,
"CPU"
)
not
in
self
.
_devices
:
...
@@ -140,7 +141,7 @@ class Timeline(object):
...
@@ -140,7 +141,7 @@ class Timeline(object):
(
k
,
event
.
device_id
),
pid
)
(
k
,
event
.
device_id
),
pid
)
def
_allocate_events
(
self
):
def
_allocate_events
(
self
):
for
k
,
profile_pb
in
s
elf
.
_profile_dict
.
iteritems
(
):
for
k
,
profile_pb
in
s
ix
.
iteritems
(
self
.
_profile_dict
):
for
event
in
profile_pb
.
events
:
for
event
in
profile_pb
.
events
:
if
event
.
type
==
profiler_pb2
.
Event
.
CPU
:
if
event
.
type
==
profiler_pb2
.
Event
.
CPU
:
type
=
"CPU"
type
=
"CPU"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录