!35 Replace std::cout with MS_LOG in dataset unit test

Merge pull request !35 from jonathan_yan/4SZ
This commit is contained in:
mindspore-ci-bot 2020-03-31 08:15:37 +08:00 committed by Gitee
commit be9aa4a6ee
22 changed files with 102 additions and 66 deletions

View File

@ -45,5 +45,5 @@ TEST_F(MindDataTestArena, TestALLFunction) {
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
mp->Deallocate(v.at(i)); mp->Deallocate(v.at(i));
} }
std::cout << *mp; MS_LOG(DEBUG) << *mp;
} }

View File

@ -196,6 +196,6 @@ TEST_F(MindDataTestBPlusTree, Test3) {
EXPECT_EQ(it.value(), "b"); EXPECT_EQ(it.value(), "b");
MS_LOG(INFO) << "Dump all the values using [] operator."; MS_LOG(INFO) << "Dump all the values using [] operator.";
for (uint64_t i = min; i <= max; i++) { for (uint64_t i = min; i <= max; i++) {
std::cout << ai[i] << std::endl; MS_LOG(DEBUG) << ai[i] << std::endl;
} }
} }

View File

@ -81,7 +81,8 @@ TEST_F(MindDataTestCifarOp, TestSequentialSamplerCifar10) {
uint32_t label = 0; uint32_t label = 0;
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {}); tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 100); EXPECT_TRUE(i == 100);
@ -108,7 +109,8 @@ TEST_F(MindDataTestCifarOp, TestRandomSamplerCifar10) {
uint32_t label = 0; uint32_t label = 0;
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {}); tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 12); EXPECT_TRUE(i == 12);
@ -133,7 +135,8 @@ TEST_F(MindDataTestCifarOp, TestCifar10NumSample) {
uint32_t label = 0; uint32_t label = 0;
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {}); tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 100); EXPECT_TRUE(i == 100);
@ -159,8 +162,9 @@ TEST_F(MindDataTestCifarOp, TestSequentialSamplerCifar100) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["coarse_label"]->GetItemAt<uint32_t>(&coarse, {}); tensor_map["coarse_label"]->GetItemAt<uint32_t>(&coarse, {});
tensor_map["fine_label"]->GetItemAt<uint32_t>(&fine, {}); tensor_map["fine_label"]->GetItemAt<uint32_t>(&fine, {});
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << " coarse:" MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << " coarse:"
<< coarse << " fine:" << fine << "\n"; << coarse << " fine:" << fine << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 100); EXPECT_TRUE(i == 100);

View File

@ -52,7 +52,7 @@ Status TestMem(MindDataTestCircularPool *tp, int32_t num_iterations) {
uint64_t new_sz = dist(gen); uint64_t new_sz = dist(gen);
std::string str = "Allocate " + std::to_string(old_sz) + std::string str = "Allocate " + std::to_string(old_sz) +
" bytes of memory and then resize to " + std::to_string(new_sz); " bytes of memory and then resize to " + std::to_string(new_sz);
std::cout << str << std::endl; MS_LOG(DEBUG) << str << std::endl;
std::string id = Services::GetUniqueID(); std::string id = Services::GetUniqueID();
void *p; void *p;
RETURN_IF_NOT_OK(tp->mp_->Allocate(old_sz, &p)); RETURN_IF_NOT_OK(tp->mp_->Allocate(old_sz, &p));
@ -76,9 +76,9 @@ TEST_F(MindDataTestCircularPool, TestALLFunction) {
vg_.CreateAsyncTask("TestMem", f); vg_.CreateAsyncTask("TestMem", f);
} }
vg_.join_all(); vg_.join_all();
std::cout << vg_.GetTaskErrorIfAny() << std::endl; MS_LOG(DEBUG) << vg_.GetTaskErrorIfAny() << std::endl;
ASSERT_TRUE(vg_.GetTaskErrorIfAny().IsOk()); ASSERT_TRUE(vg_.GetTaskErrorIfAny().IsOk());
CircularPool *cp = dynamic_cast<CircularPool *>(mp_.get()); CircularPool *cp = dynamic_cast<CircularPool *>(mp_.get());
std::cout << *cp << std::endl; MS_LOG(DEBUG) << *cp << std::endl;
} }

View File

