Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
2e3f5cd4
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看板
提交
2e3f5cd4
编写于
8月 25, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 25, 2020
浏览文件
操作
浏览文件
下载
差异文件
!5114 fix bug in c-api: rename, concat, take
Merge pull request !5114 from luoyang/c-api-pyfunc
上级
d173b055
b26f6b3d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
6 deletion
+40
-6
mindspore/ccsrc/minddata/dataset/api/datasets.cc
mindspore/ccsrc/minddata/dataset/api/datasets.cc
+16
-2
tests/ut/cpp/dataset/c_api_dataset_ops_test.cc
tests/ut/cpp/dataset/c_api_dataset_ops_test.cc
+24
-4
未找到文件。
mindspore/ccsrc/minddata/dataset/api/datasets.cc
浏览文件 @
2e3f5cd4
...
...
@@ -221,7 +221,7 @@ std::shared_ptr<MnistDataset> Mnist(const std::string &dataset_dir, const std::s
// Function to overload "+" operator to concat two datasets
std
::
shared_ptr
<
ConcatDataset
>
operator
+
(
const
std
::
shared_ptr
<
Dataset
>
&
datasets1
,
const
std
::
shared_ptr
<
Dataset
>
&
datasets2
)
{
std
::
shared_ptr
<
ConcatDataset
>
ds
=
std
::
make_shared
<
ConcatDataset
>
(
std
::
vector
({
datasets
1
,
datasets2
}));
std
::
shared_ptr
<
ConcatDataset
>
ds
=
std
::
make_shared
<
ConcatDataset
>
(
std
::
vector
({
datasets
2
,
datasets1
}));
// Call derived class validation method.
return
ds
->
ValidateParams
()
?
ds
:
nullptr
;
...
...
@@ -1592,6 +1592,10 @@ bool ConcatDataset::ValidateParams() {
MS_LOG
(
ERROR
)
<<
"Concat: concatenated datasets are not specified."
;
return
false
;
}
if
(
find
(
datasets_
.
begin
(),
datasets_
.
end
(),
nullptr
)
!=
datasets_
.
end
())
{
MS_LOG
(
ERROR
)
<<
"Concat: concatenated dataset should not be null."
;
return
false
;
}
return
true
;
}
...
...
@@ -1676,6 +1680,16 @@ bool RenameDataset::ValidateParams() {
MS_LOG
(
ERROR
)
<<
"input and output columns must be the same size"
;
return
false
;
}
for
(
uint32_t
i
=
0
;
i
<
input_columns_
.
size
();
++
i
)
{
if
(
input_columns_
[
i
].
empty
())
{
MS_LOG
(
ERROR
)
<<
"input_columns: column name should not be empty."
;
return
false
;
}
if
(
output_columns_
[
i
].
empty
())
{
MS_LOG
(
ERROR
)
<<
"output_columns: column name should not be empty."
;
return
false
;
}
}
return
true
;
}
...
...
@@ -1766,7 +1780,7 @@ std::vector<std::shared_ptr<DatasetOp>> TakeDataset::Build() {
// Function to validate the parameters for TakeDataset
bool
TakeDataset
::
ValidateParams
()
{
if
(
take_count_
<
0
&&
take_count_
!=
-
1
)
{
if
(
take_count_
<
=
0
&&
take_count_
!=
-
1
)
{
MS_LOG
(
ERROR
)
<<
"Take: take_count should be either -1 or positive integer, take_count: "
<<
take_count_
;
return
false
;
}
...
...
tests/ut/cpp/dataset/c_api_dataset_ops_test.cc
浏览文件 @
2e3f5cd4
...
...
@@ -362,8 +362,8 @@ TEST_F(MindDataTestPipeline, TestProjectMapAutoInjection) {
iter
->
Stop
();
}
TEST_F
(
MindDataTestPipeline
,
TestRenameFail
)
{
MS_LOG
(
INFO
)
<<
"Doing MindDataTestPipeline-TestRenameFail."
;
TEST_F
(
MindDataTestPipeline
,
TestRenameFail
1
)
{
MS_LOG
(
INFO
)
<<
"Doing MindDataTestPipeline-TestRenameFail
1
."
;
// We expect this test to fail because input and output in Rename are not the same size
// Create an ImageFolder Dataset
...
...
@@ -381,6 +381,20 @@ TEST_F(MindDataTestPipeline, TestRenameFail) {
EXPECT_EQ
(
ds
,
nullptr
);
}
TEST_F
(
MindDataTestPipeline
,
TestRenameFail2
)
{
MS_LOG
(
INFO
)
<<
"Doing MindDataTestPipeline-TestRenameFail2."
;
// We expect this test to fail because input or output column name is empty
// Create an ImageFolder Dataset
std
::
string
folder_path
=
datasets_root_path_
+
"/testPK/data/"
;
std
::
shared_ptr
<
Dataset
>
ds
=
ImageFolder
(
folder_path
,
true
,
RandomSampler
(
false
,
10
));
EXPECT_NE
(
ds
,
nullptr
);
// Create a Rename operation on ds
ds
=
ds
->
Rename
({
"image"
,
"label"
},
{
"col2"
,
""
});
EXPECT_EQ
(
ds
,
nullptr
);
}
TEST_F
(
MindDataTestPipeline
,
TestRenameSuccess
)
{
MS_LOG
(
INFO
)
<<
"Doing MindDataTestPipeline-TestRenameSuccess."
;
...
...
@@ -688,9 +702,15 @@ TEST_F(MindDataTestPipeline, TestTakeDatasetError1) {
// Create a Take operation on ds with invalid count input
int32_t
count
=
-
5
;
ds
=
ds
->
Take
(
count
);
auto
ds1
=
ds
->
Take
(
count
);
// Expect nullptr for invalid input take_count
EXPECT_EQ
(
ds
,
nullptr
);
EXPECT_EQ
(
ds1
,
nullptr
);
// Create a Take operation on ds with invalid count input
count
=
0
;
auto
ds2
=
ds
->
Take
(
count
);
// Expect nullptr for invalid input take_count
EXPECT_EQ
(
ds2
,
nullptr
);
}
TEST_F
(
MindDataTestPipeline
,
TestTakeDatasetNormal
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录