|
|
|
@@ -735,3 +735,129 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheClueCApi) { |
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(MindDataTestCacheOp, DISABLED_TestCApiCacheShare) { |
|
|
|
session_id_type env_session; |
|
|
|
Status s = GetSessionFromEnv(&env_session); |
|
|
|
EXPECT_EQ(s, Status::OK()); |
|
|
|
|
|
|
|
std::shared_ptr<DatasetCache> some_cache = CreateDatasetCache(env_session, 0, true); |
|
|
|
EXPECT_NE(some_cache, nullptr); |
|
|
|
|
|
|
|
// Create an ImageFolder Dataset, this folder_path only has 2 images in it |
|
|
|
std::string folder_path = datasets_root_path_ + "/testImageNetData/train/"; |
|
|
|
std::shared_ptr<Dataset> ds1 = ImageFolder(folder_path, false, RandomSampler(), {}, {}, some_cache); |
|
|
|
EXPECT_NE(ds1, nullptr); |
|
|
|
std::shared_ptr<Dataset> ds2 = ImageFolder(folder_path, false, RandomSampler(), {}, {}, some_cache); |
|
|
|
EXPECT_NE(ds2, nullptr); |
|
|
|
|
|
|
|
// Create and launch the Execution Tree for ds1 |
|
|
|
std::shared_ptr<Iterator> iter1 = ds1->CreateIterator(); |
|
|
|
EXPECT_NE(iter1, nullptr); |
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
iter1->GetNextRow(&row); |
|
|
|
|
|
|
|
uint64_t i = 0; |
|
|
|
while (row.size() != 0) { |
|
|
|
i++; |
|
|
|
auto image = row["image"]; |
|
|
|
MS_LOG(INFO) << "Tensor image shape: " << image->shape(); |
|
|
|
iter1->GetNextRow(&row); |
|
|
|
} |
|
|
|
EXPECT_EQ(i, 2); |
|
|
|
// Manually terminate the pipeline |
|
|
|
iter1->Stop(); |
|
|
|
|
|
|
|
// Create and launch the Execution Tree for ds2 |
|
|
|
std::shared_ptr<Iterator> iter2 = ds2->CreateIterator(); |
|
|
|
EXPECT_NE(iter2, nullptr); |
|
|
|
// Iterate the dataset and get each row |
|
|
|
iter2->GetNextRow(&row); |
|
|
|
|
|
|
|
i = 0; |
|
|
|
while (row.size() != 0) { |
|
|
|
i++; |
|
|
|
auto image = row["image"]; |
|
|
|
MS_LOG(INFO) << "Tensor image shape: " << image->shape(); |
|
|
|
iter2->GetNextRow(&row); |
|
|
|
} |
|
|
|
EXPECT_EQ(i, 2); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter2->Stop(); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(MindDataTestCacheOp, DISABLED_TestCApiCacheShareFailure1) { |
|
|
|
session_id_type env_session; |
|
|
|
Status s = GetSessionFromEnv(&env_session); |
|
|
|
EXPECT_EQ(s, Status::OK()); |
|
|
|
|
|
|
|
std::shared_ptr<DatasetCache> some_cache = CreateDatasetCache(env_session, 0, true); |
|
|
|
EXPECT_NE(some_cache, nullptr); |
|
|
|
|
|
|
|
// Create an ImageFolder Dataset, this folder_path only has 2 images in it |
|
|
|
std::string folder_path = datasets_root_path_ + "/testImageNetData/train/"; |
|
|
|
std::shared_ptr<Dataset> ds1 = ImageFolder(folder_path, true, RandomSampler(), {}, {}, some_cache); |
|
|
|
EXPECT_NE(ds1, nullptr); |
|
|
|
std::shared_ptr<Dataset> ds2 = ImageFolder(folder_path, true, SequentialSampler(), {}, {}, some_cache); |
|
|
|
EXPECT_NE(ds2, nullptr); |
|
|
|
|
|
|
|
// Create and launch the Execution Tree for ds1 |
|
|
|
std::shared_ptr<Iterator> iter1 = ds1->CreateIterator(); |
|
|
|
EXPECT_NE(iter1, nullptr); |
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
iter1->GetNextRow(&row); |
|
|
|
|
|
|
|
uint64_t i = 0; |
|
|
|
while (row.size() != 0) { |
|
|
|
i++; |
|
|
|
auto image = row["image"]; |
|
|
|
iter1->GetNextRow(&row); |
|
|
|
} |
|
|
|
EXPECT_EQ(i, 2); |
|
|
|
// Manually terminate the pipeline |
|
|
|
iter1->Stop(); |
|
|
|
|
|
|
|
// Re-use a cache for the second pipeline would fail |
|
|
|
std::shared_ptr<Iterator> iter2 = ds2->CreateIterator(); |
|
|
|
EXPECT_EQ(iter2, nullptr); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(MindDataTestCacheOp, DISABLED_TestCApiCacheShareFailure2) { |
|
|
|
session_id_type env_session; |
|
|
|
Status s = GetSessionFromEnv(&env_session); |
|
|
|
EXPECT_EQ(s, Status::OK()); |
|
|
|
|
|
|
|
std::shared_ptr<DatasetCache> some_cache = CreateDatasetCache(env_session, 0, true); |
|
|
|
EXPECT_NE(some_cache, nullptr); |
|
|
|
|
|
|
|
// Create an ImageFolder Dataset, this folder_path only has 2 images in it |
|
|
|
std::string folder_path = datasets_root_path_ + "/testImageNetData/train/"; |
|
|
|
std::shared_ptr<Dataset> ds1 = ImageFolder(folder_path, true, RandomSampler(), {}, {}, some_cache); |
|
|
|
EXPECT_NE(ds1, nullptr); |
|
|
|
std::shared_ptr<Dataset> ds2 = ImageFolder(folder_path, false, RandomSampler(), {}, {}, some_cache); |
|
|
|
EXPECT_NE(ds2, nullptr); |
|
|
|
|
|
|
|
// Create and launch the Execution Tree for ds1 |
|
|
|
std::shared_ptr<Iterator> iter1 = ds1->CreateIterator(); |
|
|
|
EXPECT_NE(iter1, nullptr); |
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
iter1->GetNextRow(&row); |
|
|
|
|
|
|
|
uint64_t i = 0; |
|
|
|
while (row.size() != 0) { |
|
|
|
i++; |
|
|
|
auto image = row["image"]; |
|
|
|
iter1->GetNextRow(&row); |
|
|
|
} |
|
|
|
EXPECT_EQ(i, 2); |
|
|
|
// Manually terminate the pipeline |
|
|
|
iter1->Stop(); |
|
|
|
|
|
|
|
// Re-use a cache for the second pipeline would fail |
|
|
|
std::shared_ptr<Iterator> iter2 = ds2->CreateIterator(); |
|
|
|
EXPECT_EQ(iter2, nullptr); |
|
|
|
} |