@ -102,7 +102,8 @@ TEST_F(MindDataTestImageFolderSampler, TestSequentialImageFolderWithRepeat) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
EXPECT_TRUE(res[(i % 44) / 11] == label); EXPECT_TRUE(res[(i % 44) / 11] == label);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 88); EXPECT_TRUE(i == 88);
@ -126,7 +127,8 @@ TEST_F(MindDataTestImageFolderSampler, TestRandomImageFolder) {
int32_t label = 0; int32_t label = 0;
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 44); EXPECT_TRUE(i == 44);
@ -155,7 +157,8 @@ TEST_F(MindDataTestImageFolderSampler, TestRandomSamplerImageFolder) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
EXPECT_TRUE(res[i] == label); EXPECT_TRUE(res[i] == label);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 12); EXPECT_TRUE(i == 12);
@ -185,8 +188,9 @@ TEST_F(MindDataTestImageFolderSampler, TestSequentialImageFolderWithRepeatBatch)
std::shared_ptr<Tensor> label; std::shared_ptr<Tensor> label;
Create1DTensor(&label, 11, reinterpret_cast<unsigned char *>(res[i % 4]), DataType::DE_INT32); Create1DTensor(&label, 11, reinterpret_cast<unsigned char *>(res[i % 4]), DataType::DE_INT32);
EXPECT_TRUE((*label) == (*tensor_map["label"])); EXPECT_TRUE((*label) == (*tensor_map["label"]));
std::cout << "row: " << i++ << " " << tensor_map["image"]->shape() << " (*label):" << (*label) MS_LOG(DEBUG) << "row: " << i << " " << tensor_map["image"]->shape() << " (*label):" << (*label)
<< " *tensor_map[label]: " << *tensor_map["label"] << std::endl; << " *tensor_map[label]: " << *tensor_map["label"] << std::endl;
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 8); EXPECT_TRUE(i == 8);
@ -282,7 +286,8 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderClassIndex) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
EXPECT_TRUE(label == res[i / 11]); EXPECT_TRUE(label == res[i / 11]);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 22); EXPECT_TRUE(i == 22);
@ -308,7 +313,8 @@ TEST_F(MindDataTestImageFolderSampler, TestDistributedSampler) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
EXPECT_EQ(i % 4, label); EXPECT_EQ(i % 4, label);
std::cout << "row:" << i++ << "\tlabel:" << label << "\n"; MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 16); EXPECT_TRUE(i == 16);
@ -335,7 +341,8 @@ TEST_F(MindDataTestImageFolderSampler, TestPKSamplerImageFolder) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
EXPECT_TRUE(res[i] == label); EXPECT_TRUE(res[i] == label);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 12); EXPECT_TRUE(i == 12);
@ -360,7 +367,8 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderNumSamples) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
EXPECT_TRUE(0 == label); EXPECT_TRUE(0 == label);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 22); EXPECT_TRUE(i == 22);
@ -392,7 +400,8 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderDecode) {
EXPECT_TRUE(label == res[i / 11]); EXPECT_TRUE(label == res[i / 11]);
EXPECT_TRUE( EXPECT_TRUE(
tensor_map["image"]->shape() == TensorShape({2268, 4032, 3})); // verify shapes are correct after decode tensor_map["image"]->shape() == TensorShape({2268, 4032, 3})); // verify shapes are correct after decode
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 20); EXPECT_TRUE(i == 20);
@ -442,7 +451,8 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderSharding1) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
EXPECT_EQ(labels[i], label); EXPECT_EQ(labels[i], label);
std::cout << "row:" << i++ << "\tlabel:" << label << "\n"; MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 5); EXPECT_TRUE(i == 5);
@ -470,7 +480,8 @@ TEST_F(MindDataTestImageFolderSampler, TestImageFolderSharding2) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
EXPECT_EQ(labels[i], label); EXPECT_EQ(labels[i], label);
std::cout << "row:" << i++ << "\tlabel:" << label << "\n"; MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 11); EXPECT_TRUE(i == 11);

View File

