Browse Source

dataset UT: Update UTs to check for return Status

pull/15191/head
Cathy Wong 4 years ago
parent
commit
a2ee0cb3e5
42 changed files with 733 additions and 737 deletions
  1. +5
    -5
      tests/ut/cpp/dataset/album_op_test.cc
  2. +44
    -44
      tests/ut/cpp/dataset/c_api_cache_test.cc
  3. +8
    -8
      tests/ut/cpp/dataset/c_api_dataset_album_test.cc
  4. +6
    -6
      tests/ut/cpp/dataset/c_api_dataset_cifar_test.cc
  5. +39
    -39
      tests/ut/cpp/dataset/c_api_dataset_clue_test.cc
  6. +12
    -12
      tests/ut/cpp/dataset/c_api_dataset_coco_test.cc
  7. +6
    -6
      tests/ut/cpp/dataset/c_api_dataset_config_test.cc
  8. +29
    -29
      tests/ut/cpp/dataset/c_api_dataset_csv_test.cc
  9. +10
    -10
      tests/ut/cpp/dataset/c_api_dataset_iterator_test.cc
  10. +13
    -13
      tests/ut/cpp/dataset/c_api_dataset_manifest_test.cc
  11. +18
    -18
      tests/ut/cpp/dataset/c_api_dataset_minddata_test.cc
  12. +55
    -56
      tests/ut/cpp/dataset/c_api_dataset_ops_test.cc
  13. +30
    -30
      tests/ut/cpp/dataset/c_api_dataset_randomdata_test.cc
  14. +4
    -4
      tests/ut/cpp/dataset/c_api_dataset_save.cc
  15. +32
    -32
      tests/ut/cpp/dataset/c_api_dataset_textfile_test.cc
  16. +28
    -28
      tests/ut/cpp/dataset/c_api_dataset_tfrecord_test.cc
  17. +6
    -6
      tests/ut/cpp/dataset/c_api_dataset_voc_test.cc
  18. +5
    -5
      tests/ut/cpp/dataset/c_api_datasets_test.cc
  19. +16
    -16
      tests/ut/cpp/dataset/c_api_epoch_ctrl_test.cc
  20. +3
    -6
      tests/ut/cpp/dataset/c_api_pull_based_test.cc
  21. +2
    -2
      tests/ut/cpp/dataset/c_api_repeat_test.cc
  22. +14
    -14
      tests/ut/cpp/dataset/c_api_samplers_test.cc
  23. +4
    -4
      tests/ut/cpp/dataset/c_api_text_sentence_piece_vocab_test.cc
  24. +112
    -112
      tests/ut/cpp/dataset/c_api_text_test.cc
  25. +10
    -10
      tests/ut/cpp/dataset/c_api_text_vocab_test.cc
  26. +46
    -46
      tests/ut/cpp/dataset/c_api_transforms_test.cc
  27. +28
    -28
      tests/ut/cpp/dataset/c_api_vision_a_to_q_test.cc
  28. +2
    -2
      tests/ut/cpp/dataset/c_api_vision_affine_test.cc
  29. +6
    -6
      tests/ut/cpp/dataset/c_api_vision_bounding_box_augment_test.cc
  30. +10
    -10
      tests/ut/cpp/dataset/c_api_vision_r_to_z_test.cc
  31. +8
    -8
      tests/ut/cpp/dataset/c_api_vision_random_subselect_policy_test.cc
  32. +46
    -46
      tests/ut/cpp/dataset/c_api_vision_random_test.cc
  33. +8
    -8
      tests/ut/cpp/dataset/c_api_vision_soft_dvpp_test.cc
  34. +6
    -6
      tests/ut/cpp/dataset/c_api_vision_uniform_aug_test.cc
  35. +15
    -15
      tests/ut/cpp/dataset/celeba_op_test.cc
  36. +6
    -6
      tests/ut/cpp/dataset/cifar_op_test.cc
  37. +19
    -19
      tests/ut/cpp/dataset/image_folder_op_test.cc
  38. +2
    -2
      tests/ut/cpp/dataset/ir_callback_test.cc
  39. +9
    -9
      tests/ut/cpp/dataset/manifest_op_test.cc
  40. +6
    -6
      tests/ut/cpp/dataset/map_op_test.cc
  41. +4
    -4
      tests/ut/cpp/dataset/mnist_op_test.cc
  42. +1
    -1
      tests/ut/cpp/dataset/optimization_pass_test.cc

+ 5
- 5
tests/ut/cpp/dataset/album_op_test.cc View File

@@ -96,7 +96,7 @@ TEST_F(MindDataTestAlbum, TestSequentialAlbumWithSchema) {
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "label shape"
<< tensor_map["label"] << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
MS_LOG(INFO) << "got rows: " << i << "\n";
EXPECT_TRUE(i == 14);
@@ -114,7 +114,7 @@ TEST_F(MindDataTestAlbum, TestSequentialAlbumWithSchemaNoOrder) {
ASSERT_OK(tree->Launch());
DatasetIterator di(tree);
TensorMap tensor_map;
ASSERT_TRUE(di.GetNextAsMap(&tensor_map));
ASSERT_OK(di.GetNextAsMap(&tensor_map));
uint64_t i = 0;
std::string_view label;
while (tensor_map.size() != 0) {
@@ -122,7 +122,7 @@ TEST_F(MindDataTestAlbum, TestSequentialAlbumWithSchemaNoOrder) {
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "label shape"
<< tensor_map["label"] << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
MS_LOG(INFO) << "got rows: " << i << "\n";
EXPECT_TRUE(i == 14);
@@ -151,7 +151,7 @@ TEST_F(MindDataTestAlbum, TestSequentialAlbumWithSchemaFloat) {
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "label shape"
<< tensor_map["label"] << "priority: " << priority << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
MS_LOG(INFO) << "got rows: " << i << "\n";
EXPECT_TRUE(i == 14);
@@ -183,7 +183,7 @@ TEST_F(MindDataTestAlbum, TestSequentialAlbumWithFullSchema) {
<< tensor_map["label"] << "priority: " << priority
<< " embedding : " << tensor_map["_embedding"]->shape() << " id: " << id << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
MS_LOG(INFO) << "got rows: " << i << "\n";
EXPECT_TRUE(i == 14);


+ 44
- 44
tests/ut/cpp/dataset/c_api_cache_test.cc View File

@@ -100,14 +100,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheImageFolderCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -143,14 +143,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheCocoCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 12);
@@ -184,14 +184,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheMnistCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -226,14 +226,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheCelebaCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 8);
@@ -267,14 +267,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheManifestCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -308,14 +308,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheCifar10CApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -349,14 +349,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheCifar100CApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -391,14 +391,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheVocCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 18);
@@ -435,12 +435,12 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheAlbumCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 14);
@@ -460,8 +460,8 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheRandomDataCApi) {
// Create a RandomDataset
std::shared_ptr<SchemaObj> schema = Schema();

schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2});
schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1});
ASSERT_OK(schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2}));
ASSERT_OK(schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1}));
std::shared_ptr<Dataset> ds = RandomData(8, schema, {}, some_cache);
EXPECT_NE(ds, nullptr);

@@ -477,12 +477,12 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheRandomDataCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 16);
@@ -518,14 +518,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheTFRecordCApi1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 6);
@@ -569,14 +569,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheTFRecordCApi2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -616,14 +616,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheTFRecordCApi3) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -661,12 +661,12 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheTextfileCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -705,12 +705,12 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheCsvCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -750,12 +750,12 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCacheClueCApi) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -784,14 +784,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCApiCacheShare1) {
EXPECT_NE(iter1, nullptr);
// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter1->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter1->GetNextRow(&row));
}
EXPECT_EQ(i, 2);
// Manually terminate the pipeline
@@ -801,14 +801,14 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCApiCacheShare1) {
std::shared_ptr<Iterator> iter2 = ds2->CreateIterator();
EXPECT_NE(iter2, nullptr);
// Iterate the dataset and get each row
iter2->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter2->GetNextRow(&row));
}
EXPECT_EQ(i, 2);

@@ -839,13 +839,13 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCApiCacheShare2) {
EXPECT_NE(iter1, nullptr);
// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter1->GetNextRow(&row);
ASSERT_OK(iter1->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
auto image = row["image"];
iter1->GetNextRow(&row);
ASSERT_OK(iter1->GetNextRow(&row));
}
EXPECT_EQ(i, 2);
// Manually terminate the pipeline
@@ -855,13 +855,13 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCApiCacheShare2) {
std::shared_ptr<Iterator> iter2 = ds2->CreateIterator();
EXPECT_NE(iter2, nullptr);
// Iterate the dataset and get each row
iter2->GetNextRow(&row);
ASSERT_OK(iter2->GetNextRow(&row));

i = 0;
while (row.size() != 0) {
i++;
auto image = row["image"];
iter2->GetNextRow(&row);
ASSERT_OK(iter2->GetNextRow(&row));
}
EXPECT_EQ(i, 2);

@@ -889,13 +889,13 @@ TEST_F(MindDataTestCacheOp, DISABLED_TestCApiCacheShareFailure1) {
EXPECT_NE(iter1, nullptr);
// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter1->GetNextRow(&row);
ASSERT_OK(iter1->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
auto image = row["image"];
iter1->GetNextRow(&row);
ASSERT_OK(iter1->GetNextRow(&row));
}
EXPECT_EQ(i, 2);
// Manually terminate the pipeline


+ 8
- 8
tests/ut/cpp/dataset/c_api_dataset_album_test.cc View File

@@ -40,14 +40,14 @@ TEST_F(MindDataTestPipeline, TestAlbumBasic) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 7);
@@ -95,14 +95,14 @@ TEST_F(MindDataTestPipeline, TestAlbumBasicWithPipeline) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 35);
@@ -155,7 +155,7 @@ TEST_F(MindDataTestPipeline, TestAlbumDecode) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -165,7 +165,7 @@ TEST_F(MindDataTestPipeline, TestAlbumDecode) {
MS_LOG(INFO) << "Tensor image shape size: " << shape.size();
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_GT(shape.size(), 1); // Verify decode=true took effect
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 7);
@@ -191,14 +191,14 @@ TEST_F(MindDataTestPipeline, TestAlbumNumSamplers) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 1);


+ 6
- 6
tests/ut/cpp/dataset/c_api_dataset_cifar_test.cc View File

@@ -41,7 +41,7 @@ TEST_F(MindDataTestPipeline, TestCifar10Dataset) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("image"), row.end());
EXPECT_NE(row.find("label"), row.end());
@@ -51,7 +51,7 @@ TEST_F(MindDataTestPipeline, TestCifar10Dataset) {
i++;
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -96,7 +96,7 @@ TEST_F(MindDataTestPipeline, TestCifar10DatasetWithPipeline) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("image"), row.end());
EXPECT_NE(row.find("label"), row.end());
@@ -106,7 +106,7 @@ TEST_F(MindDataTestPipeline, TestCifar10DatasetWithPipeline) {
i++;
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -179,7 +179,7 @@ TEST_F(MindDataTestPipeline, TestCifar100Dataset) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("image"), row.end());
EXPECT_NE(row.find("coarse_label"), row.end());
@@ -190,7 +190,7 @@ TEST_F(MindDataTestPipeline, TestCifar100Dataset) {
i++;
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);


+ 39
- 39
tests/ut/cpp/dataset/c_api_dataset_clue_test.cc View File

@@ -45,7 +45,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetAFQMC) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence1"), row.end());
std::vector<std::string> expected_result = {"蚂蚁借呗等额还款能否换成先息后本", "蚂蚁花呗说我违约了",
@@ -57,11 +57,11 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetAFQMC) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -78,7 +78,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetAFQMC) {
EXPECT_NE(ds, nullptr);
iter = ds->CreateIterator();
EXPECT_NE(iter, nullptr);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("sentence1"), row.end());
i = 0;
while (row.size() != 0) {
@@ -86,10 +86,10 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetAFQMC) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
iter->Stop();
@@ -101,7 +101,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetAFQMC) {
EXPECT_NE(ds, nullptr);
iter = ds->CreateIterator();
EXPECT_NE(iter, nullptr);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("sentence1"), row.end());
i = 0;
while (row.size() != 0) {
@@ -109,10 +109,10 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetAFQMC) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
iter->Stop();
@@ -135,7 +135,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetBasic) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence1"), row.end());
uint64_t i = 0;
@@ -143,7 +143,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetBasic) {
auto text = row["sentence1"];
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 2 samples
@@ -191,7 +191,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetBasicWithPipeline) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence1"), row.end());
uint64_t i = 0;
@@ -199,7 +199,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetBasicWithPipeline) {
auto text = row["sentence1"];
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 10 samples
@@ -241,7 +241,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetCMNLI) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence1"), row.end());
std::vector<std::string> expected_result = {"你应该给这件衣服定一个价格。", "我怎么知道他要说什么", "向左。"};
@@ -252,11 +252,11 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetCMNLI) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -284,7 +284,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetCSL) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("abst"), row.end());
std::vector<std::string> expected_result = {"这是一段长文本", "这是一段长文本", "这是一段长文本"};
@@ -295,11 +295,11 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetCSL) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -327,7 +327,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetDistribution) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence1"), row.end());
uint64_t i = 0;
@@ -335,7 +335,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetDistribution) {
auto text = row["sentence1"];
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 1 samples
@@ -427,7 +427,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetIFLYTEK) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence"), row.end());
std::vector<std::string> expected_result = {"第一个文本", "第二个文本", "第三个文本"};
@@ -438,11 +438,11 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetIFLYTEK) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -484,7 +484,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetShuffleFilesA) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence1"), row.end());
std::vector<std::string> expected_result = {"你有花呗吗",
@@ -500,13 +500,13 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetShuffleFilesA) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 3 + 3 = 6 samples
@@ -551,7 +551,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetShuffleFilesB) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence1"), row.end());
std::vector<std::string> expected_result = {"你有花呗吗",
@@ -567,12 +567,12 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetShuffleFilesB) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 3 + 3 = 6 samples
@@ -611,7 +611,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetShuffleGlobal) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence1"), row.end());
std::vector<std::string> expected_result = {"蚂蚁花呗说我违约了", "帮我看看本月花呗账单结清了没",
@@ -622,12 +622,12 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetShuffleGlobal) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 3 samples
@@ -658,7 +658,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetTNEWS) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("sentence"), row.end());
std::vector<std::string> expected_result = {"新闻1", "新闻2", "新闻3"};
@@ -669,11 +669,11 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetTNEWS) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -701,7 +701,7 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetWSC) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"小明呢,他在哪?", "小红刚刚看到小明,他在操场",
@@ -713,11 +713,11 @@ TEST_F(MindDataTestPipeline, TestCLUEDatasetWSC) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}



