Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
f82e63fe
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f82e63fe
编写于
4月 27, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
4月 27, 2020
浏览文件
操作
浏览文件
下载
差异文件
!671 Added testcase for sync_wait
Merge pull request !671 from EricZ/master
上级
0e3054d5
2d115cd0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
4 deletion
+34
-4
mindspore/ccsrc/dataset/engine/datasetops/barrier_op.cc
mindspore/ccsrc/dataset/engine/datasetops/barrier_op.cc
+2
-2
mindspore/dataset/engine/datasets.py
mindspore/dataset/engine/datasets.py
+1
-1
tests/ut/python/dataset/test_sync_wait.py
tests/ut/python/dataset/test_sync_wait.py
+31
-1
未找到文件。
mindspore/ccsrc/dataset/engine/datasetops/barrier_op.cc
浏览文件 @
f82e63fe
...
...
@@ -65,8 +65,8 @@ Status BarrierOp::operator()() {
TaskManager
::
FindMe
()
->
Post
();
// create child iterator, right now this barrier is a pipeline operator
int32_t
worker_id
=
0
;
int32_t
child_idx
=
0
;
const
int32_t
worker_id
=
0
;
const
int32_t
child_idx
=
0
;
child_iterator_
=
std
::
make_unique
<
ChildIterator
>
(
this
,
worker_id
,
child_idx
);
// Loop until eof is true
...
...
mindspore/dataset/engine/datasets.py
浏览文件 @
f82e63fe
...
...
@@ -922,7 +922,7 @@ class Dataset:
def
sync_update
(
self
,
condition_name
,
num_batch
=
None
,
data
=
None
):
"""
condition_name (str): The condition name that is used to toggle sending next row
step_size (int or None): The number of step
s(rows) that are released
num_batch (int or None): The number of batche
s(rows) that are released
when pass_rows is None, will update the same number as sync_wait specified
data (dict or None): The data passed to the callback
"""
...
...
tests/ut/python/dataset/test_sync_wait.py
浏览文件 @
f82e63fe
...
...
@@ -107,6 +107,7 @@ def test_two_sync():
if
count
%
2
==
0
:
dataset
.
sync_update
(
condition_name
=
"every 2 batches"
)
def
test_sync_epoch
():
"""
Test sync wait with epochs: test sync with epochs in dataset pipeline
...
...
@@ -130,6 +131,34 @@ def test_sync_epoch():
dataset
.
sync_update
(
condition_name
=
"policy"
,
data
=
data
)
def
test_multiple_iterators
():
"""
Test sync wait with multiple iterators: will start multiple
"""
logger
.
info
(
"test_sync_epoch"
)
batch_size
=
30
dataset
=
ds
.
GeneratorDataset
(
gen
,
column_names
=
[
"input"
])
aug
=
Augment
(
0
)
dataset
=
dataset
.
sync_wait
(
condition_name
=
"policy"
,
callback
=
aug
.
update
)
dataset
=
dataset
.
map
(
input_columns
=
[
"input"
],
operations
=
[
aug
.
preprocess
])
dataset
=
dataset
.
batch
(
batch_size
,
drop_remainder
=
True
)
# 2nd dataset
dataset2
=
ds
.
GeneratorDataset
(
gen
,
column_names
=
[
"input"
])
aug
=
Augment
(
0
)
dataset2
=
dataset2
.
sync_wait
(
condition_name
=
"policy"
,
callback
=
aug
.
update
)
dataset2
=
dataset2
.
map
(
input_columns
=
[
"input"
],
operations
=
[
aug
.
preprocess
])
dataset2
=
dataset2
.
batch
(
batch_size
,
drop_remainder
=
True
)
for
item1
,
item2
in
zip
(
dataset
.
create_dict_iterator
(),
dataset2
.
create_dict_iterator
()):
assert
(
item1
[
"input"
][
0
]
==
item2
[
"input"
][
0
])
data1
=
{
"loss"
:
item1
[
"input"
][
0
]}
data2
=
{
"loss"
:
item2
[
"input"
][
0
]}
dataset
.
sync_update
(
condition_name
=
"policy"
,
data
=
data1
)
dataset2
.
sync_update
(
condition_name
=
"policy"
,
data
=
data2
)
def
test_sync_exception_01
():
"""
Test sync: with shuffle in sync mode
...
...
@@ -179,4 +208,5 @@ if __name__ == "__main__":
test_two_sync
()
test_sync_exception_01
()
test_sync_exception_02
()
test_sync_epoch
()
\ No newline at end of file
test_sync_epoch
()
test_multiple_iterators
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录