@ -76,7 +76,8 @@ TEST_F(MindDataTestManifest, TestSequentialManifestWithRepeat) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {}); tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
EXPECT_TRUE(res[i] == label); EXPECT_TRUE(res[i] == label);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 4); EXPECT_TRUE(i == 4);
@ -134,7 +135,8 @@ TEST_F(MindDataTestManifest, MindDataTestManifestClassIndex) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {}); tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
EXPECT_TRUE(label == res[i]); EXPECT_TRUE(label == res[i]);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 2); EXPECT_TRUE(i == 2);
@ -159,7 +161,8 @@ TEST_F(MindDataTestManifest, MindDataTestManifestNumSamples) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {}); tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
EXPECT_TRUE(0 == label); EXPECT_TRUE(0 == label);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 4); EXPECT_TRUE(i == 4);
@ -184,7 +187,8 @@ TEST_F(MindDataTestManifest, MindDataTestManifestEval) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {}); tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
EXPECT_TRUE(0 == label); EXPECT_TRUE(0 == label);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 1); EXPECT_TRUE(i == 1);

View File

@ -697,7 +697,7 @@ TEST_F(MindDataTestMapOp, ImageFolder_Decode_Repeat_Resize) {
std::string result; std::string result;
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
std::cout << "row:" << i << "\tlabel:" << label << "\n"; MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
EXPECT_TRUE(img_class[(i % 44) / 11] == label); EXPECT_TRUE(img_class[(i % 44) / 11] == label);
// Dump all the image into string, to be used as a comparison later. // Dump all the image into string, to be used as a comparison later.
result.append((char *) tensor_map["image"]->StartAddr(), (int64_t) tensor_map["image"]->Size()); result.append((char *) tensor_map["image"]->StartAddr(), (int64_t) tensor_map["image"]->Size());
@ -743,7 +743,7 @@ TEST_F(MindDataTestMapOp, ImageFolder_Decode_Repeat_Resize) {
std::string result2; std::string result2;
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<int32_t>(&label, {}); tensor_map["label"]->GetItemAt<int32_t>(&label, {});
std::cout << "row:" << i << "\tlabel:" << label << "\n"; MS_LOG(DEBUG) << "row:" << i << "\tlabel:" << label << "\n";
EXPECT_TRUE(img_class[(i % 44) / 11] == label); EXPECT_TRUE(img_class[(i % 44) / 11] == label);
result2.append((char *) tensor_map["image"]->StartAddr(), (int64_t) tensor_map["image"]->Size()); result2.append((char *) tensor_map["image"]->StartAddr(), (int64_t) tensor_map["image"]->Size());
di2.GetNextAsMap(&tensor_map); di2.GetNextAsMap(&tensor_map);

View File

@ -35,7 +35,7 @@ class MindDataTestMemoryPool : public UT::Common {
}; };
TEST_F(MindDataTestMemoryPool, DumpPoolInfo) { TEST_F(MindDataTestMemoryPool, DumpPoolInfo) {
std::cout << *(std::dynamic_pointer_cast<CircularPool>(mp_)) << std::endl; MS_LOG(DEBUG) << *(std::dynamic_pointer_cast<CircularPool>(mp_)) << std::endl;
} }
TEST_F(MindDataTestMemoryPool, TestOperator1) { TEST_F(MindDataTestMemoryPool, TestOperator1) {
@ -72,5 +72,5 @@ TEST_F(MindDataTestMemoryPool, TestAllocator) {
std::shared_ptr<A> obj_a = std::allocate_shared<A>(alloc, 3); std::shared_ptr<A> obj_a = std::allocate_shared<A>(alloc, 3);
int v = obj_a->val_a(); int v = obj_a->val_a();
ASSERT_EQ(v, 3); ASSERT_EQ(v, 3);
std::cout << *(std::dynamic_pointer_cast<CircularPool>(mp_)) << std::endl; MS_LOG(DEBUG) << *(std::dynamic_pointer_cast<CircularPool>(mp_)) << std::endl;
} }

View File

@ -69,7 +69,7 @@ TEST_F(MindDataTestMindRecordOp, TestMindRecordBasic) {
rc = builder.Build(&my_mindrecord_op); rc = builder.Build(&my_mindrecord_op);
ASSERT_TRUE(rc.IsOk()); ASSERT_TRUE(rc.IsOk());
std::cout << (*my_mindrecord_op); MS_LOG(DEBUG) << (*my_mindrecord_op);
my_tree->AssociateNode(my_mindrecord_op); my_tree->AssociateNode(my_mindrecord_op);
@ -140,7 +140,7 @@ TEST_F(MindDataTestMindRecordOp, TestMindRecordSample) {
rc = builder.Build(&my_mindrecord_op); rc = builder.Build(&my_mindrecord_op);
ASSERT_TRUE(rc.IsOk()); ASSERT_TRUE(rc.IsOk());
std::cout << (*my_mindrecord_op); MS_LOG(DEBUG) << (*my_mindrecord_op);
my_tree->AssociateNode(my_mindrecord_op); my_tree->AssociateNode(my_mindrecord_op);
@ -211,7 +211,7 @@ TEST_F(MindDataTestMindRecordOp, TestMindRecordShuffle) {
rc = builder.Build(&my_mindrecord_op); rc = builder.Build(&my_mindrecord_op);
ASSERT_TRUE(rc.IsOk()); ASSERT_TRUE(rc.IsOk());
std::cout << (*my_mindrecord_op); MS_LOG(DEBUG) << (*my_mindrecord_op);
my_tree->AssociateNode(my_mindrecord_op); my_tree->AssociateNode(my_mindrecord_op);
@ -285,7 +285,7 @@ TEST_F(MindDataTestMindRecordOp, TestMindRecordCategory) {
rc = builder.Build(&my_mindrecord_op); rc = builder.Build(&my_mindrecord_op);
ASSERT_TRUE(rc.IsOk()); ASSERT_TRUE(rc.IsOk());
std::cout << (*my_mindrecord_op); MS_LOG(DEBUG) << (*my_mindrecord_op);
my_tree->AssociateNode(my_mindrecord_op); my_tree->AssociateNode(my_mindrecord_op);
@ -352,7 +352,7 @@ TEST_F(MindDataTestMindRecordOp, TestMindRecordRepeat) {
rc = builder.Build(&my_mindrecord_op); rc = builder.Build(&my_mindrecord_op);
ASSERT_TRUE(rc.IsOk()); ASSERT_TRUE(rc.IsOk());
std::cout << (*my_mindrecord_op); MS_LOG(DEBUG) << (*my_mindrecord_op);
rc = my_tree->AssociateNode(my_mindrecord_op); rc = my_tree->AssociateNode(my_mindrecord_op);
EXPECT_TRUE(rc.IsOk()); EXPECT_TRUE(rc.IsOk());
@ -434,7 +434,7 @@ TEST_F(MindDataTestMindRecordOp, TestMindRecordBlockReaderRepeat) {
rc = builder.Build(&my_mindrecord_op); rc = builder.Build(&my_mindrecord_op);
ASSERT_TRUE(rc.IsOk()); ASSERT_TRUE(rc.IsOk());
std::cout << (*my_mindrecord_op); MS_LOG(DEBUG) << (*my_mindrecord_op);
rc = my_tree->AssociateNode(my_mindrecord_op); rc = my_tree->AssociateNode(my_mindrecord_op);
EXPECT_TRUE(rc.IsOk()); EXPECT_TRUE(rc.IsOk());

View File

@ -91,7 +91,8 @@ TEST_F(MindDataTestMnistSampler, TestSequentialMnistWithRepeat) {
while (tensor_map.size() != 0) { while (tensor_map.size() != 0) {
tensor_map["label"]->GetItemAt<uint32_t>(&label, {}); tensor_map["label"]->GetItemAt<uint32_t>(&label, {});
EXPECT_TRUE(res[i % 10] == label); EXPECT_TRUE(res[i % 10] == label);
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << label << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 20); EXPECT_TRUE(i == 20);
@ -120,7 +121,8 @@ TEST_F(MindDataTestMnistSampler, TestSequentialImageFolderWithRepeatBatch) {
std::shared_ptr<Tensor> label; std::shared_ptr<Tensor> label;
Create1DTensor(&label, 5, reinterpret_cast<unsigned char *>(res[i % 4])); Create1DTensor(&label, 5, reinterpret_cast<unsigned char *>(res[i % 4]));
EXPECT_TRUE((*label) == (*tensor_map["label"])); EXPECT_TRUE((*label) == (*tensor_map["label"]));
std::cout << "row: " << i++ << "\t" << tensor_map["image"]->shape() << "label:" << *tensor_map["label"] << "\n"; MS_LOG(DEBUG) << "row: " << i << "\t" << tensor_map["image"]->shape() << "label:" << *tensor_map["label"] << "\n";
i++;
di.GetNextAsMap(&tensor_map); di.GetNextAsMap(&tensor_map);
} }
EXPECT_TRUE(i == 4); EXPECT_TRUE(i == 4);

View File

@ -51,7 +51,7 @@ TEST_F(MindDataTestNormalizeOP, TestOp) {
cv::Mat cv_output_image; cv::Mat cv_output_image;
cv_output_image = p->mat(); cv_output_image = p->mat();
std::cout << "Storing output file to : " << output_filename << std::endl; MS_LOG(DEBUG) << "Storing output file to : " << output_filename << std::endl;
cv::FileStorage file(output_filename, cv::FileStorage::WRITE); cv::FileStorage file(output_filename, cv::FileStorage::WRITE);
file << "imageData" << cv_output_image; file << "imageData" << cv_output_image;
} }

View File

@ -47,8 +47,8 @@ TEST_F(MindDataTestOneHotOp, TestOp) {
EXPECT_TRUE(s.IsOk()); EXPECT_TRUE(s.IsOk());
ASSERT_TRUE(output->shape() == expected->shape()); ASSERT_TRUE(output->shape() == expected->shape());
ASSERT_TRUE(output->type() == expected->type()); ASSERT_TRUE(output->type() == expected->type());
std::cout << *output << std::endl; MS_LOG(DEBUG) << *output << std::endl;
std::cout << *expected << std::endl; MS_LOG(DEBUG) << *expected << std::endl;
ASSERT_TRUE(*output == *expected); ASSERT_TRUE(*output == *expected);
MS_LOG(INFO) << "MindDataTestOneHotOp end."; MS_LOG(INFO) << "MindDataTestOneHotOp end.";

View File

@ -38,7 +38,7 @@ TEST_F(MindDataTestPath, Test1) {
int i = 0; int i = 0;
while (dir_it->hasNext()) { while (dir_it->hasNext()) {
Path v = dir_it->next(); Path v = dir_it->next();
std::cout << v.toString() << "\n"; MS_LOG(DEBUG) << v.toString() << "\n";
i++; i++;
if (i == 10) { if (i == 10) {
break; break;
@ -46,7 +46,7 @@ TEST_F(MindDataTestPath, Test1) {
} }
// Test extension. // Test extension.
Path g("file.jpeg"); Path g("file.jpeg");
std::cout << g.Extension() << "\n"; MS_LOG(DEBUG) << g.Extension() << "\n";
ASSERT_EQ(g.Extension(), ".jpeg"); ASSERT_EQ(g.Extension(), ".jpeg");
} }

View File

@ -44,7 +44,7 @@ class RefCount {
explicit RefCount(int x) : v_(std::make_shared<int>(x)) {} explicit RefCount(int x) : v_(std::make_shared<int>(x)) {}
explicit RefCount(const RefCount &o) : v_(o.v_) {} explicit RefCount(const RefCount &o) : v_(o.v_) {}
~RefCount() { ~RefCount() {
std::cout << "Destructor of RefCount called" << std::endl; MS_LOG(DEBUG) << "Destructor of RefCount called" << std::endl;
gRefCountDestructorCalled++; gRefCountDestructorCalled++;
} }
RefCount& operator=(const RefCount &o) { RefCount& operator=(const RefCount &o) {

View File

@ -78,7 +78,7 @@ TEST_F(MindDataTestRandomCropDecodeResizeOp, TestOp2) {
} else { } else {
mse = mse_sum; mse = mse_sum;
} }
std::cout << "mse: " << mse << std::endl; MS_LOG(DEBUG) << "mse: " << mse << std::endl;
} }
MS_LOG(INFO) << "MindDataTestRandomCropDecodeResizeOp end!"; MS_LOG(INFO) << "MindDataTestRandomCropDecodeResizeOp end!";
} }
@ -150,7 +150,7 @@ TEST_F(MindDataTestRandomCropDecodeResizeOp, TestOp1) {
} }
mse = (count == 0) ? mse_sum : static_cast<float>(mse_sum) / count; mse = (count == 0) ? mse_sum : static_cast<float>(mse_sum) / count;
std::cout << "mse: " << mse << std::endl; MS_LOG(DEBUG) << "mse: " << mse << std::endl;
} }
MS_LOG(INFO) << "MindDataTestRandomCropDecodeResizeOp end!"; MS_LOG(INFO) << "MindDataTestRandomCropDecodeResizeOp end!";
} }

View File

@ -78,7 +78,7 @@ TEST_F(MindDataTestStandAloneSampler, TestDistributedSampler) {
sampler->Init(&mock); sampler->Init(&mock);
sampler->GetNextBuffer(&db); sampler->GetNextBuffer(&db);
db->GetTensor(&tensor, 0, 0); db->GetTensor(&tensor, 0, 0);
std::cout << (*tensor); MS_LOG(DEBUG) << (*tensor);
if(i < 3) { // This is added due to std::shuffle() if(i < 3) { // This is added due to std::shuffle()
EXPECT_TRUE((*tensor) == (*row[i])); EXPECT_TRUE((*tensor) == (*row[i]));
} }

View File

@ -43,19 +43,19 @@ TEST_F(MindDataTestStatus, Test1) {
Status rc; Status rc;
ASSERT_TRUE(rc.IsOk()); ASSERT_TRUE(rc.IsOk());
Status err1(StatusCode::kOutOfMemory, __LINE__, __FILE__); Status err1(StatusCode::kOutOfMemory, __LINE__, __FILE__);
std::cout << err1; MS_LOG(DEBUG) << err1;
ASSERT_TRUE(err1.IsOutofMemory()); ASSERT_TRUE(err1.IsOutofMemory());
ASSERT_TRUE(err1.IsError()); ASSERT_TRUE(err1.IsError());
Status err2(StatusCode::kUnexpectedError, __LINE__, __FILE__, "Oops"); Status err2(StatusCode::kUnexpectedError, __LINE__, __FILE__, "Oops");
std::cout << err2; MS_LOG(DEBUG) << err2;
} }
TEST_F(MindDataTestStatus, Test2) { TEST_F(MindDataTestStatus, Test2) {
Status rc = f1(); Status rc = f1();
std::cout << rc; MS_LOG(DEBUG) << rc;
} }
TEST_F(MindDataTestStatus, Test3) { TEST_F(MindDataTestStatus, Test3) {
Status rc = f3(); Status rc = f3();
std::cout << rc; MS_LOG(DEBUG) << rc;
} }

View File

@ -36,7 +36,7 @@ Status f(TaskGroup &vg){
RETURN_IF_NOT_OK(vg.CreateAsyncTask("Infinity", [&]() -> Status { RETURN_IF_NOT_OK(vg.CreateAsyncTask("Infinity", [&]() -> Status {
TaskManager::FindMe()->Post(); TaskManager::FindMe()->Post();
int a = v.fetch_add(1); int a = v.fetch_add(1);
std::cout << a << std::endl; MS_LOG(DEBUG) << a << std::endl;
return f(vg); return f(vg);
})); }));
} }

View File

@ -311,7 +311,7 @@ TEST_F(MindDataTestTensorDE, CVTensorAs) {
m = 2 * m; m = 2 * m;
ASSERT_EQ(ctv->StartAddr(), addr); ASSERT_EQ(ctv->StartAddr(), addr);
ASSERT_TRUE(*t2 == *ctv); ASSERT_TRUE(*t2 == *ctv);
std::cout << *t2 << std::endl << *ctv; MS_LOG(DEBUG) << *t2 << std::endl << *ctv;
} }
TEST_F(MindDataTestTensorDE, CVTensorMatSlice) { TEST_F(MindDataTestTensorDE, CVTensorMatSlice) {

View File

@ -54,7 +54,7 @@ void testCast(std::vector<FROM> values, const DataType &from, const DataType &to
EXPECT_TRUE(op->Compute(t, &output)); EXPECT_TRUE(op->Compute(t, &output));
ASSERT_TRUE(t->shape() == output->shape()); ASSERT_TRUE(t->shape() == output->shape());
ASSERT_TRUE(DataType(to)==output->type()); ASSERT_TRUE(DataType(to)==output->type());
std::cout << *output << std::endl; MS_LOG(DEBUG) << *output << std::endl;
auto out = output->begin<TO>(); auto out = output->begin<TO>();
auto v = values.begin(); auto v = values.begin();
for (; out != output->end<TO>(); out++, v++) { for (; out != output->end<TO>(); out++, v++) {

View File

@ -58,7 +58,8 @@ TEST_F(TestShardOperator, TestShardSampleBasic) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]); MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]);
i++;
} }
dataset.Finish(); dataset.Finish();
ASSERT_TRUE(i <= kSampleCount); ASSERT_TRUE(i <= kSampleCount);
@ -83,7 +84,8 @@ TEST_F(TestShardOperator, TestShardSampleWrongNumber) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]); MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]);
i++;
} }
dataset.Finish(); dataset.Finish();
ASSERT_TRUE(i <= 5); ASSERT_TRUE(i <= 5);
@ -108,7 +110,8 @@ TEST_F(TestShardOperator, TestShardSampleRatio) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]); MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]);
i++;
} }
dataset.Finish(); dataset.Finish();
ASSERT_TRUE(i <= 10); ASSERT_TRUE(i <= 10);
@ -137,7 +140,8 @@ TEST_F(TestShardOperator, TestShardSamplePartition) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]); MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]);
i++;
} }
dataset.Finish(); dataset.Finish();
ASSERT_TRUE(i <= 10); ASSERT_TRUE(i <= 10);
@ -166,8 +170,9 @@ TEST_F(TestShardOperator, TestShardCategory) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second); ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second);
@ -194,8 +199,9 @@ TEST_F(TestShardOperator, TestShardShuffle) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
} }
dataset.Finish(); dataset.Finish();
} }
@ -218,8 +224,9 @@ TEST_F(TestShardOperator, TestShardSampleShuffle) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
} }
dataset.Finish(); dataset.Finish();
ASSERT_LE(i, 35); ASSERT_LE(i, 35);
@ -244,8 +251,9 @@ TEST_F(TestShardOperator, TestShardShuffleSample) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
} }
dataset.Finish(); dataset.Finish();
ASSERT_TRUE(i <= kSampleSize); ASSERT_TRUE(i <= kSampleSize);
@ -270,8 +278,9 @@ TEST_F(TestShardOperator, TestShardSampleShuffleSample) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
} }
dataset.Finish(); dataset.Finish();
ASSERT_LE(i, 35); ASSERT_LE(i, 35);
@ -298,8 +307,9 @@ TEST_F(TestShardOperator, TestShardShuffleCompare) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
auto y = compare_dataset.GetNext(); auto y = compare_dataset.GetNext();
if ((std::get<1>(x[0]))["file_name"] != (std::get<1>(y[0]))["file_name"]) different = true; if ((std::get<1>(x[0]))["file_name"] != (std::get<1>(y[0]))["file_name"]) different = true;
@ -332,8 +342,9 @@ TEST_F(TestShardOperator, TestShardCategoryShuffle1) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second); ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second);
category_no++; category_no++;
@ -365,8 +376,9 @@ TEST_F(TestShardOperator, TestShardCategoryShuffle2) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second); ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second);
category_no++; category_no++;
category_no %= static_cast<int>(categories.size()); category_no %= static_cast<int>(categories.size());
@ -398,8 +410,9 @@ TEST_F(TestShardOperator, TestShardCategorySample) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second); ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second);
category_no++; category_no++;
@ -435,8 +448,9 @@ TEST_F(TestShardOperator, TestShardCategorySampleShuffle) {
while (true) { while (true) {
auto x = dataset.GetNext(); auto x = dataset.GetNext();
if (x.empty()) break; if (x.empty()) break;
MS_LOG(INFO) << "index: " << i++ << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) << MS_LOG(INFO) << "index: " << i << ", filename: " << common::SafeCStr((std::get<1>(x[0]))["file_name"]) <<
", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump()); ", label: " << common::SafeCStr((std::get<1>(x[0]))["label"].dump());
i++;
ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second); ASSERT_TRUE((std::get<1>(x[0]))["label"] == categories[category_no].second);
category_no++; category_no++;

View File

@ -28,6 +28,7 @@ cd ${BUILD_PATH}/mindspore/tests/ut/cpp
export LD_LIBRARY_PATH=${BUILD_PATH}/mindspore/googletest/googlemock/gtest:${PROJECT_PATH}/mindspore:${PROJECT_PATH}/mindspore/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${BUILD_PATH}/mindspore/googletest/googlemock/gtest:${PROJECT_PATH}/mindspore:${PROJECT_PATH}/mindspore/lib:$LD_LIBRARY_PATH
export PYTHONPATH=${PROJECT_PATH}/tests/ut/cpp/python_input:$PYTHONPATH:${PROJECT_PATH} export PYTHONPATH=${PROJECT_PATH}/tests/ut/cpp/python_input:$PYTHONPATH:${PROJECT_PATH}
export GLOG_v=2
## prepare data for dataset & mindrecord ## prepare data for dataset & mindrecord
cp -fr $PROJECT_PATH/tests/ut/data ${PROJECT_PATH}/build/mindspore/tests/ut/cpp/ cp -fr $PROJECT_PATH/tests/ut/data ${PROJECT_PATH}/build/mindspore/tests/ut/cpp/