+ 12
- 12
tests/ut/cpp/dataset/c_api_dataset_coco_test.cc View File

@@ -41,7 +41,7 @@ TEST_F(MindDataTestPipeline, TestCocoDefault) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -51,7 +51,7 @@ TEST_F(MindDataTestPipeline, TestCocoDefault) {
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
MS_LOG(INFO) << "Tensor bbox shape: " << bbox.Shape();
MS_LOG(INFO) << "Tensor category_id shape: " << category_id.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -98,7 +98,7 @@ TEST_F(MindDataTestPipeline, TestCocoDefaultWithPipeline) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -108,7 +108,7 @@ TEST_F(MindDataTestPipeline, TestCocoDefaultWithPipeline) {
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
MS_LOG(INFO) << "Tensor bbox shape: " << bbox.Shape();
MS_LOG(INFO) << "Tensor category_id shape: " << category_id.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -149,7 +149,7 @@ TEST_F(MindDataTestPipeline, TestCocoDetection) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::string expect_file[] = {"000000391895", "000000318219", "000000554625",
"000000574769", "000000060623", "000000309022"};
@@ -182,7 +182,7 @@ TEST_F(MindDataTestPipeline, TestCocoDetection) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expect_categoryid));
EXPECT_MSTENSOR_EQ(category_id, expect_categoryid);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -239,7 +239,7 @@ TEST_F(MindDataTestPipeline, TestCocoKeypoint) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::string expect_file[] = {"000000391895", "000000318219"};
std::vector<std::vector<float>> expect_keypoint_vector = {
@@ -274,7 +274,7 @@ TEST_F(MindDataTestPipeline, TestCocoKeypoint) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expect_num_keypoints));
EXPECT_MSTENSOR_EQ(num_keypoints, expect_num_keypoints);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -301,7 +301,7 @@ TEST_F(MindDataTestPipeline, TestCocoPanoptic) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::string expect_file[] = {"000000391895", "000000574769"};
std::vector<std::vector<float>> expect_bbox_vector = {{472, 173, 36, 48, 340, 22, 154, 301, 486, 183, 30, 35},
@@ -346,7 +346,7 @@ TEST_F(MindDataTestPipeline, TestCocoPanoptic) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expect_area));
EXPECT_MSTENSOR_EQ(area, expect_area);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -396,7 +396,7 @@ TEST_F(MindDataTestPipeline, TestCocoStuff) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::string expect_file[] = {"000000391895", "000000318219", "000000554625",
"000000574769", "000000060623", "000000309022"};
@@ -424,7 +424,7 @@ TEST_F(MindDataTestPipeline, TestCocoStuff) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expect_segmentation));
EXPECT_MSTENSOR_EQ(segmentation, expect_segmentation);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}



+ 6
- 6
tests/ut/cpp/dataset/c_api_dataset_config_test.cc View File

@@ -129,7 +129,7 @@ TEST_F(MindDataTestPipeline, TestShuffleWithSeed) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("text"), row.end());

std::vector<std::string> expected_result = {"Good luck to everyone.", "Be happy every day.", "This is a text file."};
@@ -141,14 +141,14 @@ TEST_F(MindDataTestPipeline, TestShuffleWithSeed) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 3 samples
@@ -194,7 +194,7 @@ TEST_F(MindDataTestPipeline, TestCallShuffleTwice) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("text"), row.end());

std::vector<std::string> first_copy;
@@ -206,7 +206,7 @@ TEST_F(MindDataTestPipeline, TestCallShuffleTwice) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);

@@ -218,7 +218,7 @@ TEST_F(MindDataTestPipeline, TestCallShuffleTwice) {
}

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 6 samples


+ 29
- 29
tests/ut/cpp/dataset/c_api_dataset_csv_test.cc View File

@@ -42,7 +42,7 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetBasic) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("col1"), row.end());
std::vector<std::vector<std::string>> expected_result = {
{"1", "2", "3", "4"},
@@ -57,11 +57,11 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetBasic) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i][j].c_str());
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -109,7 +109,7 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetMultiFiles) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("col1"), row.end());
std::vector<std::vector<std::string>> expected_result = {
{"17", "18", "19", "20"}, {"1", "2", "3", "4"}, {"5", "6", "7", "8"},
@@ -123,11 +123,11 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetMultiFiles) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i][j].c_str());
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -158,7 +158,7 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetNumSamples) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("col1"), row.end());
std::vector<std::vector<std::string>> expected_result = {{"1", "2", "3", "4"}, {"5", "6", "7", "8"}};

@@ -169,11 +169,11 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetNumSamples) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i][j].c_str());
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -200,7 +200,7 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetDistribution) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("col1"), row.end());
std::vector<std::vector<std::string>> expected_result = {{"1", "2", "3", "4"}, {"5", "6", "7", "8"}};

@@ -211,11 +211,11 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetDistribution) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i][j].c_str());
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -248,7 +248,7 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetType) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
std::vector<std::vector<std::shared_ptr<CsvBase>>> expected = {
{
std::make_shared<CsvRecord<std::string>>(CsvType::STRING, ""),
@@ -273,20 +273,20 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetType) {
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
if (colum_type[j]->type == CsvType::INT) {
int val;
de_text->GetItemAt(&val, {});
ASSERT_OK(de_text->GetItemAt(&val, {}));
EXPECT_EQ(val, std::dynamic_pointer_cast<CsvRecord<int>>(expected[i][j])->value);
} else if (colum_type[j]->type == CsvType::FLOAT) {
float val;
de_text->GetItemAt(&val, {});
ASSERT_OK(de_text->GetItemAt(&val, {}));
EXPECT_EQ(val, std::dynamic_pointer_cast<CsvRecord<float>>(expected[i][j])->value);
} else if (colum_type[j]->type == CsvType::STRING) {
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), std::dynamic_pointer_cast<CsvRecord<std::string>>(expected[i][j])->value.c_str());
}
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -312,7 +312,7 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetHeader) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("col1"), row.end());
std::vector<std::vector<std::string>> expected_result = {
{"a", "b", "c", "d"},
@@ -326,11 +326,11 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetHeader) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i][j].c_str());
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -421,7 +421,7 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetShuffleFilesA) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("col1"), row.end());
std::vector<std::vector<std::string>> expected_result = {
{"13", "14", "15", "16"}, {"1", "2", "3", "4"}, {"17", "18", "19", "20"},
@@ -435,11 +435,11 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetShuffleFilesA) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i][j].c_str());
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -478,7 +478,7 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetShuffleFilesB) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("col1"), row.end());
std::vector<std::vector<std::string>> expected_result = {
{"13", "14", "15", "16"}, {"1", "2", "3", "4"}, {"17", "18", "19", "20"},
@@ -492,12 +492,12 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetShuffleFilesB) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
EXPECT_STREQ(ss.c_str(), expected_result[i][j].c_str());
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -536,7 +536,7 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetShuffleGlobal) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_NE(row.find("col1"), row.end());
std::vector<std::vector<std::string>> expected_result = {
{"5", "6", "7", "8"}, {"9", "10", "11", "12"}, {"1", "2", "3", "4"}};
@@ -548,11 +548,11 @@ TEST_F(MindDataTestPipeline, TestCSVDatasetShuffleGlobal) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
EXPECT_STREQ(ss.c_str(), expected_result[i][j].c_str());
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}



+ 10
- 10
tests/ut/cpp/dataset/c_api_dataset_iterator_test.cc View File

@@ -39,7 +39,7 @@ TEST_F(MindDataTestPipeline, TestIteratorEmptyColumn) {

// Iterate the dataset and get each row
std::vector<mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
std::vector<int64_t> expect_image = {32, 32, 3};
std::vector<int64_t> expect_label = {};

@@ -49,7 +49,7 @@ TEST_F(MindDataTestPipeline, TestIteratorEmptyColumn) {
EXPECT_EQ(expect_image, row[0].Shape());
EXPECT_EQ(expect_label, row[1].Shape());

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -79,7 +79,7 @@ TEST_F(MindDataTestPipeline, TestIteratorOneColumn) {

// Iterate the dataset and get each row
std::vector<mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
std::vector<int64_t> expect_image = {2, 28, 28, 1};

uint64_t i = 0;
@@ -88,7 +88,7 @@ TEST_F(MindDataTestPipeline, TestIteratorOneColumn) {
MS_LOG(INFO) << "image shape:" << v.Shape();
EXPECT_EQ(expect_image, v.Shape());
}
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -117,7 +117,7 @@ TEST_F(MindDataTestPipeline, TestIteratorReOrder) {

// Iterate the dataset and get each row
std::vector<mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
std::vector<int64_t> expect_image = {32, 32, 3};
std::vector<int64_t> expect_label = {};

@@ -127,7 +127,7 @@ TEST_F(MindDataTestPipeline, TestIteratorReOrder) {
MS_LOG(INFO) << "row[0]:" << row[0].Shape() << ", row[1]:" << row[1].Shape();
EXPECT_EQ(expect_label, row[0].Shape());
EXPECT_EQ(expect_image, row[1].Shape());
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -158,7 +158,7 @@ TEST_F(MindDataTestPipeline, TestIteratorTwoColumns) {

// Iterate the dataset and get each row
std::vector<mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
std::vector<std::vector<int64_t>> expect = {{173673}, {1, 4}, {173673}, {1, 4},
{147025}, {1, 4}, {211653}, {1, 4}};

@@ -169,7 +169,7 @@ TEST_F(MindDataTestPipeline, TestIteratorTwoColumns) {
EXPECT_EQ(2, row.size());
EXPECT_EQ(expect[j++], row[0].Shape());
EXPECT_EQ(expect[j++], row[1].Shape());
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
j = (j == expect.size()) ? 0 : j;
}
@@ -209,10 +209,10 @@ TEST_F(MindDataTestPipeline, TestIteratorNumEpoch) {
int32_t inner_row_cnt = 0;
int32_t total_row_cnt = 0;
for (int32_t i = 0; i < num_epochs; i++) {
ASSERT_TRUE(iter->GetNextRow(&row));
ASSERT_OK(iter->GetNextRow(&row));
inner_row_cnt = 0;
while (row.size() != 0) {
ASSERT_TRUE(iter->GetNextRow(&row));
ASSERT_OK(iter->GetNextRow(&row));
++inner_row_cnt;
++total_row_cnt;
}


+ 13
- 13
tests/ut/cpp/dataset/c_api_dataset_manifest_test.cc View File

@@ -38,14 +38,14 @@ TEST_F(MindDataTestPipeline, TestManifestBasic) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -90,14 +90,14 @@ TEST_F(MindDataTestPipeline, TestManifestBasicWithPipeline) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -157,7 +157,7 @@ TEST_F(MindDataTestPipeline, TestManifestDecode) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -167,7 +167,7 @@ TEST_F(MindDataTestPipeline, TestManifestDecode) {
MS_LOG(INFO) << "Tensor image shape size: " << shape.size();
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_GT(shape.size(), 1); // Verify decode=true took effect
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -191,14 +191,14 @@ TEST_F(MindDataTestPipeline, TestManifestEval) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 1);
@@ -235,7 +235,7 @@ TEST_F(MindDataTestPipeline, TestManifestClassIndex) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
int32_t label_idx = 0;
@@ -247,12 +247,12 @@ TEST_F(MindDataTestPipeline, TestManifestClassIndex) {

std::shared_ptr<Tensor> de_label;
ASSERT_OK(Tensor::CreateFromMSTensor(label, &de_label));
de_label->GetItemAt<int32_t>(&label_idx, {});
ASSERT_OK(de_label->GetItemAt<int32_t>(&label_idx, {}));
MS_LOG(INFO) << "Tensor label value: " << label_idx;
auto label_it = std::find(expected_label.begin(), expected_label.end(), label_idx);
EXPECT_NE(label_it, expected_label.end());

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -276,14 +276,14 @@ TEST_F(MindDataTestPipeline, TestManifestNumSamplers) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 1);


+ 18
- 18
tests/ut/cpp/dataset/c_api_dataset_minddata_test.cc View File

@@ -41,7 +41,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -49,7 +49,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess1) {
auto image = row["file_name"];
TEST_MS_LOG_MSTENSOR(INFO, "Tensor image file name: ", image);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Each *.mindrecord file has 5 rows, so there are 20 rows in total(imagenet.mindrecord0 ~ imagenet.mindrecord3)
@@ -91,7 +91,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -99,7 +99,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess2) {
auto image = row["file_name"];
TEST_MS_LOG_MSTENSOR(INFO, "Tensor image file name: ", image);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Only records in imagenet.mindrecord0 are read
@@ -127,7 +127,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess3) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -135,7 +135,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess3) {
auto image = row["file_name"];
TEST_MS_LOG_MSTENSOR(INFO, "Tensor image file name: ", image);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Only records in imagenet.mindrecord0 and imagenet.mindrecord1 are read
@@ -162,14 +162,14 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess4) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
auto label = row["label"];
TEST_MS_LOG_MSTENSOR(INFO, "Tensor label: ", label);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Shard file "mindrecord0/mindrecord1/mindrecord2/mindrecord3" have same dataset info,
@@ -197,7 +197,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess5) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::shared_ptr<Tensor> de_expect_item;
ASSERT_OK(Tensor::CreateScalar((int64_t)0, &de_expect_item));
@@ -210,7 +210,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess5) {

EXPECT_MSTENSOR_EQ(label, expect_item);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// SequentialSampler will return 3 samples
@@ -263,14 +263,14 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess6) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t j = 0;
while (row.size() != 0) {
j++;
auto label = row["label"];
TEST_MS_LOG_MSTENSOR(INFO, "Tensor label: ", label);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}
EXPECT_EQ(j, expected_samples[i]);

@@ -306,7 +306,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess7) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::shared_ptr<Tensor> de_expect_item;
ASSERT_OK(Tensor::CreateScalar((int64_t)999, &de_expect_item));
@@ -322,7 +322,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess7) {

EXPECT_MSTENSOR_EQ(label, expect_item);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -377,7 +377,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess8) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::shared_ptr<Tensor> de_expect_item;
ASSERT_OK(Tensor::CreateScalar((int64_t)999, &de_expect_item));
@@ -393,7 +393,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess8) {

EXPECT_MSTENSOR_EQ(label, expect_item);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 8);
@@ -452,7 +452,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess9) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::shared_ptr<Tensor> de_expect_item;
ASSERT_OK(Tensor::CreateScalar((int64_t)999, &de_expect_item));
@@ -466,7 +466,7 @@ TEST_F(MindDataTestPipeline, TestMindDataSuccess9) {

EXPECT_MSTENSOR_EQ(label, expect_item);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);


