|
|
|
@ -69,6 +69,65 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic1) {
|
|
|
|
|
iter->Stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestRandomDatasetBasicWithPipeline) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRandomDatasetBasic1.";
|
|
|
|
|
|
|
|
|
|
// Create two RandomDataset
|
|
|
|
|
std::shared_ptr<SchemaObj> schema = Schema();
|
|
|
|
|
schema->add_column("image", mindspore::TypeId::kNumberTypeUInt8, {2});
|
|
|
|
|
schema->add_column("label", mindspore::TypeId::kNumberTypeUInt8, {1});
|
|
|
|
|
std::shared_ptr<Dataset> ds1 = RandomData(50, schema);
|
|
|
|
|
std::shared_ptr<Dataset> ds2 = RandomData(50, schema);
|
|
|
|
|
EXPECT_NE(ds1, nullptr);
|
|
|
|
|
EXPECT_NE(ds2, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create two Repeat operation on ds
|
|
|
|
|
int32_t repeat_num = 2;
|
|
|
|
|
ds1 = ds1->Repeat(repeat_num);
|
|
|
|
|
EXPECT_NE(ds1, nullptr);
|
|
|
|
|
repeat_num = 2;
|
|
|
|
|
ds2 = ds2->Repeat(repeat_num);
|
|
|
|
|
EXPECT_NE(ds2, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create two Project operation on ds
|
|
|
|
|
std::vector<std::string> column_project = {"image", "label"};
|
|
|
|
|
ds1 = ds1->Project(column_project);
|
|
|
|
|
EXPECT_NE(ds1, nullptr);
|
|
|
|
|
ds2 = ds2->Project(column_project);
|
|
|
|
|
EXPECT_NE(ds2, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Concat operation on the ds
|
|
|
|
|
ds1 = ds1->Concat({ds2});
|
|
|
|
|
EXPECT_NE(ds1, nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an iterator over the result of the above dataset
|
|
|
|
|
// This will trigger the creation of the Execution Tree and launch it.
|
|
|
|
|
std::shared_ptr<Iterator> iter = ds1->CreateIterator();
|
|
|
|
|
EXPECT_NE(iter, nullptr);
|
|
|
|
|
|
|
|
|
|
// Iterate the dataset and get each row
|
|
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row;
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
|
|
|
|
|
// Check if RandomDataOp read correct columns
|
|
|
|
|
uint64_t i = 0;
|
|
|
|
|
while (row.size() != 0) {
|
|
|
|
|
auto image = row["image"];
|
|
|
|
|
auto label = row["label"];
|
|
|
|
|
MS_LOG(INFO) << "Tensor image shape: " << image->shape();
|
|
|
|
|
MS_LOG(INFO) << "Tensor label shape: " << label->shape();
|
|
|
|
|
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(i, 200);
|
|
|
|
|
|
|
|
|
|
// Manually terminate the pipeline
|
|
|
|
|
iter->Stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestRandomDatasetGetters) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRandomDatasetGetters.";
|
|
|
|
|
|
|
|
|
|