Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
dcfdff60
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看板
提交
dcfdff60
编写于
6月 17, 2020
作者:
J
Jesse Lee
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename Sampler Reset
上级
a1f194c9
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
44 addition
and
34 deletion
+44
-34
mindspore/ccsrc/dataset/engine/datasetops/source/celeba_op.cc
...spore/ccsrc/dataset/engine/datasetops/source/celeba_op.cc
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/cifar_op.cc
mindspore/ccsrc/dataset/engine/datasetops/source/cifar_op.cc
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/coco_op.cc
mindspore/ccsrc/dataset/engine/datasetops/source/coco_op.cc
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/image_folder_op.cc
...ccsrc/dataset/engine/datasetops/source/image_folder_op.cc
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/manifest_op.cc
...ore/ccsrc/dataset/engine/datasetops/source/manifest_op.cc
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/mnist_op.cc
mindspore/ccsrc/dataset/engine/datasetops/source/mnist_op.cc
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/distributed_sampler.cc
...t/engine/datasetops/source/sampler/distributed_sampler.cc
+2
-2
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/distributed_sampler.h
...et/engine/datasetops/source/sampler/distributed_sampler.h
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/pk_sampler.cc
...rc/dataset/engine/datasetops/source/sampler/pk_sampler.cc
+2
-2
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/pk_sampler.h
...src/dataset/engine/datasetops/source/sampler/pk_sampler.h
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/python_sampler.cc
...ataset/engine/datasetops/source/sampler/python_sampler.cc
+2
-2
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/python_sampler.h
...dataset/engine/datasetops/source/sampler/python_sampler.h
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/random_sampler.cc
...ataset/engine/datasetops/source/sampler/random_sampler.cc
+2
-2
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/random_sampler.h
...dataset/engine/datasetops/source/sampler/random_sampler.h
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sampler.cc
...ccsrc/dataset/engine/datasetops/source/sampler/sampler.cc
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sampler.h
.../ccsrc/dataset/engine/datasetops/source/sampler/sampler.h
+11
-1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sequential_sampler.cc
...et/engine/datasetops/source/sampler/sequential_sampler.cc
+2
-2
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sequential_sampler.h
...set/engine/datasetops/source/sampler/sequential_sampler.h
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/subset_random_sampler.cc
...engine/datasetops/source/sampler/subset_random_sampler.cc
+2
-2
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/subset_random_sampler.h
.../engine/datasetops/source/sampler/subset_random_sampler.h
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/weighted_random_sampler.cc
...gine/datasetops/source/sampler/weighted_random_sampler.cc
+2
-2
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/weighted_random_sampler.h
...ngine/datasetops/source/sampler/weighted_random_sampler.h
+1
-1
mindspore/ccsrc/dataset/engine/datasetops/source/voc_op.cc
mindspore/ccsrc/dataset/engine/datasetops/source/voc_op.cc
+1
-1
tests/ut/cpp/dataset/stand_alone_samplers_test.cc
tests/ut/cpp/dataset/stand_alone_samplers_test.cc
+1
-1
tests/ut/cpp/dataset/subset_random_sampler_test.cc
tests/ut/cpp/dataset/subset_random_sampler_test.cc
+1
-1
tests/ut/cpp/dataset/weighted_random_sampler_test.cc
tests/ut/cpp/dataset/weighted_random_sampler_test.cc
+2
-2
未找到文件。
mindspore/ccsrc/dataset/engine/datasetops/source/celeba_op.cc
浏览文件 @
dcfdff60
...
...
@@ -409,7 +409,7 @@ void CelebAOp::Print(std::ostream &out, bool show_all) const {
// Reset Sampler and wakeup Master thread (functor)
Status
CelebAOp
::
Reset
()
{
RETURN_IF_NOT_OK
(
sampler_
->
Reset
());
RETURN_IF_NOT_OK
(
sampler_
->
Reset
Sampler
());
wp_
.
Set
();
// wake up master thread after reset is done
return
Status
::
OK
();
}
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/cifar_op.cc
浏览文件 @
dcfdff60
...
...
@@ -241,7 +241,7 @@ void CifarOp::Print(std::ostream &out, bool show_all) const {
// Reset Sampler and wakeup Master thread (functor)
Status
CifarOp
::
Reset
()
{
RETURN_IF_NOT_OK
(
sampler_
->
Reset
());
RETURN_IF_NOT_OK
(
sampler_
->
Reset
Sampler
());
row_cnt_
=
0
;
wp_
.
Set
();
// wake up master thread after reset is done
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/coco_op.cc
浏览文件 @
dcfdff60
...
...
@@ -207,7 +207,7 @@ void CocoOp::Print(std::ostream &out, bool show_all) const {
}
Status
CocoOp
::
Reset
()
{
RETURN_IF_NOT_OK
(
sampler_
->
Reset
());
RETURN_IF_NOT_OK
(
sampler_
->
Reset
Sampler
());
row_cnt_
=
0
;
wp_
.
Set
();
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/image_folder_op.cc
浏览文件 @
dcfdff60
...
...
@@ -252,7 +252,7 @@ void ImageFolderOp::Print(std::ostream &out, bool show_all) const {
// Reset Sampler and wakeup Master thread (functor)
Status
ImageFolderOp
::
Reset
()
{
RETURN_IF_NOT_OK
(
sampler_
->
Reset
());
RETURN_IF_NOT_OK
(
sampler_
->
Reset
Sampler
());
row_cnt_
=
0
;
wp_
.
Set
();
// wake up master thread after reset is done
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/manifest_op.cc
浏览文件 @
dcfdff60
...
...
@@ -241,7 +241,7 @@ void ManifestOp::Print(std::ostream &out, bool show_all) const {
// Reset Sampler and wakeup Master thread (functor)
Status
ManifestOp
::
Reset
()
{
RETURN_IF_NOT_OK
(
sampler_
->
Reset
());
RETURN_IF_NOT_OK
(
sampler_
->
Reset
Sampler
());
row_cnt_
=
0
;
wp_
.
Set
();
// wake up master thread after reset is done
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/mnist_op.cc
浏览文件 @
dcfdff60
...
...
@@ -204,7 +204,7 @@ void MnistOp::Print(std::ostream &out, bool show_all) const {
// Reset Sampler and wakeup Master thread (functor)
Status
MnistOp
::
Reset
()
{
RETURN_IF_NOT_OK
(
sampler_
->
Reset
());
RETURN_IF_NOT_OK
(
sampler_
->
Reset
Sampler
());
row_cnt_
=
0
;
wp_
.
Set
();
// wake up master thread after reset is done
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/distributed_sampler.cc
浏览文件 @
dcfdff60
...
...
@@ -89,7 +89,7 @@ Status DistributedSampler::GetNextSample(std::unique_ptr<DataBuffer> *out_buffer
return
Status
::
OK
();
}
Status
DistributedSampler
::
Reset
()
{
Status
DistributedSampler
::
Reset
Sampler
()
{
CHECK_FAIL_RETURN_UNEXPECTED
(
cnt_
==
samples_per_buffer_
,
"ERROR Reset() called early/late"
);
cnt_
=
0
;
...
...
@@ -100,7 +100,7 @@ Status DistributedSampler::Reset() {
}
if
(
HasChildSampler
())
{
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
());
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
Sampler
());
}
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/distributed_sampler.h
浏览文件 @
dcfdff60
...
...
@@ -47,7 +47,7 @@ class DistributedSampler : public Sampler {
// for next epoch of sampleIds
// @return - The error code return
Status
Reset
()
override
;
Status
Reset
Sampler
()
override
;
void
Print
(
std
::
ostream
&
out
,
bool
show_all
)
const
override
;
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/pk_sampler.cc
浏览文件 @
dcfdff60
...
...
@@ -94,13 +94,13 @@ Status PKSampler::GetNextSample(std::unique_ptr<DataBuffer> *out_buffer) {
return
Status
::
OK
();
}
Status
PKSampler
::
Reset
()
{
Status
PKSampler
::
Reset
Sampler
()
{
CHECK_FAIL_RETURN_UNEXPECTED
(
next_id_
==
num_samples_
,
"ERROR Reset() called early/late"
);
next_id_
=
0
;
rnd_
.
seed
(
seed_
++
);
if
(
HasChildSampler
())
{
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
());
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
Sampler
());
}
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/pk_sampler.h
浏览文件 @
dcfdff60
...
...
@@ -54,7 +54,7 @@ class PKSampler : public Sampler { // NOT YET FINISHED
// for next epoch of sampleIds
// @return - The error code return
Status
Reset
()
override
;
Status
Reset
Sampler
()
override
;
private:
bool
shuffle_
;
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/python_sampler.cc
浏览文件 @
dcfdff60
...
...
@@ -84,7 +84,7 @@ Status PythonSampler::InitSampler() {
return
Status
::
OK
();
}
Status
PythonSampler
::
Reset
()
{
Status
PythonSampler
::
Reset
Sampler
()
{
CHECK_FAIL_RETURN_UNEXPECTED
(
need_to_reset_
,
"ERROR Reset() called not at end of an epoch"
);
need_to_reset_
=
false
;
py
::
gil_scoped_acquire
gil_acquire
;
...
...
@@ -98,7 +98,7 @@ Status PythonSampler::Reset() {
}
if
(
HasChildSampler
())
{
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
());
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
Sampler
());
}
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/python_sampler.h
浏览文件 @
dcfdff60
...
...
@@ -42,7 +42,7 @@ class PythonSampler : public Sampler {
// for next epoch of sampleIds
// @return - The error code return
Status
Reset
()
override
;
Status
Reset
Sampler
()
override
;
// Op calls this to get next Buffer that contains all the sampleIds
// @param std::unique_ptr<DataBuffer> pBuffer - Buffer to be returned to StorageOp
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/random_sampler.cc
浏览文件 @
dcfdff60
...
...
@@ -91,7 +91,7 @@ Status RandomSampler::InitSampler() {
return
Status
::
OK
();
}
Status
RandomSampler
::
Reset
()
{
Status
RandomSampler
::
Reset
Sampler
()
{
CHECK_FAIL_RETURN_UNEXPECTED
(
next_id_
==
num_samples_
,
"ERROR Reset() called early/late"
);
next_id_
=
0
;
...
...
@@ -106,7 +106,7 @@ Status RandomSampler::Reset() {
}
if
(
HasChildSampler
())
{
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
());
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
Sampler
());
}
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/random_sampler.h
浏览文件 @
dcfdff60
...
...
@@ -48,7 +48,7 @@ class RandomSampler : public Sampler {
// for next epoch of sampleIds
// @return - The error code return
Status
Reset
()
override
;
Status
Reset
Sampler
()
override
;
virtual
void
Print
(
std
::
ostream
&
out
,
bool
show_all
)
const
;
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sampler.cc
浏览文件 @
dcfdff60
...
...
@@ -113,7 +113,7 @@ Status Sampler::GetAllIdsThenReset(py::array *data) {
RETURN_IF_NOT_OK
(
GetNextSample
(
&
db
));
CHECK_FAIL_RETURN_UNEXPECTED
(
db
->
eoe
(),
"ERROR Non EOE received"
);
// Reset Sampler since this is the end of the epoch
RETURN_IF_NOT_OK
(
Reset
());
RETURN_IF_NOT_OK
(
Reset
Sampler
());
return
Status
::
OK
();
}
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sampler.h
浏览文件 @
dcfdff60
...
...
@@ -62,6 +62,8 @@ class Sampler {
// @param int64_t samplesPerBuffer: Num of Sampler Ids to fetch via 1 GetNextBuffer call
explicit
Sampler
(
int64_t
num_samples
,
int64_t
samples_per_buffer
);
Sampler
(
const
Sampler
&
s
)
:
Sampler
(
s
.
num_samples_
,
s
.
samples_per_buffer_
)
{}
// default destructor
~
Sampler
()
=
default
;
...
...
@@ -77,7 +79,7 @@ class Sampler {
// for next epoch of sampleIds
// @return - The error code return
virtual
Status
Reset
()
=
0
;
virtual
Status
Reset
Sampler
()
=
0
;
// first handshake between leaf source op and Sampler. This func will determine the amount of data
// in the dataset that we can sample from.
...
...
@@ -109,8 +111,16 @@ class Sampler {
// @return - The error code returned.
Status
CreateSamplerTensor
(
std
::
shared_ptr
<
Tensor
>
*
sample_ids
,
int64_t
num_elements
);
// A print method typically used for debugging
// @param out - The output stream to write output to
// @param show_all - A bool to control if you want to show all info or just a summary
virtual
void
Print
(
std
::
ostream
&
out
,
bool
show_all
)
const
;
// << Stream output operator overload
// @notes This allows you to write the debug print info using stream operators
// @param out - reference to the output stream being overloaded
// @param sampler - reference to teh sampler to print
// @return - the output stream must be returned
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Sampler
&
sampler
)
{
sampler
.
Print
(
out
,
false
);
return
out
;
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sequential_sampler.cc
浏览文件 @
dcfdff60
...
...
@@ -77,13 +77,13 @@ Status SequentialSampler::InitSampler() {
return
Status
::
OK
();
}
Status
SequentialSampler
::
Reset
()
{
Status
SequentialSampler
::
Reset
Sampler
()
{
CHECK_FAIL_RETURN_UNEXPECTED
(
id_count_
==
num_samples_
,
"ERROR Reset() called early/late"
);
current_id_
=
start_index_
;
id_count_
=
0
;
if
(
HasChildSampler
())
{
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
());
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
Sampler
());
}
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/sequential_sampler.h
浏览文件 @
dcfdff60
...
...
@@ -41,7 +41,7 @@ class SequentialSampler : public Sampler {
// for next epoch of sampleIds
// @return - The error code return
Status
Reset
()
override
;
Status
Reset
Sampler
()
override
;
// Op calls this to get next Buffer that contains all the sampleIds
// @param std::unique_ptr<DataBuffer> pBuffer - Buffer to be returned to StorageOp
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/subset_random_sampler.cc
浏览文件 @
dcfdff60
...
...
@@ -55,7 +55,7 @@ Status SubsetRandomSampler::InitSampler() {
}
// Reset the internal variable to the initial state.
Status
SubsetRandomSampler
::
Reset
()
{
Status
SubsetRandomSampler
::
Reset
Sampler
()
{
// Reset the internal counters.
sample_id_
=
0
;
buffer_id_
=
0
;
...
...
@@ -65,7 +65,7 @@ Status SubsetRandomSampler::Reset() {
std
::
shuffle
(
indices_
.
begin
(),
indices_
.
end
(),
rand_gen_
);
if
(
HasChildSampler
())
{
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
());
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
Sampler
());
}
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/subset_random_sampler.h
浏览文件 @
dcfdff60
...
...
@@ -44,7 +44,7 @@ class SubsetRandomSampler : public Sampler {
// Reset the internal variable to the initial state and reshuffle the indices.
// @return Status
Status
Reset
()
override
;
Status
Reset
Sampler
()
override
;
// Get the sample ids.
// @param[out] out_buffer The address of a unique_ptr to DataBuffer where the sample ids will be placed.
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/weighted_random_sampler.cc
浏览文件 @
dcfdff60
...
...
@@ -77,7 +77,7 @@ void WeightedRandomSampler::InitOnePassSampling() {
}
// Reset the internal variable to the initial state and reshuffle the indices.
Status
WeightedRandomSampler
::
Reset
()
{
Status
WeightedRandomSampler
::
Reset
Sampler
()
{
sample_id_
=
0
;
buffer_id_
=
0
;
rand_gen_
.
seed
(
GetSeed
());
...
...
@@ -88,7 +88,7 @@ Status WeightedRandomSampler::Reset() {
}
if
(
HasChildSampler
())
{
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
());
RETURN_IF_NOT_OK
(
child_
[
0
]
->
Reset
Sampler
());
}
return
Status
::
OK
();
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/weighted_random_sampler.h
浏览文件 @
dcfdff60
...
...
@@ -46,7 +46,7 @@ class WeightedRandomSampler : public Sampler {
Status
InitSampler
()
override
;
// Reset the internal variable to the initial state and reshuffle the indices.
Status
Reset
()
override
;
Status
Reset
Sampler
()
override
;
// Get the sample ids.
// @param[out] out_buffer The address of a unique_ptr to DataBuffer where the sample ids will be placed.
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/voc_op.cc
浏览文件 @
dcfdff60
...
...
@@ -177,7 +177,7 @@ void VOCOp::Print(std::ostream &out, bool show_all) const {
}
Status
VOCOp
::
Reset
()
{
RETURN_IF_NOT_OK
(
sampler_
->
Reset
());
RETURN_IF_NOT_OK
(
sampler_
->
Reset
Sampler
());
row_cnt_
=
0
;
wp_
.
Set
();
return
Status
::
OK
();
...
...
tests/ut/cpp/dataset/stand_alone_samplers_test.cc
浏览文件 @
dcfdff60
...
...
@@ -94,7 +94,7 @@ TEST_F(MindDataTestStandAloneSampler, TestStandAoneSequentialSampler) {
sampler
->
GetNextSample
(
&
db
);
db
->
GetTensor
(
&
tensor
,
0
,
0
);
EXPECT_TRUE
((
*
tensor
)
==
(
*
label2
));
sampler
->
Reset
();
sampler
->
Reset
Sampler
();
sampler
->
GetNextSample
(
&
db
);
db
->
GetTensor
(
&
tensor
,
0
,
0
);
EXPECT_TRUE
((
*
tensor
)
==
(
*
label1
));
...
...
tests/ut/cpp/dataset/subset_random_sampler_test.cc
浏览文件 @
dcfdff60
...
...
@@ -123,7 +123,7 @@ TEST_F(MindDataTestSubsetRandomSampler, TestReset) {
ASSERT_NE
(
in_set
.
find
(
out
[
i
]),
in_set
.
end
());
}
sampler
.
Reset
();
sampler
.
Reset
Sampler
();
ASSERT_EQ
(
sampler
.
GetNextSample
(
&
db
),
Status
::
OK
());
ASSERT_EQ
(
db
->
eoe
(),
false
);
...
...
tests/ut/cpp/dataset/weighted_random_sampler_test.cc
浏览文件 @
dcfdff60
...
...
@@ -214,7 +214,7 @@ TEST_F(MindDataTestWeightedRandomSampler, TestResetReplacement) {
ASSERT_EQ
(
m_sampler
.
GetNextSample
(
&
db
),
Status
::
OK
());
ASSERT_EQ
(
db
->
eoe
(),
true
);
m_sampler
.
Reset
();
m_sampler
.
Reset
Sampler
();
out
.
clear
();
ASSERT_EQ
(
m_sampler
.
GetNextSample
(
&
db
),
Status
::
OK
());
...
...
@@ -259,7 +259,7 @@ TEST_F(MindDataTestWeightedRandomSampler, TestResetNoReplacement) {
ASSERT_EQ
(
m_sampler
.
GetNextSample
(
&
db
),
Status
::
OK
());
ASSERT_EQ
(
db
->
eoe
(),
true
);
m_sampler
.
Reset
();
m_sampler
.
Reset
Sampler
();
out
.
clear
();
freq
.
clear
();
freq
.
resize
(
total_samples
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录