+ 55
- 56
tests/ut/cpp/dataset/c_api_dataset_ops_test.cc View File

@@ -31,9 +31,8 @@ TensorRow VecToRow(const MSTensorVec &v) {
TensorRow row;
for (const mindspore::MSTensor &t : v) {
std::shared_ptr<Tensor> rt;
Status rc =
Tensor::CreateFromMemory(TensorShape(t.Shape()), MSTypeToDEType(static_cast<mindspore::TypeId>(t.DataType())),
(const uchar *)(t.Data().get()), t.DataSize(), &rt);
(void)Tensor::CreateFromMemory(TensorShape(t.Shape()), MSTypeToDEType(static_cast<mindspore::TypeId>(t.DataType())),
(const uchar *)(t.Data().get()), t.DataSize(), &rt);
row.emplace_back(rt);
}
return row;
@@ -49,9 +48,9 @@ MSTensorVec RowToVec(const TensorRow &v) {
MSTensorVec BucketBatchTestFunction(MSTensorVec input) {
mindspore::dataset::TensorRow output;
std::shared_ptr<Tensor> out;
Tensor::CreateEmpty(mindspore::dataset::TensorShape({1}),
mindspore::dataset::DataType(mindspore::dataset::DataType::Type::DE_INT32), &out);
out->SetItemAt({0}, 2);
(void)Tensor::CreateEmpty(mindspore::dataset::TensorShape({1}),
mindspore::dataset::DataType(mindspore::dataset::DataType::Type::DE_INT32), &out);
(void)out->SetItemAt({0}, 2);
output.push_back(out);
return RowToVec(output);
}
@@ -60,15 +59,15 @@ MSTensorVec Predicate1(MSTensorVec in) {
// Return true if input is equal to 3
uint64_t input_value;
TensorRow input = VecToRow(in);
input.at(0)->GetItemAt(&input_value, {0});
(void)input.at(0)->GetItemAt(&input_value, {0});
bool result = (input_value == 3);

// Convert from boolean to TensorRow
TensorRow output;
std::shared_ptr<Tensor> out;
Tensor::CreateEmpty(mindspore::dataset::TensorShape({}),
mindspore::dataset::DataType(mindspore::dataset::DataType::Type::DE_BOOL), &out);
out->SetItemAt({}, result);
(void)Tensor::CreateEmpty(mindspore::dataset::TensorShape({}),
mindspore::dataset::DataType(mindspore::dataset::DataType::Type::DE_BOOL), &out);
(void)out->SetItemAt({}, result);
output.push_back(out);

return RowToVec(output);
@@ -79,15 +78,15 @@ MSTensorVec Predicate2(MSTensorVec in) {
// The index of label in input is 1
uint64_t input_value;
TensorRow input = VecToRow(in);
input.at(1)->GetItemAt(&input_value, {0});
(void)input.at(1)->GetItemAt(&input_value, {0});
bool result = (input_value > 1);

// Convert from boolean to TensorRow
TensorRow output;
std::shared_ptr<Tensor> out;
Tensor::CreateEmpty(mindspore::dataset::TensorShape({}),
mindspore::dataset::DataType(mindspore::dataset::DataType::Type::DE_BOOL), &out);
out->SetItemAt({}, result);
(void)Tensor::CreateEmpty(mindspore::dataset::TensorShape({}),
mindspore::dataset::DataType(mindspore::dataset::DataType::Type::DE_BOOL), &out);
(void)out->SetItemAt({}, result);
output.push_back(out);

return RowToVec(output);
@@ -118,14 +117,14 @@ TEST_F(MindDataTestPipeline, TestBatchAndRepeat) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -154,14 +153,14 @@ TEST_F(MindDataTestPipeline, TestBucketBatchByLengthSuccess1) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}
// 2 batches of size 5
EXPECT_EQ(i, 2);
@@ -504,13 +503,13 @@ TEST_F(MindDataTestPipeline, TestConcatSuccess) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 19);
@@ -584,13 +583,13 @@ TEST_F(MindDataTestPipeline, TestConcatSuccess2) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 19);
@@ -745,12 +744,12 @@ TEST_F(MindDataTestPipeline, TestFilterFail2) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
EXPECT_ERROR(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
EXPECT_ERROR(iter->GetNextRow(&row));
}

// Expect failure: column check fail and return nothing
@@ -805,14 +804,14 @@ TEST_F(MindDataTestPipeline, TestImageFolderBatchAndRepeat) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -861,12 +860,12 @@ TEST_F(MindDataTestPipeline, TestDistributedGetDatasetSize1) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// The value of i should be equal to the result of get dataset size
@@ -892,12 +891,12 @@ TEST_F(MindDataTestPipeline, TestDistributedGetDatasetSize2) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// The value of i should be equal to the result of get dataset size
@@ -942,14 +941,14 @@ TEST_F(MindDataTestPipeline, TestProjectMap) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -1075,7 +1074,7 @@ TEST_F(MindDataTestPipeline, TestProjectMapAutoInjection) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// 'label' is dropped during the project op
EXPECT_EQ(row.find("label"), row.end());
@@ -1088,7 +1087,7 @@ TEST_F(MindDataTestPipeline, TestProjectMapAutoInjection) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0], 30);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -1197,7 +1196,7 @@ TEST_F(MindDataTestPipeline, TestRenameSuccess) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
EXPECT_NE(row.find("col1"), row.end());
@@ -1209,7 +1208,7 @@ TEST_F(MindDataTestPipeline, TestRenameSuccess) {
i++;
auto image = row["col1"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -1243,7 +1242,7 @@ TEST_F(MindDataTestPipeline, TestRepeatDefault) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
uint64_t i = 0;
while (row.size() != 0) {
// manually stop
@@ -1253,7 +1252,7 @@ TEST_F(MindDataTestPipeline, TestRepeatDefault) {
i++;
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 100);
@@ -1286,13 +1285,13 @@ TEST_F(MindDataTestPipeline, TestRepeatOne) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -1369,14 +1368,14 @@ TEST_F(MindDataTestPipeline, TestShuffleDataset) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -1405,14 +1404,14 @@ TEST_F(MindDataTestPipeline, TestSkipDataset) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}
MS_LOG(INFO) << "Number of rows: " << i;

@@ -1450,14 +1449,14 @@ TEST_F(MindDataTestPipeline, TestSkipTakeRepeat) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}
MS_LOG(INFO) << "Number of rows: " << i;

@@ -1522,14 +1521,14 @@ TEST_F(MindDataTestPipeline, TestTakeDatasetDefault) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}
MS_LOG(INFO) << "Number of rows: " << i;

@@ -1603,14 +1602,14 @@ TEST_F(MindDataTestPipeline, TestTakeDatasetNormal) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}
MS_LOG(INFO) << "Number of rows: " << i;

@@ -1657,14 +1656,14 @@ TEST_F(MindDataTestPipeline, TestTensorOpsAndMap) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 40);
@@ -1769,7 +1768,7 @@ TEST_F(MindDataTestPipeline, TestZipSuccess) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check zipped column names
EXPECT_EQ(row.size(), 4);
@@ -1783,7 +1782,7 @@ TEST_F(MindDataTestPipeline, TestZipSuccess) {
i++;
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -1861,7 +1860,7 @@ TEST_F(MindDataTestPipeline, TestZipSuccess2) {

// iterate over the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check zipped column names
EXPECT_EQ(row.size(), 4);
@@ -1875,7 +1874,7 @@ TEST_F(MindDataTestPipeline, TestZipSuccess2) {
i++;
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 9);


+ 30
- 30
tests/ut/cpp/dataset/c_api_dataset_randomdata_test.cc View File

@@ -30,8 +30,8 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic1) {

// Create a RandomDataset
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2});
schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1});
ASSERT_OK(schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2}));
ASSERT_OK(schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1}));
std::shared_ptr<Dataset> ds = RandomData(50, schema);
EXPECT_NE(ds, nullptr);

@@ -49,7 +49,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if RandomData() read correct columns
uint64_t i = 0;
@@ -59,7 +59,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic1) {
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
MS_LOG(INFO) << "Tensor label shape: " << label.Shape();

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -74,8 +74,8 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasicWithPipeline) {

// Create two RandomDataset
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2});
schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1});
ASSERT_OK(schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2}));
ASSERT_OK(schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1}));
std::shared_ptr<Dataset> ds1 = RandomData(50, schema);
std::shared_ptr<Dataset> ds2 = RandomData(50, schema);
EXPECT_NE(ds1, nullptr);
@@ -107,7 +107,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasicWithPipeline) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if RandomData() read correct columns
uint64_t i = 0;
@@ -117,7 +117,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasicWithPipeline) {
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
MS_LOG(INFO) << "Tensor label shape: " << label.Shape();

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -132,8 +132,8 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetGetters) {

// Create a RandomDataset
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2});
schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1});
ASSERT_OK(schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2}));
ASSERT_OK(schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1}));
std::shared_ptr<Dataset> ds = RandomData(50, schema);
EXPECT_NE(ds, nullptr);

@@ -163,14 +163,14 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if RandomData() read correct columns
uint64_t i = 0;
while (row.size() != 0) {
// If no schema specified, RandomData will generate random columns
// So we don't check columns here
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -203,7 +203,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic3) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<int64_t> expect_num = {1};
std::vector<int64_t> expect_1d = {2};
@@ -252,7 +252,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic3) {
ASSERT_EQ(col_3d.DataType(), mindspore::DataType::kNumberTypeInt64);
ASSERT_EQ(col_binary.DataType(), mindspore::DataType::kNumberTypeUInt8);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -285,7 +285,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic4) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<int64_t> expect_num = {1};
std::vector<int64_t> expect_1d = {2};
@@ -334,7 +334,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic4) {
ASSERT_EQ(col_3d.DataType(), mindspore::DataType::kNumberTypeInt64);
ASSERT_EQ(col_binary.DataType(), mindspore::DataType::kNumberTypeUInt8);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -367,7 +367,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic5) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<int64_t> expect_num = {1};
std::vector<int64_t> expect_1d = {2};
@@ -396,7 +396,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic5) {
ASSERT_EQ(col_sint64.DataType(), mindspore::DataType::kNumberTypeInt64);
ASSERT_EQ(col_1d.DataType(), mindspore::DataType::kNumberTypeInt64);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -425,12 +425,12 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic6) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if RandomData() read correct columns
uint64_t i = 0;
while (row.size() != 0) {
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -459,12 +459,12 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetBasic7) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if RandomData() read correct columns
uint64_t i = 0;
while (row.size() != 0) {
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -482,7 +482,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetUInt8) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(963);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeUInt8, {4});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeUInt8, {4}));
std::shared_ptr<Dataset> ds = RandomData(3, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(3);
@@ -495,14 +495,14 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetUInt8) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
auto ind = row["col1"];
TEST_MS_LOG_MSTENSOR(INFO, "ind: ", ind);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -520,7 +520,7 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetFloat) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(369);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeFloat16, {2, 3});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeFloat16, {2, 3}));
std::shared_ptr<Dataset> ds = RandomData(4, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -533,14 +533,14 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetFloat) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
auto ind = row["col1"];
TEST_MS_LOG_MSTENSOR(INFO, "ind: ", ind);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -556,8 +556,8 @@ TEST_F(MindDataTestPipeline, TestRandomDatasetDuplicateColumnName) {

// Create a RandomDataset
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2});
schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1});
ASSERT_OK(schema->add_column("image", mindspore::DataType::kNumberTypeUInt8, {2}));
ASSERT_OK(schema->add_column("label", mindspore::DataType::kNumberTypeUInt8, {1}));
std::shared_ptr<Dataset> ds = RandomData(50, schema, {"image", "image"});
// Expect failure: duplicate column names
EXPECT_EQ(ds->CreateIterator(), nullptr);


+ 4
- 4
tests/ut/cpp/dataset/c_api_dataset_save.cc View File

