forked from mindspore-Ecosystem/mindspore
!12895 [MD] C++ testcases cleanup: for random tensor ops and transforms ops
From: @tina_mengting_zhang Reviewed-by: @mikef,@robingrosman Signed-off-by: @robingrosman
This commit is contained in:
commit
569e679c66
|
@ -12,7 +12,6 @@ SET(DE_UT_SRCS
|
|||
btree_test.cc
|
||||
buddy_test.cc
|
||||
build_vocab_test.cc
|
||||
c_api_affine_test.cc
|
||||
c_api_cache_test.cc
|
||||
c_api_dataset_album_test.cc
|
||||
c_api_dataset_cifar_test.cc
|
||||
|
@ -37,6 +36,7 @@ SET(DE_UT_SRCS
|
|||
c_api_text_vocab_test.cc
|
||||
c_api_transforms_test.cc
|
||||
c_api_vision_a_to_q_test.cc
|
||||
c_api_vision_affine_test.cc
|
||||
c_api_vision_bounding_box_augment_test.cc
|
||||
c_api_vision_random_subselect_policy_test.cc
|
||||
c_api_vision_random_test.cc
|
||||
|
@ -77,6 +77,7 @@ SET(DE_UT_SRCS
|
|||
ir_sampler_test.cc
|
||||
ir_tensor_op_fusion_pass_test.cc
|
||||
ir_tree_adapter_test.cc
|
||||
ir_vision_random_test.cc
|
||||
ir_vision_test.cc
|
||||
jieba_tokenizer_op_test.cc
|
||||
main_test.cc
|
||||
|
|
|
@ -57,18 +57,17 @@ TEST_F(MindDataTestPipeline, TestComposeSuccess) {
|
|||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
// auto image = row["image"];
|
||||
// auto label = row["label"];
|
||||
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
|
||||
// MS_LOG(INFO) << "Label shape: " << label->shape();
|
||||
// EXPECT_EQ(image->shape()[0], 777);
|
||||
// EXPECT_EQ(image->shape()[1], 777);
|
||||
auto image = row["image"];
|
||||
auto label = row["label"];
|
||||
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
MS_LOG(INFO) << "Label shape: " << label.Shape();
|
||||
EXPECT_EQ(image.Shape()[0], 777);
|
||||
EXPECT_EQ(image.Shape()[1], 777);
|
||||
iter->GetNextRow(&row);
|
||||
}
|
||||
|
||||
EXPECT_EQ(i, 3);
|
||||
|
||||
|
||||
// Manually terminate the pipeline
|
||||
iter->Stop();
|
||||
}
|
||||
|
@ -165,10 +164,12 @@ TEST_F(MindDataTestPipeline, TestDuplicateSuccess) {
|
|||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
// auto image = row["image"];
|
||||
// auto image_copy = row["image_copy"];
|
||||
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
|
||||
// EXPECT_EQ(*image, *image_copy);
|
||||
// FIXME
|
||||
// auto image = row["image"];
|
||||
// auto image_copy = row["image_copy"];
|
||||
// MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
// auto n = memcmp(&image, &image_copy, image.DataSize());
|
||||
// EXPECT_EQ(n, 0);
|
||||
iter->GetNextRow(&row);
|
||||
}
|
||||
|
||||
|
@ -179,6 +180,7 @@ TEST_F(MindDataTestPipeline, TestDuplicateSuccess) {
|
|||
}
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestOneHotSuccess1) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestOneHotSuccess1.";
|
||||
// Testing CutMixBatch on a batch of CHW images
|
||||
// Create a Cifar10 Dataset
|
||||
std::string folder_path = datasets_root_path_ + "/testCifar10Data/";
|
||||
|
@ -188,7 +190,6 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess1) {
|
|||
|
||||
// Create objects for the tensor ops
|
||||
std::shared_ptr<TensorTransform> hwc_to_chw = std::make_shared<vision::HWC2CHW>();
|
||||
EXPECT_NE(hwc_to_chw, nullptr);
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({hwc_to_chw}, {"image"});
|
||||
|
@ -201,7 +202,6 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess1) {
|
|||
|
||||
// Create objects for the tensor ops
|
||||
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(number_of_classes);
|
||||
EXPECT_NE(one_hot_op, nullptr);
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({one_hot_op}, {"label"});
|
||||
|
@ -209,7 +209,6 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess1) {
|
|||
|
||||
std::shared_ptr<TensorTransform> cutmix_batch_op =
|
||||
std::make_shared<vision::CutMixBatch>(mindspore::dataset::ImageBatchFormat::kNCHW, 1.0, 1.0);
|
||||
EXPECT_NE(cutmix_batch_op, nullptr);
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({cutmix_batch_op}, {"image", "label"});
|
||||
|
@ -227,16 +226,15 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess1) {
|
|||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
// auto image = row["image"];
|
||||
// auto label = row["label"];
|
||||
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
|
||||
// MS_LOG(INFO) << "Label shape: " << label->shape();
|
||||
// EXPECT_EQ(image->shape().AsVector().size() == 4 && batch_size == image->shape()[0] && 3 == image->shape()[1] &&
|
||||
// 32 == image->shape()[2] && 32 == image->shape()[3],
|
||||
// true);
|
||||
// EXPECT_EQ(label->shape().AsVector().size() == 2 && batch_size == label->shape()[0] &&
|
||||
// number_of_classes == label->shape()[1],
|
||||
// true);
|
||||
auto image = row["image"];
|
||||
auto label = row["label"];
|
||||
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
MS_LOG(INFO) << "Label shape: " << label.Shape();
|
||||
EXPECT_EQ(image.Shape().size() == 4 && batch_size == image.Shape()[0] && 3 == image.Shape()[1] &&
|
||||
32 == image.Shape()[2] && 32 == image.Shape()[3],
|
||||
true);
|
||||
EXPECT_EQ(label.Shape().size() == 2 && batch_size == label.Shape()[0] && number_of_classes == label.Shape()[1],
|
||||
true);
|
||||
iter->GetNextRow(&row);
|
||||
}
|
||||
|
||||
|
@ -247,6 +245,7 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess1) {
|
|||
}
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestOneHotSuccess2) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestOneHotSuccess2.";
|
||||
// Create a Cifar10 Dataset
|
||||
std::string folder_path = datasets_root_path_ + "/testCifar10Data/";
|
||||
std::shared_ptr<Dataset> ds = Cifar10(folder_path, "all", std::make_shared<RandomSampler>(false, 10));
|
||||
|
@ -259,14 +258,12 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess2) {
|
|||
|
||||
// Create objects for the tensor ops
|
||||
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(10);
|
||||
EXPECT_NE(one_hot_op, nullptr);
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({one_hot_op}, {"label"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
std::shared_ptr<TensorTransform> mixup_batch_op = std::make_shared<vision::MixUpBatch>(2.0);
|
||||
EXPECT_NE(mixup_batch_op, nullptr);
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({mixup_batch_op}, {"image", "label"});
|
||||
|
@ -284,8 +281,8 @@ TEST_F(MindDataTestPipeline, TestOneHotSuccess2) {
|
|||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
// auto image = row["image"];
|
||||
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
|
||||
auto image = row["image"];
|
||||
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
iter->GetNextRow(&row);
|
||||
}
|
||||
|
||||
|
@ -305,7 +302,6 @@ TEST_F(MindDataTestPipeline, TestOneHotFail1) {
|
|||
|
||||
// incorrect num_class
|
||||
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(0);
|
||||
EXPECT_NE(one_hot_op, nullptr);
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({one_hot_op}, {"label"});
|
||||
|
@ -326,7 +322,6 @@ TEST_F(MindDataTestPipeline, TestOneHotFail2) {
|
|||
|
||||
// incorrect num_class
|
||||
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(-5);
|
||||
EXPECT_NE(one_hot_op, nullptr);
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({one_hot_op}, {"label"});
|
||||
|
@ -365,10 +360,10 @@ TEST_F(MindDataTestPipeline, TestRandomApplySuccess) {
|
|||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
// auto image = row["image"];
|
||||
// auto label = row["label"];
|
||||
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
|
||||
// MS_LOG(INFO) << "Label shape: " << label->shape();
|
||||
auto image = row["image"];
|
||||
auto label = row["label"];
|
||||
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
MS_LOG(INFO) << "Label shape: " << label.Shape();
|
||||
iter->GetNextRow(&row);
|
||||
}
|
||||
|
||||
|
@ -590,17 +585,16 @@ TEST_F(MindDataTestPipeline, TestTypeCastSuccess) {
|
|||
iter->GetNextRow(&row);
|
||||
|
||||
// Check original data type of dataset
|
||||
// auto image = row["image"];
|
||||
// std::string ori_type = image->type().ToString();
|
||||
// MS_LOG(INFO) << "Original data type: " << ori_type;
|
||||
// EXPECT_NE(ori_type.c_str(), "uint8");
|
||||
auto image = row["image"];
|
||||
auto ori_type = image.DataType();
|
||||
MS_LOG(INFO) << "Original data type id: " << ori_type;
|
||||
EXPECT_EQ(ori_type, mindspore::DataType(mindspore::TypeId::kNumberTypeUInt8));
|
||||
|
||||
// Manually terminate the pipeline
|
||||
iter->Stop();
|
||||
|
||||
// Create objects for the tensor ops
|
||||
std::shared_ptr<TensorTransform> type_cast = std::make_shared<transforms::TypeCast>("uint16");
|
||||
EXPECT_NE(type_cast, nullptr);
|
||||
|
||||
// Create a Map operation on ds
|
||||
std::shared_ptr<Dataset> ds2 = ds->Map({type_cast}, {"image"});
|
||||
|
@ -613,10 +607,10 @@ TEST_F(MindDataTestPipeline, TestTypeCastSuccess) {
|
|||
|
||||
// Check current data type of dataset
|
||||
iter2->GetNextRow(&row);
|
||||
// auto image2 = row["image"];
|
||||
// std::string cur_type = image2->type().ToString();
|
||||
// MS_LOG(INFO) << "Current data type: " << cur_type;
|
||||
// EXPECT_NE(cur_type.c_str(), "uint16");
|
||||
auto image2 = row["image"];
|
||||
auto cur_type = image2.DataType();
|
||||
MS_LOG(INFO) << "Current data type id: " << cur_type;
|
||||
EXPECT_EQ(cur_type, mindspore::DataType(mindspore::TypeId::kNumberTypeUInt16));
|
||||
|
||||
// Manually terminate the pipeline
|
||||
iter2->Stop();
|
||||
|
@ -632,7 +626,6 @@ TEST_F(MindDataTestPipeline, TestTypeCastFail) {
|
|||
|
||||
// incorrect data type
|
||||
std::shared_ptr<TensorTransform> type_cast = std::make_shared<transforms::TypeCast>("char");
|
||||
EXPECT_NE(type_cast, nullptr);
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({type_cast}, {"image", "label"});
|
||||
|
|
|
@ -23,7 +23,7 @@ using mindspore::dataset::InterpolationMode;
|
|||
using mindspore::dataset::Tensor;
|
||||
|
||||
class MindDataTestPipeline : public UT::DatasetOpTesting {
|
||||
protected:
|
||||
protected:
|
||||
};
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestAffineAPI) {
|
||||
|
@ -94,4 +94,3 @@ TEST_F(MindDataTestPipeline, TestAffineAPIFail) {
|
|||
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
||||
EXPECT_EQ(iter, nullptr);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,242 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include "common/common.h"
|
||||
#include "minddata/dataset/kernels/ir/vision/vision_ir.h"
|
||||
|
||||
using namespace mindspore::dataset;
|
||||
|
||||
class MindDataTestIRVision : public UT::DatasetOpTesting {
|
||||
public:
|
||||
MindDataTestIRVision() = default;
|
||||
};
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomColorIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomColorIRFail.";
|
||||
|
||||
// Testing invalid lower bound > upper bound
|
||||
std::shared_ptr<TensorOperation> random_color1(new vision::RandomColorOperation(1.0, 0.1));
|
||||
Status rc1 = random_color1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid negative lower bound
|
||||
std::shared_ptr<TensorOperation> random_color2(new vision::RandomColorOperation(-0.5, 0.5));
|
||||
Status rc2 = random_color2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomColorAdjustIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomColorAdjustIRFail.";
|
||||
|
||||
// Testing invalid brightness out of range
|
||||
std::shared_ptr<TensorOperation> random_color_adjust1(
|
||||
new vision::RandomColorAdjustOperation({-1.0}, {0.0}, {0.0}, {0.0}));
|
||||
Status rc1 = random_color_adjust1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid contrast out of range
|
||||
std::shared_ptr<TensorOperation> random_color_adjust2(
|
||||
new vision::RandomColorAdjustOperation({1.0}, {-0.1}, {0.0}, {0.0}));
|
||||
Status rc2 = random_color_adjust2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
|
||||
// Testing invalid saturation out of range
|
||||
std::shared_ptr<TensorOperation> random_color_adjust3(
|
||||
new vision::RandomColorAdjustOperation({0.0}, {0.0}, {-0.2}, {0.0}));
|
||||
Status rc3 = random_color_adjust3->ValidateParams();
|
||||
EXPECT_ERROR(rc3);
|
||||
|
||||
// Testing invalid hue out of range
|
||||
std::shared_ptr<TensorOperation> random_color_adjust4(
|
||||
new vision::RandomColorAdjustOperation({0.0}, {0.0}, {0.0}, {-0.6}));
|
||||
Status rc4 = random_color_adjust4->ValidateParams();
|
||||
EXPECT_ERROR(rc4);
|
||||
|
||||
// Testing invalid hue out of range
|
||||
std::shared_ptr<TensorOperation> random_color_adjust5(
|
||||
new vision::RandomColorAdjustOperation({0.0}, {0.0}, {0.0}, {-0.5, 0.6}));
|
||||
Status rc5 = random_color_adjust5->ValidateParams();
|
||||
EXPECT_ERROR(rc5);
|
||||
|
||||
// Testing invalid hue
|
||||
std::shared_ptr<TensorOperation> random_color_adjust6(
|
||||
new vision::RandomColorAdjustOperation({0.0}, {0.0}, {0.0}, {0.51}));
|
||||
Status rc6 = random_color_adjust4->ValidateParams();
|
||||
EXPECT_ERROR(rc6);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomHorizontalFlipIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomHorizontalFlipIRFail.";
|
||||
|
||||
// Testing invalid negative input
|
||||
std::shared_ptr<TensorOperation> random_horizontal_flip1(new vision::RandomHorizontalFlipOperation(-0.5));
|
||||
Status rc1 = random_horizontal_flip1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid >1 input
|
||||
std::shared_ptr<TensorOperation> random_horizontal_flip2(new vision::RandomHorizontalFlipOperation(2));
|
||||
Status rc2 = random_horizontal_flip2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomHorizontalFlipWithBBoxIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomHorizontalFlipWithBBoxIRFail.";
|
||||
|
||||
// Testing invalid negative input
|
||||
std::shared_ptr<TensorOperation> random_horizontal_flip_bbox1(
|
||||
new vision::RandomHorizontalFlipWithBBoxOperation(-1.0));
|
||||
Status rc1 = random_horizontal_flip_bbox1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid >1 input
|
||||
std::shared_ptr<TensorOperation> random_horizontal_flip_bbox2(new vision::RandomHorizontalFlipWithBBoxOperation(2.0));
|
||||
Status rc2 = random_horizontal_flip_bbox2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomPosterizeIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomPosterizeIRFail.";
|
||||
|
||||
// Testing invalid max > 8
|
||||
std::shared_ptr<TensorOperation> random_posterize1(new vision::RandomPosterizeOperation({1, 9}));
|
||||
Status rc1 = random_posterize1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid min < 1
|
||||
std::shared_ptr<TensorOperation> random_posterize2(new vision::RandomPosterizeOperation({0, 8}));
|
||||
Status rc2 = random_posterize2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
|
||||
// Testing invalid min > max
|
||||
std::shared_ptr<TensorOperation> random_posterize3(new vision::RandomPosterizeOperation({8, 1}));
|
||||
Status rc3 = random_posterize3->ValidateParams();
|
||||
EXPECT_ERROR(rc3);
|
||||
|
||||
// Testing invalid empty input
|
||||
std::shared_ptr<TensorOperation> random_posterize4(new vision::RandomPosterizeOperation({}));
|
||||
Status rc4 = random_posterize4->ValidateParams();
|
||||
EXPECT_ERROR(rc4);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomResizeIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomResizeIRFail.";
|
||||
|
||||
// Testing invalid: size must only contain positive integers
|
||||
std::shared_ptr<TensorOperation> random_resize1(new vision::RandomResizeOperation({-66, 77}));
|
||||
Status rc1 = random_resize1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid: size must only contain positive integers
|
||||
std::shared_ptr<TensorOperation> random_resize2(new vision::RandomResizeOperation({0, 77}));
|
||||
Status rc2 = random_resize2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
|
||||
// Testing invalid: size must be a vector of one or two values
|
||||
std::shared_ptr<TensorOperation> random_resize3(new vision::RandomResizeOperation({1, 2, 3}));
|
||||
Status rc3 = random_resize3->ValidateParams();
|
||||
EXPECT_ERROR(rc3);
|
||||
|
||||
// Testing invalid: size must be a vector of one or two values
|
||||
std::shared_ptr<TensorOperation> random_resize4(new vision::RandomResizeOperation({}));
|
||||
Status rc4 = random_resize4->ValidateParams();
|
||||
EXPECT_ERROR(rc4);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomResizeWithBBoxIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomResizeWithBBoxIRFail.";
|
||||
|
||||
// Testing invalid: size must only contain positive integers
|
||||
std::shared_ptr<TensorOperation> random_resize_with_bbox1(new vision::RandomResizeWithBBoxOperation({-66, 77}));
|
||||
Status rc1 = random_resize_with_bbox1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid: size must be a vector of one or two values
|
||||
std::shared_ptr<TensorOperation> random_resize_with_bbox2(new vision::RandomResizeWithBBoxOperation({1, 2, 3}));
|
||||
Status rc2 = random_resize_with_bbox2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
|
||||
// Testing invalid: size must be a vector of one or two values
|
||||
std::shared_ptr<TensorOperation> random_resize_with_bbox3(new vision::RandomResizeWithBBoxOperation({}));
|
||||
Status rc3 = random_resize_with_bbox3->ValidateParams();
|
||||
EXPECT_ERROR(rc3);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomSharpnessIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomSharpnessIRFail.";
|
||||
|
||||
// Testing invalid empty degrees vector
|
||||
std::shared_ptr<TensorOperation> random_sharpness1(new vision::RandomSharpnessOperation({}));
|
||||
Status rc1 = random_sharpness1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid single degree value
|
||||
std::shared_ptr<TensorOperation> random_sharpness2(new vision::RandomSharpnessOperation({0.1}));
|
||||
Status rc2 = random_sharpness2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomSolarizeIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomSolarizeIRFail.";
|
||||
|
||||
// Testing invalid lower bound > upper bound
|
||||
std::shared_ptr<TensorOperation> random_solarize1(new vision::RandomSolarizeOperation({13, 1}));
|
||||
Status rc1 = random_solarize1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid threshold must be a vector of two values
|
||||
std::shared_ptr<TensorOperation> random_solarize2(new vision::RandomSolarizeOperation({1, 2, 3}));
|
||||
Status rc2 = random_solarize2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
|
||||
// Testing invalid threshold must be a vector of two values
|
||||
std::shared_ptr<TensorOperation> random_solarize3(new vision::RandomSolarizeOperation({1}));
|
||||
Status rc3 = random_solarize3->ValidateParams();
|
||||
EXPECT_ERROR(rc3);
|
||||
|
||||
// Testing invalid empty threshold
|
||||
std::shared_ptr<TensorOperation> random_solarize4(new vision::RandomSolarizeOperation({}));
|
||||
Status rc4 = random_solarize4->ValidateParams();
|
||||
EXPECT_ERROR(rc4);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomVerticalFlipIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomVerticalFlipIRFail.";
|
||||
|
||||
// Testing invalid negative input
|
||||
std::shared_ptr<TensorOperation> random_vertical_flip1(new vision::RandomVerticalFlipOperation(-0.5));
|
||||
Status rc1 = random_vertical_flip1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid >1 input
|
||||
std::shared_ptr<TensorOperation> random_vertical_flip2(new vision::RandomVerticalFlipOperation(1.1));
|
||||
Status rc2 = random_vertical_flip2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestIRVision, TestRandomVerticalFlipWithBBoxIRFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestIRVision-TestRandomVerticalFlipWithBBoxIRFail.";
|
||||
|
||||
// Testing invalid negative input
|
||||
std::shared_ptr<TensorOperation> random_vertical_flip1(new vision::RandomVerticalFlipWithBBoxOperation(-0.5));
|
||||
Status rc1 = random_vertical_flip1->ValidateParams();
|
||||
EXPECT_ERROR(rc1);
|
||||
|
||||
// Testing invalid >1 input
|
||||
std::shared_ptr<TensorOperation> random_vertical_flip2(new vision::RandomVerticalFlipWithBBoxOperation(3.0));
|
||||
Status rc2 = random_vertical_flip2->ValidateParams();
|
||||
EXPECT_ERROR(rc2);
|
||||
}
|
Loading…
Reference in New Issue