Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
3491acfb
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
3491acfb
编写于
1月 28, 2021
作者:
W
WeiXin
提交者:
GitHub
1月 28, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split unittest. (#30727)
上级
caf3680b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
97 addition
and
74 deletion
+97
-74
python/paddle/fluid/tests/unittests/CMakeLists.txt
python/paddle/fluid/tests/unittests/CMakeLists.txt
+3
-2
python/paddle/fluid/tests/unittests/test_static_save_load.py
python/paddle/fluid/tests/unittests/test_static_save_load.py
+0
-72
python/paddle/fluid/tests/unittests/test_static_save_load_large.py
...ddle/fluid/tests/unittests/test_static_save_load_large.py
+94
-0
tools/__pycache__/static_mode_white_list.cpython-35.pyc
tools/__pycache__/static_mode_white_list.cpython-35.pyc
+0
-0
未找到文件。
python/paddle/fluid/tests/unittests/CMakeLists.txt
浏览文件 @
3491acfb
...
...
@@ -709,11 +709,12 @@ set_tests_properties(test_nearest_interp_v2_op PROPERTIES TIMEOUT 120)
set_tests_properties
(
test_trilinear_interp_op PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_bicubic_interp_v2_op PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_gather_op PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_static_save_load PROPERTIES TIMEOUT 120
)
if
(
WIN32
)
set_tests_properties
(
test_static_save_load PROPERTIES TIMEOUT 900
)
set_tests_properties
(
test_static_save_load
_large
PROPERTIES TIMEOUT 900
)
set_tests_properties
(
test_paddle_save_load PROPERTIES TIMEOUT 250
)
else
()
set_tests_properties
(
test_static_save_load PROPERTIES TIMEOUT 600
)
set_tests_properties
(
test_static_save_load
_large
PROPERTIES TIMEOUT 600
)
set_tests_properties
(
test_paddle_save_load PROPERTIES TIMEOUT 150
)
endif
()
set_tests_properties
(
test_imperative_selected_rows_to_lod_tensor PROPERTIES TIMEOUT 120
)
...
...
python/paddle/fluid/tests/unittests/test_static_save_load.py
浏览文件 @
3491acfb
...
...
@@ -1313,78 +1313,6 @@ class TestProgramStateOldSave(unittest.TestCase):
self
.
assertTrue
(
np
.
array_equal
(
new_t
,
base_t
))
class
TestStaticSaveLoadLargeParameters
(
unittest
.
TestCase
):
def
test_large_parameters_static_save
(
self
):
# enable static mode
paddle
.
enable_static
()
LARGE_PARAM
=
2
**
26
with
new_program_scope
():
# create network
x
=
paddle
.
static
.
data
(
name
=
"static_save_load_large_x"
,
shape
=
[
None
,
10
],
dtype
=
'float32'
)
z
=
paddle
.
static
.
nn
.
fc
(
x
,
LARGE_PARAM
,
bias_attr
=
False
)
place
=
paddle
.
CPUPlace
()
exe
=
paddle
.
static
.
Executor
(
place
)
exe
.
run
(
paddle
.
static
.
default_startup_program
())
prog
=
paddle
.
static
.
default_main_program
()
inputs
=
np
.
random
.
randn
(
1
,
10
).
astype
(
"float32"
)
result_z
=
exe
.
run
(
program
=
prog
,
feed
=
{
"static_save_load_large_x"
:
inputs
},
fetch_list
=
[
z
.
name
])
base_map
=
{}
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
# make sure all the paramerter or optimizer var have been update
self
.
assertTrue
(
np
.
sum
(
np
.
abs
(
t
))
!=
0
)
base_map
[
var
.
name
]
=
t
path
=
os
.
path
.
join
(
"test_static_save_load_large_param"
,
"static_save"
)
paddle
.
fluid
.
save
(
prog
,
path
)
# set var to zero
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
ten
=
fluid
.
global_scope
().
find_var
(
var
.
name
).
get_tensor
()
ten
.
set
(
np
.
zeros_like
(
np
.
array
(
ten
)),
place
)
new_t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
self
.
assertTrue
(
np
.
sum
(
np
.
abs
(
new_t
))
==
0
)
paddle
.
fluid
.
load
(
prog
,
path
)
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
new_t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
base_t
=
base_map
[
var
.
name
]
self
.
assertTrue
(
np
.
array_equal
(
new_t
,
base_t
))
# set var to zero
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
ten
=
fluid
.
global_scope
().
find_var
(
var
.
name
).
get_tensor
()
ten
.
set
(
np
.
zeros_like
(
np
.
array
(
ten
)),
place
)
new_t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
self
.
assertTrue
(
np
.
sum
(
np
.
abs
(
new_t
))
==
0
)
program_state
=
fluid
.
load_program_state
(
path
)
fluid
.
set_program_state
(
prog
,
program_state
)
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
new_t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
base_t
=
base_map
[
var
.
name
]
self
.
assertTrue
(
np
.
array_equal
(
new_t
,
base_t
))
class
TestProgramStateOldSaveSingleModel
(
unittest
.
TestCase
):
def
test_ptb_rnn_cpu_float32
(
self
):
seed
=
90
...
...
python/paddle/fluid/tests/unittests/test_static_save_load_large.py
0 → 100644
浏览文件 @
3491acfb
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
print_function
import
unittest
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid.framework
as
framework
from
test_imperative_base
import
new_program_scope
import
numpy
as
np
import
six
import
pickle
import
os
class
TestStaticSaveLoadLargeParameters
(
unittest
.
TestCase
):
def
test_large_parameters_static_save
(
self
):
# enable static mode
paddle
.
enable_static
()
LARGE_PARAM
=
2
**
26
with
new_program_scope
():
# create network
x
=
paddle
.
static
.
data
(
name
=
"static_save_load_large_x"
,
shape
=
[
None
,
10
],
dtype
=
'float32'
)
z
=
paddle
.
static
.
nn
.
fc
(
x
,
LARGE_PARAM
,
bias_attr
=
False
)
place
=
paddle
.
CPUPlace
()
exe
=
paddle
.
static
.
Executor
(
place
)
exe
.
run
(
paddle
.
static
.
default_startup_program
())
prog
=
paddle
.
static
.
default_main_program
()
base_map
=
{}
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
# make sure all the paramerter or optimizer var have been update
self
.
assertTrue
(
np
.
sum
(
np
.
abs
(
t
))
!=
0
)
base_map
[
var
.
name
]
=
t
path
=
os
.
path
.
join
(
"test_static_save_load_large_param"
,
"static_save"
)
paddle
.
fluid
.
save
(
prog
,
path
)
# set var to zero
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
ten
=
fluid
.
global_scope
().
find_var
(
var
.
name
).
get_tensor
()
ten
.
set
(
np
.
zeros_like
(
np
.
array
(
ten
)),
place
)
new_t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
self
.
assertTrue
(
np
.
sum
(
np
.
abs
(
new_t
))
==
0
)
paddle
.
fluid
.
load
(
prog
,
path
)
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
new_t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
base_t
=
base_map
[
var
.
name
]
self
.
assertTrue
(
np
.
array_equal
(
new_t
,
base_t
))
# set var to zero
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
ten
=
fluid
.
global_scope
().
find_var
(
var
.
name
).
get_tensor
()
ten
.
set
(
np
.
zeros_like
(
np
.
array
(
ten
)),
place
)
new_t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
self
.
assertTrue
(
np
.
sum
(
np
.
abs
(
new_t
))
==
0
)
program_state
=
fluid
.
load_program_state
(
path
)
fluid
.
set_program_state
(
prog
,
program_state
)
for
var
in
prog
.
list_vars
():
if
isinstance
(
var
,
framework
.
Parameter
)
or
var
.
persistable
:
new_t
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
var
.
name
)
.
get_tensor
())
base_t
=
base_map
[
var
.
name
]
self
.
assertTrue
(
np
.
array_equal
(
new_t
,
base_t
))
tools/__pycache__/static_mode_white_list.cpython-35.pyc
已删除
100644 → 0
浏览文件 @
caf3680b
文件已删除
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录