@@ -41,7 +41,7 @@ TEST_F(MindDataTestPipeline, TestSaveCifar10AndLoad) {
// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
std::vector<mindspore::MSTensor> original_data;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Save original data for comparison
uint64_t i = 0;
@@ -50,7 +50,7 @@ TEST_F(MindDataTestPipeline, TestSaveCifar10AndLoad) {
original_data.push_back(label);
TEST_MS_LOG_MSTENSOR(INFO, "Tensor label: ", label);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -90,7 +90,7 @@ TEST_F(MindDataTestPipeline, TestSaveCifar10AndLoad) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row_minddata;
iter_minddata->GetNextRow(&row_minddata);
ASSERT_OK(iter_minddata->GetNextRow(&row_minddata));

// Check column name for each row
EXPECT_NE(row_minddata.find("image"), row_minddata.end());
@@ -103,7 +103,7 @@ TEST_F(MindDataTestPipeline, TestSaveCifar10AndLoad) {
EXPECT_MSTENSOR_EQ(original_data[j], label);
TEST_MS_LOG_MSTENSOR(INFO, "Tensor label: ", label);

iter_minddata->GetNextRow(&row_minddata);
ASSERT_OK(iter_minddata->GetNextRow(&row_minddata));
j++;
}



+ 32
- 32
tests/ut/cpp/dataset/c_api_dataset_textfile_test.cc View File

@@ -51,7 +51,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetBasic) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"Be happy every day.", "This is a text file."};
@@ -63,14 +63,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetBasic) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 2 samples
@@ -124,7 +124,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetBasicWithPipeline) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"Be happy every day.", "This is a text file."};
@@ -134,7 +134,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetBasicWithPipeline) {
auto text = row["text"];
MS_LOG(INFO) << "Tensor text shape: " << text.Shape();
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 10 samples
@@ -310,7 +310,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFalse1A) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"This is a text file.", "Be happy every day.", "Good luck to everyone.",
@@ -323,14 +323,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFalse1A) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 2 + 3 = 5 samples
@@ -371,7 +371,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFalse1B) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"This is a text file.", "Be happy every day.", "Good luck to everyone.",
@@ -384,14 +384,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFalse1B) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 2 + 3 = 5 samples
@@ -432,7 +432,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFalse4Shard) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"This is a text file.", "Be happy every day.", "Good luck to everyone."};
@@ -444,14 +444,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFalse4Shard) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 3 samples for this shard
@@ -493,7 +493,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFiles1A) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {
@@ -507,14 +507,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFiles1A) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 2 + 3 = 5 samples
@@ -556,7 +556,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFiles1B) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {
@@ -570,14 +570,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFiles1B) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 2 + 3 = 5 samples
@@ -619,7 +619,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFiles4) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"This is a text file.", "Another file.", "Be happy every day.",
@@ -632,14 +632,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleFiles4) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 2 + 3 = 5 samples
@@ -678,7 +678,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleGlobal1A) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"Good luck to everyone.", "This is a text file.", "Be happy every day."};
@@ -690,14 +690,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleGlobal1A) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 3 samples
@@ -738,7 +738,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleGlobal1B) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"Another file.", "Good luck to everyone.", "This is a text file.",
@@ -751,14 +751,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleGlobal1B) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 2 + 3 = 5 samples
@@ -799,7 +799,7 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleGlobal4) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

EXPECT_NE(row.find("text"), row.end());
std::vector<std::string> expected_result = {"Another file.", "Good luck to everyone.", "End of file.",
@@ -812,14 +812,14 @@ TEST_F(MindDataTestPipeline, TestTextFileDatasetShuffleGlobal4) {
std::shared_ptr<Tensor> de_text;
ASSERT_OK(Tensor::CreateFromMSTensor(text, &de_text));
std::string_view sv;
de_text->GetItemAt(&sv, {});
ASSERT_OK(de_text->GetItemAt(&sv, {}));
std::string ss(sv);
MS_LOG(INFO) << "Text length: " << ss.length() << ", Text: " << ss.substr(0, 50);
// Compare against expected result
EXPECT_STREQ(ss.c_str(), expected_result[i].c_str());

i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Expect 2 + 3 = 5 samples


+ 28
- 28
tests/ut/cpp/dataset/c_api_dataset_tfrecord_test.cc View File

@@ -63,7 +63,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetBasic) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check column
EXPECT_EQ(row.size(), 1);
@@ -74,7 +74,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetBasic) {
auto image = row["image"];

MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -143,9 +143,9 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetShuffle) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row1;
iter1->GetNextRow(&row1);
ASSERT_OK(iter1->GetNextRow(&row1));
std::unordered_map<std::string, mindspore::MSTensor> row2;
iter2->GetNextRow(&row2);
ASSERT_OK(iter2->GetNextRow(&row2));

uint64_t i = 0;
int64_t value1 = 0;
@@ -154,17 +154,17 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetShuffle) {
auto scalars1 = row1["scalars"];
std::shared_ptr<Tensor> de_scalars1;
ASSERT_OK(Tensor::CreateFromMSTensor(scalars1, &de_scalars1));
de_scalars1->GetItemAt(&value1, {0});
ASSERT_OK(de_scalars1->GetItemAt(&value1, {0}));

auto scalars2 = row2["scalars"];
std::shared_ptr<Tensor> de_scalars2;
ASSERT_OK(Tensor::CreateFromMSTensor(scalars2, &de_scalars2));
de_scalars2->GetItemAt(&value2, {0});
ASSERT_OK(de_scalars2->GetItemAt(&value2, {0}));

EXPECT_EQ(value1, value2);

iter1->GetNextRow(&row1);
iter2->GetNextRow(&row2);
ASSERT_OK(iter1->GetNextRow(&row1));
ASSERT_OK(iter2->GetNextRow(&row2));
i++;
}
EXPECT_EQ(i, 10);
@@ -198,7 +198,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetShuffle2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<int> expect = {9, 3, 4, 7, 2, 1, 6, 8, 10, 5};
std::vector<int> actual = {};
@@ -208,10 +208,10 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetShuffle2) {
auto scalars = row["scalars"];
std::shared_ptr<Tensor> de_scalars;
ASSERT_OK(Tensor::CreateFromMSTensor(scalars, &de_scalars));
de_scalars->GetItemAt(&value, {0});
ASSERT_OK(de_scalars->GetItemAt(&value, {0}));
actual.push_back(value);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
ASSERT_EQ(actual, expect);
@@ -241,7 +241,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetSchemaPath) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check column
EXPECT_EQ(row.size(), 8);
@@ -257,7 +257,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetSchemaPath) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 9);
@@ -272,9 +272,9 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetSchemaObj) {
// Create a TFRecord Dataset
std::string file_path = datasets_root_path_ + "/testTFTestAllTypes/test.data";
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col_sint16", "int16", {1});
schema->add_column("col_float", "float32", {1});
schema->add_column("col_2d", "int64", {2, 2});
ASSERT_OK(schema->add_column("col_sint16", "int16", {1}));
ASSERT_OK(schema->add_column("col_float", "float32", {1}));
ASSERT_OK(schema->add_column("col_2d", "int64", {2, 2}));
std::shared_ptr<Dataset> ds = TFRecord({file_path}, schema);
EXPECT_NE(ds, nullptr);

@@ -285,7 +285,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetSchemaObj) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check column
EXPECT_EQ(row.size(), 3);
@@ -317,7 +317,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetSchemaObj) {
ASSERT_EQ(col_float.DataType(), mindspore::DataType::kNumberTypeFloat32);
ASSERT_EQ(col_2d.DataType(), mindspore::DataType::kNumberTypeInt64);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -343,7 +343,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetNoSchema) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check column
EXPECT_EQ(row.size(), 2);
@@ -357,7 +357,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetNoSchema) {

MS_LOG(INFO) << "Shape of column [image]:" << image.Shape();
MS_LOG(INFO) << "Shape of column [label]:" << label.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -383,7 +383,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetColName) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check column
EXPECT_EQ(row.size(), 1);
@@ -392,7 +392,7 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetColName) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);
@@ -423,20 +423,20 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetShard) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row1;
iter1->GetNextRow(&row1);
ASSERT_OK(iter1->GetNextRow(&row1));
std::unordered_map<std::string, mindspore::MSTensor> row2;
iter2->GetNextRow(&row2);
ASSERT_OK(iter2->GetNextRow(&row2));

uint64_t i = 0;
uint64_t j = 0;
while (row1.size() != 0) {
i++;
iter1->GetNextRow(&row1);
ASSERT_OK(iter1->GetNextRow(&row1));
}

while (row2.size() != 0) {
j++;
iter2->GetNextRow(&row2);
ASSERT_OK(iter2->GetNextRow(&row2));
}

EXPECT_EQ(i, 5);
@@ -501,8 +501,8 @@ TEST_F(MindDataTestPipeline, TestTFRecordDatasetExeception2) {
TEST_F(MindDataTestPipeline, TestIncorrectTFSchemaObject) {
std::string path = datasets_root_path_ + "/test_tf_file_3_images2/train-0000-of-0001.data";
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("image", "uint8", {1});
schema->add_column("label", "int64", {1});
ASSERT_OK(schema->add_column("image", "uint8", {1}));
ASSERT_OK(schema->add_column("label", "int64", {1}));
std::shared_ptr<Dataset> ds = TFRecord({path}, schema);
EXPECT_NE(ds, nullptr);
auto itr = ds->CreateIterator();


+ 6
- 6
tests/ut/cpp/dataset/c_api_dataset_voc_test.cc View File

@@ -46,7 +46,7 @@ TEST_F(MindDataTestPipeline, TestVOCClassIndex) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if VOC() read correct labels
// When we provide class_index, label of ["car","cat","train"] become [0,1,9]
@@ -65,7 +65,7 @@ TEST_F(MindDataTestPipeline, TestVOCClassIndex) {
mindspore::MSTensor expect_label = mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expect_label));
EXPECT_MSTENSOR_EQ(label, expect_label);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -133,7 +133,7 @@ TEST_F(MindDataTestPipeline, TestVOCDetection) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if VOC() read correct images/labels
std::string expect_file[] = {"15", "32", "33", "39"};
@@ -156,7 +156,7 @@ TEST_F(MindDataTestPipeline, TestVOCDetection) {
mindspore::MSTensor expect_label = mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expect_label));
EXPECT_MSTENSOR_EQ(label, expect_label);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -208,7 +208,7 @@ TEST_F(MindDataTestPipeline, TestVOCSegmentation) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if VOC() read correct images/targets
std::string expect_file[] = {"32", "33", "39", "32", "33", "39"};
@@ -225,7 +225,7 @@ TEST_F(MindDataTestPipeline, TestVOCSegmentation) {
mindspore::MSTensor expect_target = ReadFileToTensor(folder_path + "/SegmentationClass/" + expect_file[i] + ".png");
EXPECT_MSTENSOR_EQ(target, expect_target);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}



+ 5
- 5
tests/ut/cpp/dataset/c_api_datasets_test.cc View File

