|
|
|
@ -167,39 +167,61 @@ TEST_F(MindDataTestPipeline, TestCelebAGetDatasetSize) {
|
|
|
|
|
EXPECT_EQ(ds->GetDatasetSize(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestCelebAException) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestCelebAException.";
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestCelebAError) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestCelebAError.";
|
|
|
|
|
|
|
|
|
|
// Create a CelebA Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testCelebAData/";
|
|
|
|
|
std::string invalid_folder_path = "./testNotExist";
|
|
|
|
|
std::string invalid_dataset_type = "invalid_type";
|
|
|
|
|
std::shared_ptr<Dataset> ds = CelebA(invalid_folder_path);
|
|
|
|
|
EXPECT_EQ(ds, nullptr);
|
|
|
|
|
std::shared_ptr<Dataset> ds1 = CelebA(folder_path, invalid_dataset_type);
|
|
|
|
|
EXPECT_EQ(ds1, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a CelebA Dataset
|
|
|
|
|
std::shared_ptr<Dataset> ds1 = CelebA(invalid_folder_path);
|
|
|
|
|
EXPECT_NE(ds1, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create an iterator over the result of the above dataset
|
|
|
|
|
std::shared_ptr<Iterator> iter1 = ds1->CreateIterator();
|
|
|
|
|
// Expect failure: invalid CelebA input, invalid dataset path
|
|
|
|
|
EXPECT_EQ(iter1, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a CelebA Dataset
|
|
|
|
|
std::shared_ptr<Dataset> ds2 = CelebA(folder_path, invalid_dataset_type);
|
|
|
|
|
EXPECT_NE(ds2, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create an iterator over the result of the above dataset
|
|
|
|
|
std::shared_ptr<Iterator> iter2 = ds2->CreateIterator();
|
|
|
|
|
// Expect failure: invalid CelebA input, invalid dataset type
|
|
|
|
|
EXPECT_EQ(iter2, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestCelebADatasetWithNullSampler) {
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestCelebADatasetWithNullSamplerError) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestCelebADataset.";
|
|
|
|
|
|
|
|
|
|
// Create a CelebA Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testCelebAData/";
|
|
|
|
|
std::shared_ptr<Dataset> ds = CelebA(folder_path, "all", nullptr, false, {});
|
|
|
|
|
// Expect failure: sampler can not be nullptr
|
|
|
|
|
EXPECT_EQ(ds, nullptr);
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create an iterator over the result of the above dataset
|
|
|
|
|
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
|
|
|
|
// Expect failure: invalid CelebA input, sampler cannot be nullptr
|
|
|
|
|
EXPECT_EQ(iter, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestImageFolderWithWrongDatasetDir) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestImageFolderWithWrongDatasetDir.";
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestImageFolderWithWrongDatasetDirFail) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestImageFolderWithWrongDatasetDirFail.";
|
|
|
|
|
|
|
|
|
|
// Create an ImageFolder Dataset
|
|
|
|
|
std::shared_ptr<Dataset> ds = ImageFolder("", true, nullptr);
|
|
|
|
|
EXPECT_EQ(ds, nullptr);
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create an iterator over the result of the above dataset
|
|
|
|
|
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
|
|
|
|
// Expect failure: invalid ImageFolder input
|
|
|
|
|
EXPECT_EQ(iter, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestImageFolderFailWithWrongExtension) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestImageFolderFailWithWrongExtension.";
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestImageFolderFailWithWrongExtensionFail) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestImageFolderFailWithWrongExtensionFail.";
|
|
|
|
|
|
|
|
|
|
// Create an ImageFolder Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
|
|
|
@ -214,7 +236,7 @@ TEST_F(MindDataTestPipeline, TestImageFolderFailWithWrongExtension) {
|
|
|
|
|
// Iterate the dataset and get each row
|
|
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row;
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
// Expect no data: can not find files with specified extension
|
|
|
|
|
// Expect no data: cannot find files with specified extension
|
|
|
|
|
EXPECT_EQ(row.size(), 0);
|
|
|
|
|
|
|
|
|
|
// Manually terminate the pipeline
|
|
|
|
@ -236,24 +258,32 @@ TEST_F(MindDataTestPipeline, TestImageFolderGetters) {
|
|
|
|
|
EXPECT_EQ(ds->GetDatasetSize(), 44);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestImageFolderFailWithNullSampler) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestImageFolderFailWithNullSampler.";
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestImageFolderFailWithNullSamplerFail) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestImageFolderFailWithNullSamplerFail.";
|
|
|
|
|
|
|
|
|
|
// Create an ImageFolder Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
|
|
|
|
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, nullptr);
|
|
|
|
|
// Expect failure: sampler can not be nullptr
|
|
|
|
|
EXPECT_EQ(ds, nullptr);
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create an iterator over the result of the above dataset
|
|
|
|
|
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
|
|
|
|
// Expect failure: invalid ImageFolder input, sampler cannot be nullptr
|
|
|
|
|
EXPECT_EQ(iter, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestImageFolderFailWithWrongSampler) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestImageFolderFailWithWrongSampler.";
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestImageFolderFailWithWrongSamplerFail) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestImageFolderFailWithWrongSamplerFail.";
|
|
|
|
|
|
|
|
|
|
// Create a Cifar10 Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testCifar100Data/";
|
|
|
|
|
// Create an ImageFolder Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
|
|
|
|
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, SequentialSampler(-2, 5));
|
|
|
|
|
// Expect failure: sampler is not construnced correctly
|
|
|
|
|
EXPECT_EQ(ds, nullptr);
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create an iterator over the result of the above dataset
|
|
|
|
|
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
|
|
|
|
// Expect failure: invalid ImageFolder input, sampler is not constructed correctly
|
|
|
|
|
EXPECT_EQ(iter, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestMnistGetDatasetSize) {
|
|
|
|
@ -266,20 +296,29 @@ TEST_F(MindDataTestPipeline, TestMnistGetDatasetSize) {
|
|
|
|
|
EXPECT_EQ(ds->GetDatasetSize(), 20);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestMnistFailWithWrongDatasetDir) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestMnistFailWithWrongDatasetDir.";
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestMnistFailWithWrongDatasetDirFail) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestMnistFailWithWrongDatasetDirFail.";
|
|
|
|
|
|
|
|
|
|
// Create a Mnist Dataset
|
|
|
|
|
std::shared_ptr<Dataset> ds = Mnist("", "all", RandomSampler(false, 10));
|
|
|
|
|
EXPECT_EQ(ds, nullptr);
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create an iterator over the result of the above dataset
|
|
|
|
|
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
|
|
|
|
// Expect failure: invalid Mnist input, incorrect dataset directory input
|
|
|
|
|
EXPECT_EQ(iter, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestMnistFailWithNullSampler) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestMnistFailWithNullSampler.";
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestMnistFailWithNullSamplerFail) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestMnistFailWithNullSamplerFail.";
|
|
|
|
|
|
|
|
|
|
// Create a Mnist Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testMnistData/";
|
|
|
|
|
std::shared_ptr<Dataset> ds = Mnist(folder_path, "all", nullptr);
|
|
|
|
|
// Expect failure: sampler can not be nullptr
|
|
|
|
|
EXPECT_EQ(ds, nullptr);
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create an iterator over the result of the above dataset
|
|
|
|
|
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
|
|
|
|
// Expect failure: invalid Mnist input, sampler cannot be nullptr
|
|
|
|
|
EXPECT_EQ(iter, nullptr);
|
|
|
|
|
}
|