!14106 reduce ut time of cutmix_batch and ConcatOp

From: @luoyang42
Reviewed-by: @pandoublefeng,@liucunwei
Signed-off-by: @pandoublefeng,@liucunwei
This commit is contained in:
mindspore-ci-bot 2021-03-25 22:58:35 +08:00 committed by Gitee
commit a91e9c9294
2 changed files with 13 additions and 7 deletions

View File

@ -53,7 +53,7 @@ TEST_F(MindDataTestConcatOp, TestConcatProject) {
TFReaderOp::Builder builder1;
builder1.SetDatasetFilesList({dataset_path}).SetRowsPerBuffer(16).SetWorkerConnectorSize(16);
std::unique_ptr<DataSchema> schema1 = std::make_unique<DataSchema>();
schema1->LoadSchemaFile(datasets_root_path_ + "/testTFTestAllTypes/datasetSchema.json", {});
schema1->LoadSchemaFile(datasets_root_path_ + "/testTFTestAllTypes/datasetSchema1Row.json", {});
builder1.SetDataSchema(std::move(schema1));
Status rc = builder1.Build(&my_tfreader_op1);
ASSERT_TRUE(rc.IsOk());
@ -65,7 +65,7 @@ TEST_F(MindDataTestConcatOp, TestConcatProject) {
TFReaderOp::Builder builder2;
builder2.SetDatasetFilesList({dataset_path}).SetRowsPerBuffer(16).SetWorkerConnectorSize(16);
std::unique_ptr<DataSchema> schema2 = std::make_unique<DataSchema>();
schema2->LoadSchemaFile(datasets_root_path_ + "/testTFTestAllTypes/datasetSchema.json", {});
schema2->LoadSchemaFile(datasets_root_path_ + "/testTFTestAllTypes/datasetSchema1Row.json", {});
builder2.SetDataSchema(std::move(schema2));
rc = builder2.Build(&my_tfreader_op2);
ASSERT_TRUE(rc.IsOk());
@ -115,5 +115,5 @@ TEST_F(MindDataTestConcatOp, TestConcatProject) {
EXPECT_TRUE(rc.IsOk());
row_count++;
}
ASSERT_EQ(row_count, 24); // Should be 24 rows fetched
ASSERT_EQ(row_count, 2); // Should be 2 rows fetched
}

View File

@ -30,12 +30,15 @@ class MindDataTestCutMixBatchOp : public UT::CVOP::CVOpCommon {
TEST_F(MindDataTestCutMixBatchOp, TestSuccess1) {
MS_LOG(INFO) << "Doing MindDataTestCutMixBatchOp success1 case";
std::shared_ptr<Tensor> input_tensor_resized;
std::shared_ptr<Tensor> batched_tensor;
std::shared_ptr<Tensor> batched_labels;
Tensor::CreateEmpty(TensorShape({2, input_tensor_->shape()[0], input_tensor_->shape()[1], input_tensor_->shape()[2]}),
input_tensor_->type(), &batched_tensor);
Resize(input_tensor_, &input_tensor_resized, 227, 403);
Tensor::CreateEmpty(TensorShape({2, input_tensor_resized->shape()[0], input_tensor_resized->shape()[1],
input_tensor_resized->shape()[2]}), input_tensor_resized->type(), &batched_tensor);
for (int i = 0; i < 2; i++) {
batched_tensor->InsertTensor({i}, input_tensor_);
batched_tensor->InsertTensor({i}, input_tensor_resized);
}
Tensor::CreateFromVector(std::vector<uint32_t>({0, 1, 1, 0}), TensorShape({2, 2}), &batched_labels);
std::shared_ptr<CutMixBatchOp> op = std::make_shared<CutMixBatchOp>(ImageBatchFormat::kNHWC, 1.0, 1.0);
@ -56,10 +59,13 @@ TEST_F(MindDataTestCutMixBatchOp, TestSuccess1) {
TEST_F(MindDataTestCutMixBatchOp, TestSuccess2) {
MS_LOG(INFO) << "Doing MindDataTestCutMixBatchOp success2 case";
std::shared_ptr<Tensor> input_tensor_resized;
std::shared_ptr<Tensor> batched_tensor;
std::shared_ptr<Tensor> batched_labels;
std::shared_ptr<Tensor> chw_tensor;
ASSERT_TRUE(HwcToChw(input_tensor_, &chw_tensor).IsOk());
Resize(input_tensor_, &input_tensor_resized, 227, 403);
ASSERT_TRUE(HwcToChw(input_tensor_resized, &chw_tensor).IsOk());
Tensor::CreateEmpty(TensorShape({2, chw_tensor->shape()[0], chw_tensor->shape()[1], chw_tensor->shape()[2]}),
chw_tensor->type(), &batched_tensor);
for (int i = 0; i < 2; i++) {