@@ -42,7 +42,7 @@ TEST_F(MindDataTestPipeline, TestCelebADataset) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if CelebA() read correct images/attr
std::string expect_file[] = {"1.JPEG", "2.jpg"};
@@ -65,7 +65,7 @@ TEST_F(MindDataTestPipeline, TestCelebADataset) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expect_attr));
EXPECT_MSTENSOR_EQ(attr, expect_attr);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -90,7 +90,7 @@ TEST_F(MindDataTestPipeline, TestCelebADefault) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check if CelebA() read correct images/attr
uint64_t i = 0;
@@ -100,7 +100,7 @@ TEST_F(MindDataTestPipeline, TestCelebADefault) {
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
MS_LOG(INFO) << "Tensor attr shape: " << attr.Shape();

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -220,8 +220,8 @@ TEST_F(MindDataTestPipeline, TestImageFolderFailWithWrongExtensionFail) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
// Expect no data: cannot find files with specified extension
EXPECT_ERROR(iter->GetNextRow(&row));
EXPECT_EQ(row.size(), 0);

// Manually terminate the pipeline


+ 16
- 16
tests/ut/cpp/dataset/c_api_epoch_ctrl_test.cc View File

@@ -47,17 +47,17 @@ TEST_F(MindDataTestEpochCtrl, TestAutoInjectEpoch) {

for (int epoch = 0; epoch < num_epochs; epoch++) {
// Iterate the dataset and get each row
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

while (row.size() != 0) {
auto label = row["label"];
std::shared_ptr<Tensor> de_label;
int64_t label_value;
ASSERT_OK(Tensor::CreateFromMSTensor(label, &de_label));
de_label->GetItemAt(&label_value, {});
ASSERT_OK(de_label->GetItemAt(&label_value, {}));
EXPECT_TRUE(img_class[(i % sampler_size) / class_size] == label_value);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
}
@@ -65,7 +65,7 @@ TEST_F(MindDataTestEpochCtrl, TestAutoInjectEpoch) {
EXPECT_EQ(i, sampler_size * num_epochs);

// Try to fetch data beyond the specified number of epochs.
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_EQ(row.size(), 2);

// Manually terminate the pipeline
@@ -94,16 +94,16 @@ TEST_F(MindDataTestEpochCtrl, TestEpoch) {
std::unordered_map<std::string, mindspore::MSTensor> row;

for (int epoch = 0; epoch < num_epochs; epoch++) {
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
while (row.size() != 0) {
auto label = row["label"];
std::shared_ptr<Tensor> de_label;
int64_t label_value;
ASSERT_OK(Tensor::CreateFromMSTensor(label, &de_label));
de_label->GetItemAt(&label_value, {});
ASSERT_OK(de_label->GetItemAt(&label_value, {}));
EXPECT_TRUE(label_value >= 0 && label_value <= 3);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
}
@@ -112,7 +112,7 @@ TEST_F(MindDataTestEpochCtrl, TestEpoch) {
EXPECT_EQ(i, sampler_size * num_epochs);

// Try to fetch data beyond the specified number of epochs.
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_EQ(row.size(), 2);

// Manually terminate the pipeline
@@ -143,16 +143,16 @@ TEST_F(MindDataTestEpochCtrl, TestRepeatEpoch) {
std::unordered_map<std::string, mindspore::MSTensor> row;

for (int epoch = 0; epoch < num_epochs; epoch++) {
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
while (row.size() != 0) {
auto label = row["label"];
std::shared_ptr<Tensor> de_label;
int64_t label_value;
ASSERT_OK(Tensor::CreateFromMSTensor(label, &de_label));
de_label->GetItemAt(&label_value, {});
ASSERT_OK(de_label->GetItemAt(&label_value, {}));
EXPECT_TRUE(label_value >= 0 && label_value <= 3);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
}
@@ -161,7 +161,7 @@ TEST_F(MindDataTestEpochCtrl, TestRepeatEpoch) {
EXPECT_EQ(i, sampler_size * num_repeats * num_epochs);

// Try to fetch data beyond the specified number of epochs.
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_EQ(row.size(), 2);

// Manually terminate the pipeline
@@ -192,16 +192,16 @@ TEST_F(MindDataTestEpochCtrl, TestRepeatRepeatEpoch) {
std::unordered_map<std::string, mindspore::MSTensor> row;

for (int epoch = 0; epoch < num_epochs; epoch++) {
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
while (row.size() != 0) {
auto label = row["label"];
std::shared_ptr<Tensor> de_label;
int64_t label_value;
ASSERT_OK(Tensor::CreateFromMSTensor(label, &de_label));
de_label->GetItemAt(&label_value, {});
ASSERT_OK(de_label->GetItemAt(&label_value, {}));
EXPECT_TRUE(label_value >= 0 && label_value <= 3);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
}
@@ -210,7 +210,7 @@ TEST_F(MindDataTestEpochCtrl, TestRepeatRepeatEpoch) {
EXPECT_EQ(i, sampler_size * num_repeats[0] * num_repeats[1] * num_epochs);

// Try to fetch data beyond the specified number of epochs.
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_EQ(row.size(), 2);

// Manually terminate the pipeline


+ 3
- 6
tests/ut/cpp/dataset/c_api_pull_based_test.cc View File

@@ -42,8 +42,7 @@ TEST_F(MindDataTestPipeline, TestPullBasedBatch) {
EXPECT_NE(iter, nullptr);

std::vector<mindspore::MSTensor> row;
Status rc = iter->GetNextRow(&row);
EXPECT_EQ(rc, Status::OK());
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_EQ(row.size(), 1);
auto temp = row[0].Shape();
std::vector<int64_t> result = {batch_size, 2};
@@ -63,8 +62,7 @@ TEST_F(MindDataTestPipeline, TestPullBasedProject) {
std::vector<mindspore::MSTensor> row;
auto iter = ds->CreatePullBasedIterator();
EXPECT_NE(iter, nullptr);
Status rc = iter->GetNextRow(&row);
EXPECT_EQ(rc, Status::OK());
ASSERT_OK(iter->GetNextRow(&row));
EXPECT_EQ(row.size(), 2);

std::shared_ptr<Dataset> ds2 = Album(folder_path, schema_file, column_names);
@@ -77,7 +75,6 @@ TEST_F(MindDataTestPipeline, TestPullBasedProject) {
EXPECT_NE(iter2, nullptr);

std::vector<mindspore::MSTensor> new_row;
rc = iter2->GetNextRow(&new_row);
EXPECT_EQ(rc, Status::OK());
ASSERT_OK(iter2->GetNextRow(&new_row));
EXPECT_EQ(new_row.size(), 1);
}

+ 2
- 2
tests/ut/cpp/dataset/c_api_repeat_test.cc View File

@@ -38,12 +38,12 @@ TEST_F(MindDataTestPipeline, TestRepeatSetNumWorkers) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

// Verify correct number of rows fetched


+ 14
- 14
tests/ut/cpp/dataset/c_api_samplers_test.cc View File

@@ -72,14 +72,14 @@ TEST_F(MindDataTestPipeline, TestImageFolderWithSamplers) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 12);
@@ -101,13 +101,13 @@ TEST_F(MindDataTestPipeline, TestNoSamplerSuccess1) {
std::shared_ptr<Iterator> iter = ds->CreateIterator();
EXPECT_NE(iter, nullptr);
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
auto label = row["label"];
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, ds->GetDatasetSize());
@@ -131,13 +131,13 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerSuccess1) {
std::shared_ptr<Iterator> iter = ds->CreateIterator();
EXPECT_NE(iter, nullptr);
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
auto label = row["label"];
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 11);
@@ -162,13 +162,13 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerSuccess2) {
std::shared_ptr<Iterator> iter = ds->CreateIterator();
EXPECT_NE(iter, nullptr);
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
auto label = row["label"];
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 11);
@@ -194,13 +194,13 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerSuccess3) {
std::shared_ptr<Iterator> iter = ds->CreateIterator();
EXPECT_NE(iter, nullptr);
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
auto label = row["label"];
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 11);
@@ -221,13 +221,13 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerSuccess4) {
std::shared_ptr<Iterator> iter = ds->CreateIterator();
EXPECT_NE(iter, nullptr);
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
auto label = row["label"];
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -314,12 +314,12 @@ TEST_F(MindDataTestPipeline, TestSamplerAddChild) {
std::shared_ptr<Iterator> iter = ds->CreateIterator();
EXPECT_NE(iter, nullptr);
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
i++;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(ds->GetDatasetSize(), 5);


+ 4
- 4
tests/ut/cpp/dataset/c_api_text_sentence_piece_vocab_test.cc View File

@@ -68,7 +68,7 @@ TEST_F(MindDataTestPipeline, TestSentencePieceVocabSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Expected result after tokenization
std::vector<std::string> expected = {"▁I", "▁sa", "w", "▁a", "▁girl", "▁with", "▁a", "▁te", "les", "co", "pe", "."};
@@ -84,7 +84,7 @@ TEST_F(MindDataTestPipeline, TestSentencePieceVocabSuccess1) {

EXPECT_MSTENSOR_EQ(txt, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -128,7 +128,7 @@ TEST_F(MindDataTestPipeline, TestSentencePieceVocabSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Expected result after tokenization
std::vector<std::string> expected = {"▁I", "▁sa", "w", "▁a", "▁girl", "▁with", "▁a", "▁te", "les", "co", "pe", "."};
@@ -144,7 +144,7 @@ TEST_F(MindDataTestPipeline, TestSentencePieceVocabSuccess2) {

EXPECT_MSTENSOR_EQ(txt, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}



+ 112
- 112
tests/ut/cpp/dataset/c_api_text_test.cc View File

@@ -63,7 +63,7 @@ TEST_F(MindDataTestPipeline, TestBasicTokenizerSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"Welcome", "to", "Beijing", "北", "京", "欢", "迎", "您"},
@@ -86,7 +86,7 @@ TEST_F(MindDataTestPipeline, TestBasicTokenizerSuccess1) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -124,7 +124,7 @@ TEST_F(MindDataTestPipeline, TestBasicTokenizerSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"this", "is", "a", "funky", "string"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -136,7 +136,7 @@ TEST_F(MindDataTestPipeline, TestBasicTokenizerSuccess2) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -175,7 +175,7 @@ TEST_F(MindDataTestPipeline, TestBasicTokenizerSuccess3) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected_tokens = {"this", "is", "a", "funky", "string"};
std::vector<uint32_t> expected_offsets_start = {0, 5, 8, 10, 16};
@@ -207,7 +207,7 @@ TEST_F(MindDataTestPipeline, TestBasicTokenizerSuccess3) {
auto limit = row["offsets_limit"];
EXPECT_MSTENSOR_EQ(limit, ms_expected_offsets_limit);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -257,7 +257,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {{"床", "前", "明", "月", "光"},
{"疑", "是", "地", "上", "霜"},
@@ -273,7 +273,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess1) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -321,7 +321,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"i", "am", "mak", "##ing", "small", "mistake",
"##s", "during", "work", "##ing", "hour", "##s"};
@@ -334,7 +334,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess2) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -382,7 +382,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess3) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"😀", "嘿", "嘿", "😃", "哈", "哈", "😄", "大", "笑", "😁", "嘻", "嘻"}, {"繁", "體", "字"}};
@@ -396,7 +396,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess3) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -444,7 +444,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess4) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"[UNK]", " ", "[CLS]"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -456,7 +456,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess4) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -504,7 +504,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess5) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"unused", " ", "[CLS]"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -516,7 +516,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess5) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -564,7 +564,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess6) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"unused", " ", "[", "CLS", "]"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -576,7 +576,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess6) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -624,7 +624,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess7) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected_tokens = {"i", "am", "mak", "##ing", "small", "mistake",
"##s", "during", "work", "##ing", "hour", "##s"};
@@ -657,7 +657,7 @@ TEST_F(MindDataTestPipeline, TestBertTokenizerSuccess7) {
auto limit = row["offsets_limit"];
EXPECT_MSTENSOR_EQ(limit, ms_expected_offsets_limit);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -739,7 +739,7 @@ TEST_F(MindDataTestPipeline, TestCaseFoldSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"welcome to beijing!", "北京欢迎您!", "我喜欢english!", " "};

@@ -751,7 +751,7 @@ TEST_F(MindDataTestPipeline, TestCaseFoldSuccess) {
mindspore::MSTensor ms_expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, ms_expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -788,7 +788,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"今天天气", "太好了", "我们", "一起", "去", "外面", "玩吧"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -800,7 +800,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerSuccess) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -837,7 +837,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"今天", "天气", "太", "好", "了", "我们", "一起", "去", "外面", "玩", "吧"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -849,7 +849,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerSuccess1) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -887,7 +887,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected_tokens = {"今天天气", "太好了", "我们", "一起", "去", "外面", "玩吧"};
std::vector<uint32_t> expected_offsets_start = {0, 12, 21, 27, 33, 36, 42};
@@ -919,7 +919,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerSuccess2) {
auto limit = row["offsets_limit"];
EXPECT_MSTENSOR_EQ(limit, ms_expected_offsets_limit);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1061,7 +1061,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddWord) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"男默女泪", "市", "长江大桥"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -1073,7 +1073,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddWord) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1113,7 +1113,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddWord1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"男默女泪", "市", "长江大桥"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -1125,7 +1125,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddWord1) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1165,7 +1165,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddWord2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"男默女泪", "市", "长江大桥"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -1177,7 +1177,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddWord2) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1217,7 +1217,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddWord3) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"江州", "市长", "江大桥", "参加", "了", "长江大桥", "的", "通车", "仪式"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -1229,7 +1229,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddWord3) {
while (row.size() != 0) {
auto ind = row["text"];
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1293,7 +1293,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddDict) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"江州", "市长", "江大桥", "参加", "了", "长江大桥", "的", "通车", "仪式"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -1305,7 +1305,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddDict) {
while (row.size() != 0) {
auto txt = row["text"];
EXPECT_MSTENSOR_EQ(txt, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1349,7 +1349,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddDictFromFile) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"今天天气", "太好了", "我们", "一起", "去", "外面", "玩吧"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -1361,7 +1361,7 @@ TEST_F(MindDataTestPipeline, TestJiebaTokenizerAddDictFromFile) {
while (row.size() != 0) {
auto txt = row["text"];
EXPECT_MSTENSOR_EQ(txt, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1398,7 +1398,7 @@ TEST_F(MindDataTestPipeline, TestSlidingWindowSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {{"This", "is", "a", "is", "a", "text", "a", "text", "file."},
{"Be", "happy", "every", "happy", "every", "day."},
@@ -1415,7 +1415,7 @@ TEST_F(MindDataTestPipeline, TestSlidingWindowSuccess) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1452,7 +1452,7 @@ TEST_F(MindDataTestPipeline, TestSlidingWindowSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {{"This", "is", "is", "a", "a", "text", "text", "file."},
{"Be", "happy", "happy", "every", "every", "day."},
@@ -1468,7 +1468,7 @@ TEST_F(MindDataTestPipeline, TestSlidingWindowSuccess1) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1555,7 +1555,7 @@ TEST_F(MindDataTestPipeline, TestToNumberSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<int64_t> expected = {-121, 14, -2219, 7623, -8162536, 162371864, -1726483716, 98921728421};

@@ -1567,7 +1567,7 @@ TEST_F(MindDataTestPipeline, TestToNumberSuccess1) {
mindspore::MSTensor ms_expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, ms_expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1610,7 +1610,7 @@ TEST_F(MindDataTestPipeline, TestToNumberSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<double_t> expected = {-1.1, 1.4, -2219.321, 7623.453, -816256.234282, 162371864.243243};

@@ -1622,7 +1622,7 @@ TEST_F(MindDataTestPipeline, TestToNumberSuccess2) {
mindspore::MSTensor ms_expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, ms_expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1667,11 +1667,11 @@ TEST_F(MindDataTestPipeline, TestToNumberFail1) {
std::unordered_map<std::string, mindspore::MSTensor> row;

// Expect error: input out of bounds of int8
iter->GetNextRow(&row);
EXPECT_ERROR(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
iter->GetNextRow(&row);
EXPECT_ERROR(iter->GetNextRow(&row));
i++;
}

@@ -1717,11 +1717,11 @@ TEST_F(MindDataTestPipeline, TestToNumberFail2) {
std::unordered_map<std::string, mindspore::MSTensor> row;

// Expect error: input out of bounds of float16
iter->GetNextRow(&row);
EXPECT_ERROR(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
iter->GetNextRow(&row);
EXPECT_ERROR(iter->GetNextRow(&row));
i++;
}

@@ -1763,11 +1763,11 @@ TEST_F(MindDataTestPipeline, TestToNumberFail3) {
std::unordered_map<std::string, mindspore::MSTensor> row;

// Expect error: invalid input which is non numerical
iter->GetNextRow(&row);
EXPECT_ERROR(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
iter->GetNextRow(&row);
EXPECT_ERROR(iter->GetNextRow(&row));
i++;
}

@@ -1840,8 +1840,8 @@ TEST_F(MindDataTestPipeline, TestTruncateSequencePairSuccess1) {

// Create a RandomDataset which has column names "col1" and "col2"
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {5});
schema->add_column("col2", mindspore::DataType::kNumberTypeInt32, {3});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {5}));
ASSERT_OK(schema->add_column("col2", mindspore::DataType::kNumberTypeInt32, {3}));
std::shared_ptr<Dataset> ds = RandomData(3, schema);
EXPECT_NE(ds, nullptr);

@@ -1860,7 +1860,7 @@ TEST_F(MindDataTestPipeline, TestTruncateSequencePairSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<int16_t>> expected1 = {{-29556, -29556}, {-18505, -18505}, {-25958, -25958}};
std::vector<std::vector<int32_t>> expected2 = {
@@ -1883,7 +1883,7 @@ TEST_F(MindDataTestPipeline, TestTruncateSequencePairSuccess1) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor2));
EXPECT_MSTENSOR_EQ(ind2, expected_tensor2);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1915,8 +1915,8 @@ TEST_F(MindDataTestPipeline, TestTruncateSequencePairSuccess2) {

// Create a RandomDataset which has column names "col1" and "col2"
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeInt32, {4});
schema->add_column("col2", mindspore::DataType::kNumberTypeInt64, {4});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeInt32, {4}));
ASSERT_OK(schema->add_column("col2", mindspore::DataType::kNumberTypeInt64, {4}));
std::shared_ptr<Dataset> ds = RandomData(4, schema);
EXPECT_NE(ds, nullptr);

@@ -1935,7 +1935,7 @@ TEST_F(MindDataTestPipeline, TestTruncateSequencePairSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<int32_t>> expected1 = {{1785358954, 1785358954, 1785358954},
{-1195853640, -1195853640, -1195853640},
@@ -1961,7 +1961,7 @@ TEST_F(MindDataTestPipeline, TestTruncateSequencePairSuccess2) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor2));
EXPECT_MSTENSOR_EQ(ind2, expected_tensor2);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1983,8 +1983,8 @@ TEST_F(MindDataTestPipeline, TestTruncateSequencePairFail) {

// Create a RandomDataset which has column names "col1" and "col2"
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeInt8, {3});
schema->add_column("col2", mindspore::DataType::kNumberTypeInt8, {3});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeInt8, {3}));
ASSERT_OK(schema->add_column("col2", mindspore::DataType::kNumberTypeInt8, {3}));
std::shared_ptr<Dataset> ds = RandomData(3, schema);
EXPECT_NE(ds, nullptr);

@@ -2028,7 +2028,7 @@ TEST_F(MindDataTestPipeline, TestNgramSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {{"_ This", "This is", "is a", "a text", "text file.", "file. _"},
{"_ Be", "Be happy", "happy every", "every day.", "day. _"},
@@ -2045,7 +2045,7 @@ TEST_F(MindDataTestPipeline, TestNgramSuccess) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2081,7 +2081,7 @@ TEST_F(MindDataTestPipeline, TestNgramSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"&-This", "This-is", "is-a", "a-text", "text-file.", "file.-&", "&-&-This", "&-This-is", "This-is-a",
@@ -2103,7 +2103,7 @@ TEST_F(MindDataTestPipeline, TestNgramSuccess1) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2252,7 +2252,7 @@ TEST_F(MindDataTestPipeline, TestNormalizeUTF8Success) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"ṩ", "ḍ̇", "q̣̇", "fi", "25", "ṩ"};

@@ -2264,7 +2264,7 @@ TEST_F(MindDataTestPipeline, TestNormalizeUTF8Success) {
mindspore::MSTensor ms_expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, ms_expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2298,7 +2298,7 @@ TEST_F(MindDataTestPipeline, TestNormalizeUTF8Success1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"ṩ", "ḍ̇", "q̣̇", "fi", "2⁵", "ẛ̣"};

@@ -2310,7 +2310,7 @@ TEST_F(MindDataTestPipeline, TestNormalizeUTF8Success1) {
mindspore::MSTensor ms_expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, ms_expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2344,7 +2344,7 @@ TEST_F(MindDataTestPipeline, TestNormalizeUTF8Success2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"ṩ", "ḍ̇", "q̣̇", "fi", "2⁵", "ẛ̣"};

@@ -2356,7 +2356,7 @@ TEST_F(MindDataTestPipeline, TestNormalizeUTF8Success2) {
mindspore::MSTensor ms_expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, ms_expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2390,7 +2390,7 @@ TEST_F(MindDataTestPipeline, TestNormalizeUTF8Success3) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"ṩ", "ḍ̇", "q̣̇", "fi", "25", "ṩ"};

@@ -2402,7 +2402,7 @@ TEST_F(MindDataTestPipeline, TestNormalizeUTF8Success3) {
mindspore::MSTensor ms_expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, ms_expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2436,7 +2436,7 @@ TEST_F(MindDataTestPipeline, TestRegexReplaceSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"Hello_World", "Let's_Go", "1:hello", "2:world",
"31:beijing", "Welcome_to_China!", "_我_不想_长大_", "Welcome_to_Shenzhen!"};
@@ -2449,7 +2449,7 @@ TEST_F(MindDataTestPipeline, TestRegexReplaceSuccess) {
mindspore::MSTensor ms_expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, ms_expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2483,7 +2483,7 @@ TEST_F(MindDataTestPipeline, TestRegexReplaceSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"Hello_World", "Let's_Go", "1:hello", "2:world",
"31:beijing", "Welcome_to China!", "_我 不想 长大 ", "Welcome_to Shenzhen!"};
@@ -2496,7 +2496,7 @@ TEST_F(MindDataTestPipeline, TestRegexReplaceSuccess1) {
mindspore::MSTensor ms_expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, ms_expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2530,7 +2530,7 @@ TEST_F(MindDataTestPipeline, TestRegexTokenizerSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {{"Hello", " ", "World"},
{"Let's", " ", "Go"},
@@ -2552,7 +2552,7 @@ TEST_F(MindDataTestPipeline, TestRegexTokenizerSuccess) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2587,7 +2587,7 @@ TEST_F(MindDataTestPipeline, TestRegexTokenizerSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected_tokens = {{"Hello", " ", "World"},
{"Let's", " ", "Go"},
@@ -2628,7 +2628,7 @@ TEST_F(MindDataTestPipeline, TestRegexTokenizerSuccess1) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_offsets_limit));
EXPECT_MSTENSOR_EQ(limit, ms_expected_offsets_limit);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2662,7 +2662,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeCharTokenizerSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"W", "e", "l", "c", "o", "m", "e", " ", "t", "o", " ", "B", "e", "i", "j", "i", "n", "g", "!"},
@@ -2681,7 +2681,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeCharTokenizerSuccess) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2716,7 +2716,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeCharTokenizerSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected_tokens = {
{"W", "e", "l", "c", "o", "m", "e", " ", "t", "o", " ", "B", "e", "i", "j", "i", "n", "g", "!"},
@@ -2761,7 +2761,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeCharTokenizerSuccess1) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_offsets_limit));
EXPECT_MSTENSOR_EQ(limit, ms_expected_offsets_limit);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2809,7 +2809,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"my"}, {"favor", "##ite"}, {"book"}, {"is"}, {"love"}, {"dur", "##ing"}, {"the"}, {"cholera"}, {"era"}, {"[UNK]"}};
@@ -2822,7 +2822,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess1) {
mindspore::MSTensor expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(txt, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2866,7 +2866,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"my"}, {"favor", "##ite"}, {"book"}, {"is"}, {"love"}, {"dur", "##ing"}, {"the"}, {"cholera"}, {"era"}, {"what"}};
@@ -2879,7 +2879,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess2) {
mindspore::MSTensor expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(txt, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2923,7 +2923,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess3) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {{"my"}, {"[UNK]"}, {"book"}, {"is"}, {"love"},
{"[UNK]"}, {"the"}, {"[UNK]"}, {"era"}, {"[UNK]"}};
@@ -2936,7 +2936,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess3) {
mindspore::MSTensor expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(txt, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -2984,7 +2984,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess4) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {{"我"}, {"最"}, {"喜"}, {"欢"}, {"的"}, {"书"}, {"是"}, {"霍"},
{"乱"}, {"时"}, {"期"}, {"的"}, {"爱"}, {"情"}, {"[UNK]"}};
@@ -2997,7 +2997,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess4) {
mindspore::MSTensor expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(txt, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -3041,7 +3041,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess5) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"my"}, {"favor", "##ite"}, {"book"}, {"is"}, {"love"}, {"dur", "##ing"}, {"the"}, {"cholera"}, {"era"}, {"[UNK]"}};
@@ -3070,7 +3070,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess5) {
mindspore::MSTensor expected_limit_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_limit_tensor));
EXPECT_MSTENSOR_EQ(limit, expected_limit_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -3114,7 +3114,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess6) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {{"[UNK]"}, {"[UNK]"}, {"[UNK]"}, {"[UNK]"}, {"[UNK]"},
{"[UNK]"}, {"[UNK]"}, {"[UNK]"}, {"[UNK]"}, {"[UNK]"}};
@@ -3127,7 +3127,7 @@ TEST_F(MindDataTestPipeline, TestWordpieceTokenizerSuccess6) {
mindspore::MSTensor expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(txt, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -3210,7 +3210,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeScriptTokenizerSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"Welcome", "to", "Beijing", "!"}, {"北京欢迎您", "!"}, {"我喜欢", "English", "!"}, {""}};
@@ -3226,7 +3226,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeScriptTokenizerSuccess) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -3261,7 +3261,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeScriptTokenizerSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"Welcome", " ", "to", " ", "Beijing", "!"}, {"北京欢迎您", "!"}, {"我喜欢", "English", "!"}, {" "}};
@@ -3277,7 +3277,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeScriptTokenizerSuccess1) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -3314,7 +3314,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeScriptTokenizerSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected_tokens = {
{"Welcome", "to", "Beijing", "!"}, {"北京欢迎您", "!"}, {"我喜欢", "English", "!"}, {""}};
@@ -3347,7 +3347,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeScriptTokenizerSuccess2) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_offsets_limit));
EXPECT_MSTENSOR_EQ(limit, ms_expected_offsets_limit);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -3383,7 +3383,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeScriptTokenizerSuccess3) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected_tokens = {
{"Welcome", " ", "to", " ", "Beijing", "!"}, {"北京欢迎您", "!"}, {"我喜欢", "English", "!"}, {" "}};
@@ -3416,7 +3416,7 @@ TEST_F(MindDataTestPipeline, TestUnicodeScriptTokenizerSuccess3) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_offsets_limit));
EXPECT_MSTENSOR_EQ(limit, ms_expected_offsets_limit);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -3450,7 +3450,7 @@ TEST_F(MindDataTestPipeline, TestWhitespaceTokenizerSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected = {
{"This", "is", "a", "text", "file."}, {"Be", "happy", "every", "day."}, {"Good", "luck", "to", "everyone."}};
@@ -3466,7 +3466,7 @@ TEST_F(MindDataTestPipeline, TestWhitespaceTokenizerSuccess) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -3501,7 +3501,7 @@ TEST_F(MindDataTestPipeline, TestWhitespaceTokenizerSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::string>> expected_tokens = {
{"Welcome", "to", "Beijing!"}, {"北京欢迎您!"}, {"我喜欢English!"}, {""}};
@@ -3534,7 +3534,7 @@ TEST_F(MindDataTestPipeline, TestWhitespaceTokenizerSuccess1) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_offsets_limit));
EXPECT_MSTENSOR_EQ(limit, ms_expected_offsets_limit);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}



