|
|
|
@@ -49,22 +49,22 @@ TEST_F(MindDataTestPipeline, TestBatchAndRepeat) { |
|
|
|
// Create a Mnist Dataset |
|
|
|
std::string folder_path = datasets_root_path_ + "/testMnistData/"; |
|
|
|
std::shared_ptr<Dataset> ds = Mnist(folder_path, RandomSampler(false, 10)); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 2; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -78,7 +78,7 @@ TEST_F(MindDataTestPipeline, TestBatchAndRepeat) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 10); |
|
|
|
EXPECT_EQ(i, 10); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -88,33 +88,33 @@ TEST_F(MindDataTestPipeline, TestTensorOpsAndMap) { |
|
|
|
// Create a Mnist Dataset |
|
|
|
std::string folder_path = datasets_root_path_ + "/testMnistData/"; |
|
|
|
std::shared_ptr<Dataset> ds = Mnist(folder_path, RandomSampler(false, 20)); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> resize_op = vision::Resize({30, 30}); |
|
|
|
EXPECT_TRUE(resize_op != nullptr); |
|
|
|
EXPECT_NE(resize_op, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> center_crop_op = vision::CenterCrop({16, 16}); |
|
|
|
EXPECT_TRUE(center_crop_op != nullptr); |
|
|
|
EXPECT_NE(center_crop_op, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({resize_op, center_crop_op}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -128,7 +128,7 @@ TEST_F(MindDataTestPipeline, TestTensorOpsAndMap) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 40); |
|
|
|
EXPECT_EQ(i, 40); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -138,34 +138,34 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps) { |
|
|
|
// Create a Mnist Dataset |
|
|
|
std::string folder_path = datasets_root_path_ + "/testMnistData/"; |
|
|
|
std::shared_ptr<Dataset> ds = Mnist(folder_path, RandomSampler(false, 20)); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 1; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> resize_op = vision::Resize({30, 30}); |
|
|
|
EXPECT_TRUE(resize_op != nullptr); |
|
|
|
EXPECT_NE(resize_op, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> random_crop_op = vision::RandomCrop({28, 28}); |
|
|
|
EXPECT_TRUE(random_crop_op != nullptr); |
|
|
|
EXPECT_NE(random_crop_op, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> center_crop_op = vision::CenterCrop({16, 16}); |
|
|
|
EXPECT_TRUE(center_crop_op != nullptr); |
|
|
|
EXPECT_NE(center_crop_op, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> uniform_aug_op = vision::UniformAugment({random_crop_op, center_crop_op}, 2); |
|
|
|
EXPECT_TRUE(uniform_aug_op != nullptr); |
|
|
|
EXPECT_NE(uniform_aug_op, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({resize_op, uniform_aug_op}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -179,7 +179,7 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 20); |
|
|
|
EXPECT_EQ(i, 20); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -189,33 +189,33 @@ TEST_F(MindDataTestPipeline, TestRandomFlip) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> random_vertical_flip_op = vision::RandomVerticalFlip(0.5); |
|
|
|
EXPECT_TRUE(random_vertical_flip_op != nullptr); |
|
|
|
EXPECT_NE(random_vertical_flip_op, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> random_horizontal_flip_op = vision::RandomHorizontalFlip(0.5); |
|
|
|
EXPECT_TRUE(random_horizontal_flip_op != nullptr); |
|
|
|
EXPECT_NE(random_horizontal_flip_op, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({random_vertical_flip_op, random_horizontal_flip_op}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -229,7 +229,7 @@ TEST_F(MindDataTestPipeline, TestRandomFlip) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 20); |
|
|
|
EXPECT_EQ(i, 20); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -239,22 +239,22 @@ TEST_F(MindDataTestPipeline, TestImageFolderBatchAndRepeat) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 2; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -268,7 +268,7 @@ TEST_F(MindDataTestPipeline, TestImageFolderBatchAndRepeat) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 10); |
|
|
|
EXPECT_EQ(i, 10); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -327,7 +327,7 @@ TEST_F(MindDataTestPipeline, TestImageFolderWithSamplers) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 12); |
|
|
|
EXPECT_EQ(i, 12); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -337,36 +337,36 @@ TEST_F(MindDataTestPipeline, TestPad) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> pad_op1 = vision::Pad({1, 2, 3, 4}, {0}, BorderType::kSymmetric); |
|
|
|
EXPECT_TRUE(pad_op1 != nullptr); |
|
|
|
EXPECT_NE(pad_op1, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> pad_op2 = vision::Pad({1}, {1, 1, 1}, BorderType::kEdge); |
|
|
|
EXPECT_TRUE(pad_op2 != nullptr); |
|
|
|
EXPECT_NE(pad_op2, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> pad_op3 = vision::Pad({1, 4}); |
|
|
|
EXPECT_TRUE(pad_op3 != nullptr); |
|
|
|
EXPECT_NE(pad_op3, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({pad_op1, pad_op2, pad_op3}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -380,7 +380,7 @@ TEST_F(MindDataTestPipeline, TestPad) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 20); |
|
|
|
EXPECT_EQ(i, 20); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -390,33 +390,33 @@ TEST_F(MindDataTestPipeline, TestCutOut) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> cut_out1 = vision::CutOut(30, 5); |
|
|
|
EXPECT_TRUE(cut_out1!= nullptr); |
|
|
|
EXPECT_NE(cut_out1, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> cut_out2 = vision::CutOut(30); |
|
|
|
EXPECT_TRUE(cut_out2 != nullptr); |
|
|
|
EXPECT_NE(cut_out2, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({cut_out1, cut_out2}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -430,7 +430,7 @@ TEST_F(MindDataTestPipeline, TestCutOut) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 20); |
|
|
|
EXPECT_EQ(i, 20); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -440,30 +440,30 @@ TEST_F(MindDataTestPipeline, TestNormalize) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> normalize = vision::Normalize({121.0, 115.0, 100.0}, {70.0, 68.0, 71.0}); |
|
|
|
EXPECT_TRUE(normalize != nullptr); |
|
|
|
EXPECT_NE(normalize, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({normalize}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -477,7 +477,7 @@ TEST_F(MindDataTestPipeline, TestNormalize) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 20); |
|
|
|
EXPECT_EQ(i, 20); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -487,30 +487,30 @@ TEST_F(MindDataTestPipeline, TestDecode) { |
|
|
|
// Create an ImageFolder Dataset |
|
|
|
std::string folder_path = datasets_root_path_ + "/testPK/data/"; |
|
|
|
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, false, RandomSampler(false, 10)); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> decode = vision::Decode(true); |
|
|
|
EXPECT_TRUE(decode != nullptr); |
|
|
|
EXPECT_NE(decode, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({decode}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -533,27 +533,27 @@ TEST_F(MindDataTestPipeline, TestShuffleDataset) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Shuffle operation on ds |
|
|
|
int32_t shuffle_size = 10; |
|
|
|
ds = ds->Shuffle(shuffle_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 2; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -567,7 +567,7 @@ TEST_F(MindDataTestPipeline, TestShuffleDataset) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 10); |
|
|
|
EXPECT_EQ(i, 10); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -579,17 +579,17 @@ TEST_F(MindDataTestPipeline, TestSkipDataset) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Skip operation on ds |
|
|
|
int32_t count = 3; |
|
|
|
ds = ds->Skip(count); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -605,7 +605,7 @@ TEST_F(MindDataTestPipeline, TestSkipDataset) { |
|
|
|
MS_LOG(INFO) << "Number of rows: " << i; |
|
|
|
|
|
|
|
// Expect 10-3=7 rows |
|
|
|
EXPECT_TRUE(i == 7); |
|
|
|
EXPECT_EQ(i, 7); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -617,13 +617,13 @@ TEST_F(MindDataTestPipeline, TestSkipDatasetError1) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Skip operation on ds with invalid count input |
|
|
|
int32_t count = -1; |
|
|
|
ds = ds->Skip(count); |
|
|
|
// Expect nullptr for invalid input skip_count |
|
|
|
EXPECT_TRUE(ds == nullptr); |
|
|
|
EXPECT_EQ(ds, nullptr); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestCifar10Dataset) { |
|
|
|
@@ -631,22 +631,22 @@ TEST_F(MindDataTestPipeline, TestCifar10Dataset) { |
|
|
|
// Create a Cifar10 Dataset |
|
|
|
std::string folder_path = datasets_root_path_ + "/testCifar10Data/"; |
|
|
|
std::shared_ptr<Dataset> ds = Cifar10(folder_path, 0, RandomSampler(false, 10)); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 2; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -660,7 +660,7 @@ TEST_F(MindDataTestPipeline, TestCifar10Dataset) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 10); |
|
|
|
EXPECT_EQ(i, 10); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -670,41 +670,41 @@ TEST_F(MindDataTestPipeline, TestRandomColorAdjust) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> random_color_adjust1 = vision::RandomColorAdjust({1.0}, {0.0}, {0.5}, {0.5}); |
|
|
|
EXPECT_TRUE(random_color_adjust1 != nullptr); |
|
|
|
EXPECT_NE(random_color_adjust1, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> random_color_adjust2 = vision::RandomColorAdjust({1.0, 1.0}, {0.0, 0.0}, {0.5, 0.5}, |
|
|
|
{0.5, 0.5}); |
|
|
|
EXPECT_TRUE(random_color_adjust2 != nullptr); |
|
|
|
EXPECT_NE(random_color_adjust2, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> random_color_adjust3 = vision::RandomColorAdjust({0.5, 1.0}, {0.0, 0.5}, {0.25, 0.5}, |
|
|
|
{0.25, 0.5}); |
|
|
|
EXPECT_TRUE(random_color_adjust3 != nullptr); |
|
|
|
EXPECT_NE(random_color_adjust3, nullptr); |
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> random_color_adjust4 = vision::RandomColorAdjust(); |
|
|
|
EXPECT_TRUE(random_color_adjust4 != nullptr); |
|
|
|
EXPECT_NE(random_color_adjust4, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({random_color_adjust1, random_color_adjust2, random_color_adjust3, random_color_adjust4}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -718,7 +718,7 @@ TEST_F(MindDataTestPipeline, TestRandomColorAdjust) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 20); |
|
|
|
EXPECT_EQ(i, 20); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -728,30 +728,30 @@ TEST_F(MindDataTestPipeline, TestRandomRotation) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> random_rotation_op = vision::RandomRotation({-180, 180}); |
|
|
|
EXPECT_TRUE(random_rotation_op != nullptr); |
|
|
|
EXPECT_NE(random_rotation_op, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({random_rotation_op}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -765,7 +765,7 @@ TEST_F(MindDataTestPipeline, TestRandomRotation) { |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_TRUE(i == 20); |
|
|
|
EXPECT_EQ(i, 20); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
@@ -775,35 +775,35 @@ TEST_F(MindDataTestPipeline, TestProjectMap) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create objects for the tensor ops |
|
|
|
std::shared_ptr<TensorOperation> random_vertical_flip_op = vision::RandomVerticalFlip(0.5); |
|
|
|
EXPECT_TRUE(random_vertical_flip_op != nullptr); |
|
|
|
EXPECT_NE(random_vertical_flip_op, nullptr); |
|
|
|
|
|
|
|
// Create a Map operation on ds |
|
|
|
ds = ds->Map({random_vertical_flip_op}, {}, {}, {"image", "label"}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Project operation on ds |
|
|
|
std::vector<std::string> column_project = {"image"}; |
|
|
|
ds = ds->Project(column_project); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -823,39 +823,47 @@ TEST_F(MindDataTestPipeline, TestProjectMap) { |
|
|
|
iter->Stop(); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestZip) { |
|
|
|
TEST_F(MindDataTestPipeline, TestZipSuccess) { |
|
|
|
// 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_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Project operation on ds |
|
|
|
std::vector<std::string> column_project = {"image"}; |
|
|
|
ds = ds->Project(column_project); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create an ImageFolder Dataset |
|
|
|
std::shared_ptr<Dataset> ds1 = ImageFolder(folder_path, true, RandomSampler(false, 10)); |
|
|
|
EXPECT_NE(ds1, nullptr); |
|
|
|
|
|
|
|
// Create a Rename operation on ds (so that the 3 datasets we are going to zip have distinct column names) |
|
|
|
ds1 = ds1->Rename({"image", "label"}, {"col1", "col2"}); |
|
|
|
EXPECT_NE(ds1, nullptr); |
|
|
|
|
|
|
|
folder_path = datasets_root_path_ + "/testCifar10Data/"; |
|
|
|
std::shared_ptr<Dataset> ds1 = Cifar10(folder_path, 0, RandomSampler(false, 10)); |
|
|
|
EXPECT_TRUE(ds1 != nullptr); |
|
|
|
std::shared_ptr<Dataset> ds2 = Cifar10(folder_path, 0, RandomSampler(false, 10)); |
|
|
|
EXPECT_NE(ds2, nullptr); |
|
|
|
|
|
|
|
// Create a Project operation on ds |
|
|
|
column_project = {"label"}; |
|
|
|
ds1 = ds1->Project(column_project); |
|
|
|
EXPECT_TRUE(ds1 != nullptr); |
|
|
|
ds2 = ds2->Project(column_project); |
|
|
|
EXPECT_NE(ds2, nullptr); |
|
|
|
|
|
|
|
// Create a Zip operation on the datasets |
|
|
|
ds = ds->Zip({ds, ds1}); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
ds = ds->Zip({ds, ds1, ds2}); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_TRUE(ds != nullptr); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_TRUE(iter != nullptr); |
|
|
|
EXPECT_NE(iter, nullptr); |
|
|
|
|
|
|
|
// Iterate the dataset and get each row |
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row; |
|
|
|
@@ -874,3 +882,97 @@ TEST_F(MindDataTestPipeline, TestZip) { |
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestZipFail) { |
|
|
|
// We expect this test to fail because we are the both datasets we are zipping have "image" and "label" columns |
|
|
|
// and zip doesn't accept datasets with same column names |
|
|
|
|
|
|
|
// 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 an ImageFolder Dataset |
|
|
|
std::shared_ptr<Dataset> ds1 = ImageFolder(folder_path, true, RandomSampler(false, 10)); |
|
|
|
EXPECT_NE(ds1, nullptr); |
|
|
|
|
|
|
|
// Create a Zip operation on the datasets |
|
|
|
ds = ds->Zip({ds, ds1}); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_NE(ds, 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 = ds->CreateIterator(); |
|
|
|
EXPECT_EQ(iter, nullptr); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestRenameSuccess) { |
|
|
|
// 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 Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Rename operation on ds |
|
|
|
ds = ds->Rename({"image", "label"}, {"col1", "col2"}); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Batch operation on ds |
|
|
|
int32_t batch_size = 1; |
|
|
|
ds = ds->Batch(batch_size); |
|
|
|
EXPECT_NE(ds, 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 = ds->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); |
|
|
|
|
|
|
|
uint64_t i = 0; |
|
|
|
EXPECT_NE(row.find("col1"), row.end()); |
|
|
|
EXPECT_NE(row.find("col2"), row.end()); |
|
|
|
EXPECT_EQ(row.find("image"), row.end()); |
|
|
|
EXPECT_EQ(row.find("label"), row.end()); |
|
|
|
|
|
|
|
while (row.size() != 0) { |
|
|
|
i++; |
|
|
|
auto image = row["col1"]; |
|
|
|
MS_LOG(INFO) << "Tensor image shape: " << image->shape(); |
|
|
|
iter->GetNextRow(&row); |
|
|
|
} |
|
|
|
|
|
|
|
EXPECT_EQ(i, 20); |
|
|
|
|
|
|
|
// Manually terminate the pipeline |
|
|
|
iter->Stop(); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestRenameFail) { |
|
|
|
// We expect this test to fail because input and output in Rename are not the same size |
|
|
|
|
|
|
|
// 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 Repeat operation on ds |
|
|
|
int32_t repeat_num = 2; |
|
|
|
ds = ds->Repeat(repeat_num); |
|
|
|
EXPECT_NE(ds, nullptr); |
|
|
|
|
|
|
|
// Create a Rename operation on ds |
|
|
|
ds = ds->Rename({"image", "label"}, {"col2"}); |
|
|
|
EXPECT_EQ(ds, nullptr); |
|
|
|
} |