|
|
@ -62,104 +62,3 @@ TEST_F(MindDataTestEager, Test1) {
|
|
|
|
double elapsed_time_ms = std::chrono::duration<double, std::milli>(t_end-t_start).count();
|
|
|
|
double elapsed_time_ms = std::chrono::duration<double, std::milli>(t_end-t_start).count();
|
|
|
|
MS_LOG(INFO) << "duration: " << elapsed_time_ms << " ms\n";
|
|
|
|
MS_LOG(INFO) << "duration: " << elapsed_time_ms << " ms\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
TEST_F(MindDataTestEager, Test2) {
|
|
|
|
|
|
|
|
// string dir for image folder
|
|
|
|
|
|
|
|
std::string in_dir = datasets_root_path_ + "/testPK/data";
|
|
|
|
|
|
|
|
// run dataset with decode = on
|
|
|
|
|
|
|
|
std::shared_ptr<Dataset> ds = ImageFolder(in_dir, true, RandomSampler(false));
|
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> normalize_op = vision::Normalize({121.0, 115.0, 100.0}, {70.0, 68.0, 71.0});
|
|
|
|
|
|
|
|
EXPECT_TRUE(normalize_op != nullptr);
|
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> resize_op = vision::Resize({224, 224});
|
|
|
|
|
|
|
|
EXPECT_TRUE(resize_op != nullptr);
|
|
|
|
|
|
|
|
ds = ds->Map({normalize_op, resize_op});
|
|
|
|
|
|
|
|
EXPECT_TRUE(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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate the dataset and get each row
|
|
|
|
|
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row;
|
|
|
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t i = 0;
|
|
|
|
|
|
|
|
while (row.size() != 0) {
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
auto image = row["image"];
|
|
|
|
|
|
|
|
MS_LOG(INFO) << "Tensor image shape: " << image->shape();
|
|
|
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MS_LOG(WARNING) << i << ".";
|
|
|
|
|
|
|
|
iter->Stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestEager, Test3) {
|
|
|
|
|
|
|
|
// string dir for image folder
|
|
|
|
|
|
|
|
ConfigManager cm = ConfigManager();
|
|
|
|
|
|
|
|
cm.set_num_parallel_workers(1);
|
|
|
|
|
|
|
|
std::string in_dir = datasets_root_path_ + "/testPK/data";
|
|
|
|
|
|
|
|
// run dataset with decode = on
|
|
|
|
|
|
|
|
std::shared_ptr<Dataset> ds = ImageFolder(in_dir, true, RandomSampler(false));
|
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> normalize_op = vision::Normalize({121.0, 115.0, 100.0}, {70.0, 68.0, 71.0});
|
|
|
|
|
|
|
|
EXPECT_TRUE(normalize_op != nullptr);
|
|
|
|
|
|
|
|
std::shared_ptr<TensorOperation> resize_op = vision::Resize({224, 224});
|
|
|
|
|
|
|
|
EXPECT_TRUE(resize_op != nullptr);
|
|
|
|
|
|
|
|
ds = ds->Map({normalize_op, resize_op});
|
|
|
|
|
|
|
|
EXPECT_TRUE(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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate the dataset and get each row
|
|
|
|
|
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row;
|
|
|
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t i = 0;
|
|
|
|
|
|
|
|
while (row.size() != 0) {
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
auto image = row["image"];
|
|
|
|
|
|
|
|
MS_LOG(INFO) << "Tensor image shape: " << image->shape();
|
|
|
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MS_LOG(WARNING) << i << ".";
|
|
|
|
|
|
|
|
iter->Stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestEager, Test4) {
|
|
|
|
|
|
|
|
// string dir for image folder
|
|
|
|
|
|
|
|
ConfigManager cm = ConfigManager();
|
|
|
|
|
|
|
|
cm.set_num_parallel_workers(1);
|
|
|
|
|
|
|
|
std::string in_dir = datasets_root_path_ + "/testPK/data";
|
|
|
|
|
|
|
|
// run dataset with decode = on
|
|
|
|
|
|
|
|
std::shared_ptr<Dataset> ds = ImageFolder(in_dir, true, RandomSampler(false));
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate the dataset and get each row
|
|
|
|
|
|
|
|
std::unordered_map<std::string, std::shared_ptr<Tensor>> row;
|
|
|
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t i = 0;
|
|
|
|
|
|
|
|
while (row.size() != 0) {
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
auto image = row["image"];
|
|
|
|
|
|
|
|
image = Execute(vision::Normalize({121.0, 115.0, 100.0}, {70.0, 68.0, 71.0}))(image);
|
|
|
|
|
|
|
|
EXPECT_TRUE(image != nullptr);
|
|
|
|
|
|
|
|
image = Execute(vision::Resize({224, 224}))(image);
|
|
|
|
|
|
|
|
EXPECT_TRUE(image != nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MS_LOG(INFO) << "Tensor image shape: " << image->shape();
|
|
|
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MS_LOG(WARNING) << i << ".";
|
|
|
|
|
|
|
|
iter->Stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|