+ 10
- 10
tests/ut/cpp/dataset/c_api_text_vocab_test.cc View File

@@ -70,7 +70,7 @@ TEST_F(MindDataTestPipeline, TestVocabLookupOp) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
std::vector<int32_t> expected = {2, 1, 4, 5, 6, 7};
@@ -84,7 +84,7 @@ TEST_F(MindDataTestPipeline, TestVocabLookupOp) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_item));
EXPECT_MSTENSOR_EQ(ind, ms_expected_item);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
}
@@ -118,7 +118,7 @@ TEST_F(MindDataTestPipeline, TestVocabLookupOpEmptyString) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
std::vector<int32_t> expected = {2, 1, 4, 5, 6, 7};
@@ -132,7 +132,7 @@ TEST_F(MindDataTestPipeline, TestVocabLookupOpEmptyString) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_item));
EXPECT_MSTENSOR_EQ(ind, ms_expected_item);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
}
@@ -218,7 +218,7 @@ TEST_F(MindDataTestPipeline, TestVocabFromDataset) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
std::vector<int32_t> expected = {4, 5, 3, 6, 7, 2};
@@ -232,7 +232,7 @@ TEST_F(MindDataTestPipeline, TestVocabFromDataset) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_item));
EXPECT_MSTENSOR_EQ(ind, ms_expected_item);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
}
@@ -268,7 +268,7 @@ TEST_F(MindDataTestPipeline, TestVocabFromDatasetDefault) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
std::vector<int32_t> expected = {2, 3, 1, 4, 5, 0};
@@ -290,7 +290,7 @@ TEST_F(MindDataTestPipeline, TestVocabFromDatasetDefault) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_not_expected_item));
EXPECT_MSTENSOR_DATA_NE(ind, ms_not_expected_item);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
}
@@ -385,7 +385,7 @@ TEST_F(MindDataTestPipeline, TestVocabFromDatasetInt64) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
std::vector<int64_t> expected = {2, 3, 1, 4, 5, 0};
@@ -407,7 +407,7 @@ TEST_F(MindDataTestPipeline, TestVocabFromDatasetInt64) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_not_expected_item));
EXPECT_MSTENSOR_DATA_NE(ind, ms_not_expected_item);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}
}

+ 46
- 46
tests/ut/cpp/dataset/c_api_transforms_test.cc View File

@@ -52,7 +52,7 @@ TEST_F(MindDataTestPipeline, TestComposeSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -63,7 +63,7 @@ TEST_F(MindDataTestPipeline, TestComposeSuccess) {
MS_LOG(INFO) << "Label shape: " << label.Shape();
EXPECT_EQ(image.Shape()[0], 777);
EXPECT_EQ(image.Shape()[1], 777);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);
@@ -144,7 +144,7 @@ TEST_F(MindDataTestPipeline, TestConcatenateSuccess) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(246);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {1});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {1}));
std::shared_ptr<Dataset> ds = RandomData(4, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -176,7 +176,7 @@ TEST_F(MindDataTestPipeline, TestConcatenateSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::int16_t>> expected = {
{1, 2, 31354, 3}, {1, 2, -5655, 3}, {1, 2, -17734, 3}, {1, 2, -17220, 3}};
@@ -190,7 +190,7 @@ TEST_F(MindDataTestPipeline, TestConcatenateSuccess) {
mindspore::MSTensor expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -223,7 +223,7 @@ TEST_F(MindDataTestPipeline, TestDuplicateSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -232,7 +232,7 @@ TEST_F(MindDataTestPipeline, TestDuplicateSuccess) {
auto image_copy = row["image_copy"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_MSTENSOR_EQ(image, image_copy);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -248,7 +248,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessInt) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(864);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeInt32, {6});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeInt32, {6}));
std::shared_ptr<Dataset> ds = RandomData(5, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(3);
@@ -270,7 +270,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessInt) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<int32_t>> expected = {
{3, 3, 3, 3, 3, 3}, {3, 3, 3, 3, 3, 3}, {3, 3, 3, 3, 3, 3}, {3, 3, 3, 3, 3, 3}, {3, 3, 3, 3, 3, 3}};
@@ -285,7 +285,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessInt) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -303,7 +303,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessBool) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(963);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeBool, {4});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeBool, {4}));
std::shared_ptr<Dataset> ds = RandomData(3, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -325,7 +325,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessBool) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<bool>> expected = {
{true, true, true, true}, {true, true, true, true}, {true, true, true, true}};
@@ -340,7 +340,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessBool) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -358,7 +358,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessDownTypecast) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(963);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeUInt8, {4});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeUInt8, {4}));
std::shared_ptr<Dataset> ds = RandomData(3, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -380,7 +380,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessDownTypecast) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Note: 2**8 -3 = 256 -3 = 253
std::vector<std::vector<uint8_t>> expected = {{253, 253, 253, 253}, {253, 253, 253, 253}, {253, 253, 253, 253}};
@@ -395,7 +395,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessDownTypecast) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -413,7 +413,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessDownTypecastZero) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(963);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeUInt8, {4});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeUInt8, {4}));
std::shared_ptr<Dataset> ds = RandomData(3, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -435,7 +435,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessDownTypecastZero) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Note: 2**8 = 256
std::vector<std::vector<uint8_t>> expected = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
@@ -450,7 +450,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessDownTypecastZero) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -468,7 +468,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessDownTypecast16) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(963);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeUInt16, {4});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeUInt16, {4}));
std::shared_ptr<Dataset> ds = RandomData(3, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -490,7 +490,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessDownTypecast16) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Note: 2**16 -3 = 65536 -3 = 65533
std::vector<std::vector<uint16_t>> expected = {
@@ -506,7 +506,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessDownTypecast16) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -524,7 +524,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessUpTypecast) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(963);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeFloat32, {2});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeFloat32, {2}));
std::shared_ptr<Dataset> ds = RandomData((float)4.0, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -546,7 +546,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessUpTypecast) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<float_t>> expected = {{0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}};

@@ -560,7 +560,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessUpTypecast) {
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -607,7 +607,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessString) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::string> expected = {"Hello", "Hello", "Hello", "Hello", "Hello"};
std::shared_ptr<Tensor> de_expected_tensor;
@@ -620,7 +620,7 @@ TEST_F(MindDataTestPipeline, TestFillSuccessString) {
auto ind = row["text"];
TEST_MS_LOG_MSTENSOR(INFO, "ind: ", ind);
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -676,7 +676,7 @@ TEST_F(MindDataTestPipeline, TestMaskSuccess) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(246);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {4});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {4}));
std::shared_ptr<Dataset> ds = RandomData(4, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -698,7 +698,7 @@ TEST_F(MindDataTestPipeline, TestMaskSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<bool>> expected = {
{true, true, true, true}, {false, false, false, false}, {false, false, false, false}, {false, false, false, false}};
@@ -711,7 +711,7 @@ TEST_F(MindDataTestPipeline, TestMaskSuccess) {
mindspore::MSTensor expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -764,7 +764,7 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -778,7 +778,7 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess1) {
true);
EXPECT_EQ(label.Shape().size() == 2 && batch_size == label.Shape()[0] && number_of_classes == label.Shape()[1],
true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -819,14 +819,14 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -882,7 +882,7 @@ TEST_F(MindDataTestPipeline, TestPadEndSuccess) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(246);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {1});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {1}));
std::shared_ptr<Dataset> ds = RandomData(4, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -905,7 +905,7 @@ TEST_F(MindDataTestPipeline, TestPadEndSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::int16_t>> expected = {{31354, 0, 0}, {-5655, 0, 0}, {-17734, 0, 0}, {-17220, 0, 0}};

@@ -917,7 +917,7 @@ TEST_F(MindDataTestPipeline, TestPadEndSuccess) {
mindspore::MSTensor expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -951,7 +951,7 @@ TEST_F(MindDataTestPipeline, TestRandomApplySuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -960,7 +960,7 @@ TEST_F(MindDataTestPipeline, TestRandomApplySuccess) {
auto label = row["label"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
MS_LOG(INFO) << "Label shape: " << label.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 5);
@@ -1079,7 +1079,7 @@ TEST_F(MindDataTestPipeline, TestRandomChoiceSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -1088,7 +1088,7 @@ TEST_F(MindDataTestPipeline, TestRandomChoiceSuccess) {
auto label = row["label"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
MS_LOG(INFO) << "Label shape: " << label.Shape();
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);
@@ -1170,7 +1170,7 @@ TEST_F(MindDataTestPipeline, TestSliceSuccess) {
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(246);
std::shared_ptr<SchemaObj> schema = Schema();
schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {1});
ASSERT_OK(schema->add_column("col1", mindspore::DataType::kNumberTypeInt16, {1}));
std::shared_ptr<Dataset> ds = RandomData(4, schema);
EXPECT_NE(ds, nullptr);
ds = ds->SetNumWorkers(2);
@@ -1202,7 +1202,7 @@ TEST_F(MindDataTestPipeline, TestSliceSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

std::vector<std::vector<std::int16_t>> expected = {{1, 3}, {1, 3}, {1, 3}, {1, 3}};

@@ -1215,7 +1215,7 @@ TEST_F(MindDataTestPipeline, TestSliceSuccess) {
mindspore::MSTensor expected_tensor =
mindspore::MSTensor(std::make_shared<mindspore::dataset::DETensor>(de_expected_tensor));
EXPECT_MSTENSOR_EQ(ind, expected_tensor);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
i++;
}

@@ -1241,7 +1241,7 @@ TEST_F(MindDataTestPipeline, TestTypeCastSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

// Check original data type of dataset
auto image = row["image"];
@@ -1266,7 +1266,7 @@ TEST_F(MindDataTestPipeline, TestTypeCastSuccess) {
EXPECT_NE(iter2, nullptr);

// Check current data type of dataset
iter2->GetNextRow(&row);
ASSERT_OK(iter2->GetNextRow(&row));
auto image2 = row["image"];
auto cur_type = image2.DataType();
MS_LOG(INFO) << "Current data type id: " << cur_type;


+ 28
- 28
tests/ut/cpp/dataset/c_api_vision_a_to_q_test.cc View File

@@ -60,14 +60,14 @@ TEST_F(MindDataTestPipeline, TestAutoContrastSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 15);
@@ -109,14 +109,14 @@ TEST_F(MindDataTestPipeline, TestAutoContrastSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 15);
@@ -158,14 +158,14 @@ TEST_F(MindDataTestPipeline, TestCenterCrop) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 15);
@@ -220,7 +220,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -234,7 +234,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchSuccess1) {
true);
EXPECT_EQ(label.Shape().size() == 2 && batch_size == label.Shape()[0] && number_of_classes == label.Shape()[1],
true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -281,7 +281,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -296,7 +296,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchSuccess2) {
EXPECT_EQ(label.Shape().size() == 2 && batch_size == label.Shape()[0] && number_of_classes == label.Shape()[1],
true);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -478,14 +478,14 @@ TEST_F(MindDataTestPipeline, TestCutOut) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -527,14 +527,14 @@ TEST_F(MindDataTestPipeline, TestDecode) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}
EXPECT_EQ(i, 20);

@@ -575,7 +575,7 @@ TEST_F(MindDataTestPipeline, TestHwcToChw) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -586,7 +586,7 @@ TEST_F(MindDataTestPipeline, TestHwcToChw) {
EXPECT_EQ(
batch_size == image.Shape()[0] && 3 == image.Shape()[1] && 2268 == image.Shape()[2] && 4032 == image.Shape()[3],
true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}
EXPECT_EQ(i, 20);

@@ -617,14 +617,14 @@ TEST_F(MindDataTestPipeline, TestInvert) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}
EXPECT_EQ(i, 20);

@@ -735,14 +735,14 @@ TEST_F(MindDataTestPipeline, TestMixUpBatchSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -786,14 +786,14 @@ TEST_F(MindDataTestPipeline, TestMixUpBatchSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);
@@ -835,14 +835,14 @@ TEST_F(MindDataTestPipeline, TestNormalize) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -880,7 +880,7 @@ TEST_F(MindDataTestPipeline, TestNormalizePad) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -889,7 +889,7 @@ TEST_F(MindDataTestPipeline, TestNormalizePad) {
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[2], 4);

iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -933,14 +933,14 @@ TEST_F(MindDataTestPipeline, TestPad) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);


+ 2
- 2
tests/ut/cpp/dataset/c_api_vision_affine_test.cc View File

@@ -52,7 +52,7 @@ TEST_F(MindDataTestPipeline, TestAffineAPI) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -60,7 +60,7 @@ TEST_F(MindDataTestPipeline, TestAffineAPI) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(row["image"].Shape().at(0), 256);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 15);


+ 6
- 6
tests/ut/cpp/dataset/c_api_vision_bounding_box_augment_test.cc View File

@@ -50,14 +50,14 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentSuccess1Shr) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);
@@ -90,14 +90,14 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentSuccess2Auto) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);
@@ -133,14 +133,14 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentSuccess3Obj) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);


+ 10
- 10
tests/ut/cpp/dataset/c_api_vision_r_to_z_test.cc View File

@@ -40,7 +40,7 @@ TEST_F(MindDataTestPipeline, TestRescaleSucess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

auto image = row["image"];

@@ -62,7 +62,7 @@ TEST_F(MindDataTestPipeline, TestRescaleSucess1) {

// Iterate the dataset and get each row1
std::unordered_map<std::string, mindspore::MSTensor> row1;
iter1->GetNextRow(&row1);
ASSERT_OK(iter1->GetNextRow(&row1));

auto image1 = row1["image"];

@@ -93,14 +93,14 @@ TEST_F(MindDataTestPipeline, TestRescaleSucess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 1);
@@ -141,14 +141,14 @@ TEST_F(MindDataTestPipeline, TestResize1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 24);
@@ -181,14 +181,14 @@ TEST_F(MindDataTestPipeline, TestResizeWithBBoxSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);
@@ -216,14 +216,14 @@ TEST_F(MindDataTestPipeline, TestRGB2GRAYSucess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 1);


+ 8
- 8
tests/ut/cpp/dataset/c_api_vision_random_subselect_policy_test.cc View File

@@ -61,14 +61,14 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess1Shr) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 7);
@@ -114,14 +114,14 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess2Auto) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 7);
@@ -171,14 +171,14 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess3Obj) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 7);
@@ -223,14 +223,14 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess4MultiPolicy) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 7);


+ 46
- 46
tests/ut/cpp/dataset/c_api_vision_random_test.cc View File

@@ -99,14 +99,14 @@ TEST_F(MindDataTestPipeline, TestRandomAffineSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -147,14 +147,14 @@ TEST_F(MindDataTestPipeline, TestRandomAffineSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -199,14 +199,14 @@ TEST_F(MindDataTestPipeline, TestRandomColor) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -263,14 +263,14 @@ TEST_F(MindDataTestPipeline, TestRandomColorAdjust) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -320,14 +320,14 @@ TEST_F(MindDataTestPipeline, TestRandomCropSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -466,7 +466,7 @@ TEST_F(MindDataTestPipeline, TestRandomCropWithBboxSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -475,7 +475,7 @@ TEST_F(MindDataTestPipeline, TestRandomCropWithBboxSuccess) {
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0], 128);
EXPECT_EQ(image.Shape()[1], 128);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);
@@ -596,14 +596,14 @@ TEST_F(MindDataTestPipeline, TestRandomHorizontalFlipWithBBoxSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);
@@ -644,14 +644,14 @@ TEST_F(MindDataTestPipeline, TestRandomHorizontalAndVerticalFlip) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -692,14 +692,14 @@ TEST_F(MindDataTestPipeline, TestRandomPosterizeSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -740,14 +740,14 @@ TEST_F(MindDataTestPipeline, TestRandomPosterizeSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -778,7 +778,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizeSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -786,7 +786,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizeSuccess1) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 66, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 5);
@@ -822,7 +822,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizeSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -830,7 +830,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizeSuccess2) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 66 && image.Shape()[1] == 77, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 6);
@@ -865,7 +865,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizeWithBBoxSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -873,7 +873,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizeWithBBoxSuccess1) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 88, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);
@@ -912,7 +912,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizeWithBBoxSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -920,7 +920,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizeWithBBoxSuccess2) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 88 && image.Shape()[1] == 99, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 8);
@@ -952,7 +952,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizedCropSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -960,7 +960,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizedCropSuccess1) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 5 && image.Shape()[1] == 5, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -992,7 +992,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizedCropSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -1000,7 +1000,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizedCropSuccess2) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 5 && image.Shape()[1] == 10, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -1114,7 +1114,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizedCropWithBBoxSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -1122,7 +1122,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizedCropWithBBoxSuccess1) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 5 && image.Shape()[1] == 5, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -1158,7 +1158,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizedCropWithBBoxSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -1166,7 +1166,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizedCropWithBBoxSuccess2) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 5 && image.Shape()[1] == 10, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -1290,14 +1290,14 @@ TEST_F(MindDataTestPipeline, TestRandomRotation) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -1424,14 +1424,14 @@ TEST_F(MindDataTestPipeline, TestRandomSharpness) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -1464,14 +1464,14 @@ TEST_F(MindDataTestPipeline, TestRandomSolarizeSucess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -1502,14 +1502,14 @@ TEST_F(MindDataTestPipeline, TestRandomSolarizeSucess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 10);
@@ -1540,14 +1540,14 @@ TEST_F(MindDataTestPipeline, TestRandomVerticalFlipWithBBoxSuccess) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 3);


+ 8
- 8
tests/ut/cpp/dataset/c_api_vision_soft_dvpp_test.cc View File

@@ -51,7 +51,7 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeRandomCropResizeJpegSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -59,7 +59,7 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeRandomCropResizeJpegSuccess1) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 500 && image.Shape()[1] == 500, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 4);
@@ -93,7 +93,7 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeRandomCropResizeJpegSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));

uint64_t i = 0;
while (row.size() != 0) {
@@ -101,7 +101,7 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeRandomCropResizeJpegSuccess2) {
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
EXPECT_EQ(image.Shape()[0] == 500 && image.Shape()[1] == 600, true);
iter->GetNextRow(&row);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 6);
@@ -137,14 +137,14 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeResizeJpegSuccess1) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 12);
@@ -175,14 +175,14 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeResizeJpegSuccess2) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 2);


+ 6
- 6
tests/ut/cpp/dataset/c_api_vision_uniform_aug_test.cc View File

@@ -58,14 +58,14 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps1Shr) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -106,14 +106,14 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps2Auto) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);
@@ -159,14 +159,14 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps3Obj) {

// Iterate the dataset and get each row
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);
ASSERT_OK(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);
ASSERT_OK(iter->GetNextRow(&row));
}

EXPECT_EQ(i, 20);


+ 15
- 15
tests/ut/cpp/dataset/celeba_op_test.cc View File

@@ -72,17 +72,17 @@ TEST_F(MindDataTestCelebaDataset, TestSequentialCeleba) {
EXPECT_TRUE(false);
} else {
DatasetIterator di(tree);
TensorMap tersor_map;
di.GetNextAsMap(&tersor_map);
TensorMap tensor_map;
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
while (tersor_map.size() != 0) {
while (tensor_map.size() != 0) {
uint32_t label;
for (int index = 0; index < 40; index++) {
tersor_map["attr"]->GetItemAt<uint32_t>(&label, {index});
tensor_map["attr"]->GetItemAt<uint32_t>(&label, {index});
EXPECT_TRUE(expect_labels[count][index] == label);
}
count++;
di.GetNextAsMap(&tersor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(count == 4);
}
@@ -119,17 +119,17 @@ TEST_F(MindDataTestCelebaDataset, TestCelebaRepeat) {
EXPECT_TRUE(false);
} else {
DatasetIterator di(tree);
TensorMap tersor_map;
di.GetNextAsMap(&tersor_map);
TensorMap tensor_map;
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
while (tersor_map.size() != 0) {
while (tensor_map.size() != 0) {
uint32_t label;
for (int index = 0; index < 40; index++) {
tersor_map["attr"]->GetItemAt<uint32_t>(&label, {index});
tensor_map["attr"]->GetItemAt<uint32_t>(&label, {index});
EXPECT_TRUE(expect_labels[count][index] == label);
}
count++;
di.GetNextAsMap(&tersor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(count == 8);
}
@@ -151,17 +151,17 @@ TEST_F(MindDataTestCelebaDataset, TestSubsetRandomSamplerCeleba) {
EXPECT_TRUE(false);
} else {
DatasetIterator di(tree);
TensorMap tersor_map;
di.GetNextAsMap(&tersor_map);
TensorMap tensor_map;
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
while (tersor_map.size() != 0) {
while (tensor_map.size() != 0) {
uint32_t label;
for (int index = 0; index < 40; index++) {
tersor_map["attr"]->GetItemAt<uint32_t>(&label, {index});
tensor_map["attr"]->GetItemAt<uint32_t>(&label, {index});
EXPECT_TRUE(expect_labels[count][index] == label);
}
count++;
di.GetNextAsMap(&tersor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(count == 1);
}


+ 6
- 6
tests/ut/cpp/dataset/cifar_op_test.cc View File

@@ -75,7 +75,7 @@ TEST_F(MindDataTestCifarOp, TestSequentialSamplerCifar10) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
uint32_t label = 0;
@@ -84,7 +84,7 @@ TEST_F(MindDataTestCifarOp, TestSequentialSamplerCifar10) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 100);
}
@@ -104,7 +104,7 @@ TEST_F(MindDataTestCifarOp, TestRandomSamplerCifar10) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
uint32_t label = 0;
@@ -112,7 +112,7 @@ TEST_F(MindDataTestCifarOp, TestRandomSamplerCifar10) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 12);
}
@@ -130,7 +130,7 @@ TEST_F(MindDataTestCifarOp, TestSequentialSamplerCifar100) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
uint32_t coarse = 0;
@@ -142,7 +142,7 @@ TEST_F(MindDataTestCifarOp, TestSequentialSamplerCifar100) {
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << " coarse:"
<< coarse << " fine:" << fine << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 100);
}


+ 19
- 19
tests/ut/cpp/dataset/image_folder_op_test.cc View File

@@ -94,7 +94,7 @@ TEST_F(MindDataTestImageFolderSampler, TestSequentialImageFolderWithRepeat) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -103,7 +103,7 @@ TEST_F(MindDataTestImageFolderSampler, TestSequentialImageFolderWithRepeat) {
EXPECT_TRUE(res[(i % 44) / 11] == label);
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 88);
}
@@ -120,7 +120,7 @@ TEST_F(MindDataTestImageFolderSampler, TestRandomImageFolder) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -128,7 +128,7 @@ TEST_F(MindDataTestImageFolderSampler, TestRandomImageFolder) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {});
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 44);
}
@@ -150,7 +150,7 @@ TEST_F(MindDataTestImageFolderSampler, TestRandomSamplerImageFolder) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -159,7 +159,7 @@ TEST_F(MindDataTestImageFolderSampler, TestRandomSamplerImageFolder) {
EXPECT_TRUE(res[i] == label);
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 12);
}
@@ -186,7 +186,7 @@ TEST_F(MindDataTestImageFolderSampler, TestSequentialImageFolderWithRepeatBatch)
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
while (tensor_map.size() != 0) {
@@ -196,7 +196,7 @@ TEST_F(MindDataTestImageFolderSampler, TestSequentialImageFolderWithRepeatBatch)
MS_LOG(DEBUG) << "row: " << i << " " << tensor_map["image"]->shape() << " (*label):" << (*label)
<< " *tensor_map[label]: " << *tensor_map["label"] << std::endl;
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 8);
}
@@ -227,7 +227,7 @@ TEST_F(MindDataTestImageFolderSampler, TestSubsetRandomSamplerImageFolder) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {});
res[label]--;
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_EQ(res[0], 0);
EXPECT_EQ(res[1], 0);
@@ -263,7 +263,7 @@ TEST_F(MindDataTestImageFolderSampler, TestWeightedRandomSamplerImageFolder) {
while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {});
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 12);
}
@@ -285,7 +285,7 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderClassIndex) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -294,7 +294,7 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderClassIndex) {
EXPECT_TRUE(label == res[i / 11]);
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 22);
}
@@ -326,7 +326,7 @@ TEST_F(MindDataTestImageFolderSampler, TestDistributedSampler) {
EXPECT_EQ(i % 4, label);
MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 16);
}
@@ -346,7 +346,7 @@ TEST_F(MindDataTestImageFolderSampler, TestPKSamplerImageFolder) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -355,7 +355,7 @@ TEST_F(MindDataTestImageFolderSampler, TestPKSamplerImageFolder) {
EXPECT_TRUE(res[i] == label);
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 12);
}
@@ -380,7 +380,7 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderDecode) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -391,7 +391,7 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderDecode) {
TensorShape({2268, 4032, 3})); // verify shapes are correct after decode
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 20);
}
@@ -421,7 +421,7 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderSharding1) {
EXPECT_EQ(labels[i], label);
MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 5);
}
@@ -451,7 +451,7 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderSharding2) {
EXPECT_EQ(labels[i], label);
MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 11);
}


+ 2
- 2
tests/ut/cpp/dataset/ir_callback_test.cc View File

@@ -236,7 +236,7 @@ TEST_F(MindDataTestCallback, TestMultiEpochCallback) {
TensorMap tensor_map;
size_t num_epochs = 2;
for (int ep_num = 0; ep_num < num_epochs; ++ep_num) {
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());

while (tensor_map.size() != 0) {
@@ -301,7 +301,7 @@ TEST_F(MindDataTestCallback, TestSelectedCallback) {
TensorMap tensor_map;
size_t num_epochs = 2;
for (int ep_num = 0; ep_num < num_epochs; ++ep_num) {
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());

while (tensor_map.size() != 0) {


+ 9
- 9
tests/ut/cpp/dataset/manifest_op_test.cc View File

@@ -77,7 +77,7 @@ TEST_F(MindDataTestManifest, TestSequentialManifestWithRepeat) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -86,7 +86,7 @@ TEST_F(MindDataTestManifest, TestSequentialManifestWithRepeat) {
EXPECT_TRUE(res[i] == label);
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 4);
}
@@ -114,7 +114,7 @@ TEST_F(MindDataTestManifest, TestSubsetRandomSamplerManifest) {
while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {});
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_EQ(label, 1);
}
EXPECT_TRUE(i == 1);
@@ -137,7 +137,7 @@ TEST_F(MindDataTestManifest, MindDataTestManifestClassIndex) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -146,7 +146,7 @@ TEST_F(MindDataTestManifest, MindDataTestManifestClassIndex) {
EXPECT_TRUE(label == res[i]);
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 2);
}
@@ -170,7 +170,7 @@ TEST_F(MindDataTestManifest, MindDataTestManifestNumSamples) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -179,7 +179,7 @@ TEST_F(MindDataTestManifest, MindDataTestManifestNumSamples) {
EXPECT_TRUE(0 == label);
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 4);
}
@@ -199,7 +199,7 @@ TEST_F(MindDataTestManifest, MindDataTestManifestEval) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -208,7 +208,7 @@ TEST_F(MindDataTestManifest, MindDataTestManifestEval) {
EXPECT_TRUE(0 == label);
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 1);
}


+ 6
- 6
tests/ut/cpp/dataset/map_op_test.cc View File

@@ -634,7 +634,7 @@ TEST_F(MindDataTestMapOp, ImageFolder_Decode_Repeat_Resize) {
// Start the loop of reading tensors from our pipeline
DatasetIterator di(my_tree_);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -646,7 +646,7 @@ TEST_F(MindDataTestMapOp, ImageFolder_Decode_Repeat_Resize) {
EXPECT_TRUE(img_class[(i % 44) / 11] == label);
// Dump all the image into string, to be used as a comparison later.
result.append((char *)tensor_map["image"]->GetBuffer(), (int64_t)tensor_map["image"]->Size());
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
i++;
}
EXPECT_TRUE(i == 88);
@@ -684,7 +684,7 @@ TEST_F(MindDataTestMapOp, ImageFolder_Decode_Repeat_Resize) {

// Start the loop of reading tensors from our pipeline
DatasetIterator di2(my_tree_2);
di2.GetNextAsMap(&tensor_map);
ASSERT_OK(di2.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
i = 0;
label = 0;
@@ -694,7 +694,7 @@ TEST_F(MindDataTestMapOp, ImageFolder_Decode_Repeat_Resize) {
MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
EXPECT_TRUE(img_class[(i % 44) / 11] == label);
result2.append((char *)tensor_map["image"]->GetBuffer(), (int64_t)tensor_map["image"]->Size());
di2.GetNextAsMap(&tensor_map);
ASSERT_OK(di2.GetNextAsMap(&tensor_map));
i++;
}
EXPECT_TRUE(i == 88);
@@ -747,7 +747,7 @@ TEST_F(MindDataTestMapOp, ImageFolder_Decode_Repeat_Resize_NoInputColumns) {
// Start the loop of reading tensors from our pipeline
DatasetIterator di(my_tree_);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
int32_t label = 0;
@@ -756,7 +756,7 @@ TEST_F(MindDataTestMapOp, ImageFolder_Decode_Repeat_Resize_NoInputColumns) {
while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {});
EXPECT_TRUE(img_class[(i % 44) / 11] == label);
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
i++;
}
EXPECT_TRUE(i == 88);


+ 4
- 4
tests/ut/cpp/dataset/mnist_op_test.cc View File

@@ -92,7 +92,7 @@ TEST_F(MindDataTestMnistSampler, TestSequentialMnistWithRepeat) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
uint32_t label = 0;
@@ -101,7 +101,7 @@ TEST_F(MindDataTestMnistSampler, TestSequentialMnistWithRepeat) {
EXPECT_TRUE(res[i % 10] == label);
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 20);
}
@@ -130,7 +130,7 @@ TEST_F(MindDataTestMnistSampler, TestSequentialImageFolderWithRepeatBatch) {
} else {
DatasetIterator di(tree);
TensorMap tensor_map;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
EXPECT_TRUE(rc.IsOk());
uint64_t i = 0;
while (tensor_map.size() != 0) {
@@ -139,7 +139,7 @@ TEST_F(MindDataTestMnistSampler, TestSequentialImageFolderWithRepeatBatch) {
EXPECT_TRUE((*label) == (*tensor_map["label"]));
MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << *tensor_map["label"] << "\n";
i++;
di.GetNextAsMap(&tensor_map);
ASSERT_OK(di.GetNextAsMap(&tensor_map));
}
EXPECT_TRUE(i == 4);
}


+ 1
- 1
tests/ut/cpp/dataset/optimization_pass_test.cc View File

@@ -40,7 +40,7 @@ TEST_F(MindDataTestOptimizationPass, MindDataTestAutoWorkerPass) {
MS_LOG(INFO) << "Doing MindDataTestOptimizationPass-MindDataTestAutoWorkerPass.";

std::shared_ptr<SchemaObj> schema = std::make_shared<SchemaObj>();
ASSERT_TRUE(schema->add_column("label", "uint32", {}));
ASSERT_OK(schema->add_column("label", "uint32", {}));
std::shared_ptr<Dataset> map_leaf = ImageFolder("dir")->SetNumWorkers(0);
std::shared_ptr<Dataset> nonmap_leaf = RandomData(44, schema)->SetNumWorkers(0);
std::shared_ptr<Dataset> batch = Zip({map_leaf, nonmap_leaf})->Batch(1)->SetNumWorkers(0);


Loading…
Cancel
Save