Enable kernel tests for ios.

PiperOrigin-RevId: 227727388
This commit is contained in:
Karim Nosir 2019-01-03 12:07:50 -08:00 committed by TensorFlower Gardener
parent e518527f10
commit 41c30afbfb
9 changed files with 39 additions and 165 deletions

View File

@ -2348,7 +2348,12 @@ cc_library(
cc_library(
name = "tflite_portable_logging",
srcs = [],
srcs = [
] + if_ios([
"platform/default/logging.cc",
"platform/env_time.cc",
"platform/posix/env_time.cc",
]),
hdrs = [
"lib/bfloat16/bfloat16.h",
"platform/default/integral_types.h",
@ -2357,7 +2362,7 @@ cc_library(
"platform/macros.h",
"platform/platform.h",
"platform/types.h",
] + if_windows(["platform/windows/integral_types.h"]),
] + if_windows(["platform/windows/integral_types.h"]) + if_ios(["platform/env_time.h"]),
copts = tf_copts(),
linkopts = ["-ldl"],
deps = [

View File

@ -25,9 +25,6 @@ tf_cc_test(
name = "optional_tensor_test",
size = "small",
srcs = ["optional_tensor_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -122,9 +119,6 @@ tf_cc_test(
name = "kernel_util_test",
size = "small",
srcs = ["kernel_util_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":kernel_util",
"//tensorflow/lite/testing:util",
@ -136,9 +130,6 @@ tf_cc_test(
name = "test_util_test",
size = "small",
srcs = ["test_util_test.cc"],
tags = [
"tflite_not_portable_ios", # TODO(b/117786830)
],
deps = [
":test_util",
"//tensorflow/lite/testing:util",
@ -304,9 +295,6 @@ tf_cc_test(
name = "audio_spectrogram_test",
size = "small",
srcs = ["audio_spectrogram_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -320,9 +308,6 @@ tf_cc_test(
name = "mfcc_test",
size = "small",
srcs = ["mfcc_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -336,9 +321,6 @@ tf_cc_test(
name = "detection_postprocess_test",
size = "small",
srcs = ["detection_postprocess_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -352,9 +334,6 @@ tf_cc_test(
name = "relu1_test",
size = "small",
srcs = ["relu1_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -368,9 +347,6 @@ tf_cc_test(
name = "sparse_output_fully_connected_test",
size = "small",
srcs = ["sparse_output_fully_connected_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -384,7 +360,6 @@ tf_cc_test(
name = "activations_test",
size = "small",
srcs = ["activations_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -397,7 +372,6 @@ tf_cc_test(
name = "add_test",
size = "small",
srcs = ["add_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -410,9 +384,6 @@ tf_cc_test(
name = "arg_min_max_test",
size = "small",
srcs = ["arg_min_max_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -425,9 +396,6 @@ tf_cc_test(
name = "div_test",
size = "small",
srcs = ["div_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -440,9 +408,6 @@ tf_cc_test(
name = "sub_test",
size = "small",
srcs = ["sub_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -455,9 +420,6 @@ tf_cc_test(
name = "transpose_test",
size = "small",
srcs = ["transpose_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -472,9 +434,6 @@ tf_cc_test(
name = "space_to_batch_nd_test",
size = "small",
srcs = ["space_to_batch_nd_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -487,9 +446,6 @@ tf_cc_test(
name = "batch_to_space_nd_test",
size = "small",
srcs = ["batch_to_space_nd_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -502,9 +458,6 @@ tf_cc_test(
name = "cast_test",
size = "small",
srcs = ["cast_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -517,7 +470,6 @@ tf_cc_test(
name = "concatenation_test",
size = "small",
srcs = ["concatenation_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -530,7 +482,6 @@ tf_cc_test(
name = "conv_test",
size = "small",
srcs = ["conv_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -544,7 +495,6 @@ tf_cc_test(
name = "depthwise_conv_test",
size = "small",
srcs = ["depthwise_conv_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -558,9 +508,6 @@ tf_cc_test(
name = "dequantize_test",
size = "small",
srcs = ["dequantize_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -574,7 +521,6 @@ tf_cc_test(
name = "basic_rnn_test",
size = "small",
srcs = ["basic_rnn_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -587,9 +533,6 @@ tf_cc_test(
name = "bidirectional_sequence_lstm_test",
size = "small",
srcs = ["bidirectional_sequence_lstm_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -603,9 +546,6 @@ tf_cc_test(
name = "floor_test",
size = "small",
srcs = ["floor_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -618,9 +558,6 @@ tf_cc_test(
name = "elementwise_test",
size = "small",
srcs = ["elementwise_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -633,9 +570,6 @@ tf_cc_test(
name = "unidirectional_sequence_lstm_test",
size = "small",
srcs = ["unidirectional_sequence_lstm_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -663,9 +597,6 @@ tf_cc_test(
name = "unidirectional_sequence_rnn_test",
size = "small",
srcs = ["unidirectional_sequence_rnn_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -678,7 +609,6 @@ tf_cc_test(
name = "l2norm_test",
size = "small",
srcs = ["l2norm_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -691,9 +621,6 @@ tf_cc_test(
name = "exp_test",
size = "small",
srcs = ["exp_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -706,9 +633,6 @@ tf_cc_test(
name = "fake_quant_test",
size = "small",
srcs = ["fake_quant_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -721,9 +645,6 @@ tf_cc_test(
name = "maximum_minimum_test",
size = "small",
srcs = ["maximum_minimum_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -736,9 +657,6 @@ tf_cc_test(
name = "reduce_test",
size = "small",
srcs = ["reduce_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -751,7 +669,6 @@ tf_cc_test(
name = "mul_test",
size = "small",
srcs = ["mul_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -764,9 +681,6 @@ tf_cc_test(
name = "pad_test",
size = "small",
srcs = ["pad_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -779,7 +693,6 @@ tf_cc_test(
name = "reshape_test",
size = "small",
srcs = ["reshape_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -792,9 +705,6 @@ tf_cc_test(
name = "gather_test",
size = "small",
srcs = ["gather_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -808,9 +718,6 @@ tf_cc_test(
name = "topk_v2_test",
size = "small",
srcs = ["topk_v2_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -824,7 +731,6 @@ tf_cc_test(
name = "resize_bilinear_test",
size = "small",
srcs = ["resize_bilinear_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -837,7 +743,6 @@ tf_cc_test(
name = "resize_nearest_neighbor_test",
size = "small",
srcs = ["resize_nearest_neighbor_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -850,7 +755,6 @@ tf_cc_test(
name = "svdf_test",
size = "small",
srcs = ["svdf_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -863,7 +767,6 @@ tf_cc_test(
name = "embedding_lookup_test",
size = "small",
srcs = ["embedding_lookup_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -876,7 +779,6 @@ tf_cc_test(
name = "embedding_lookup_sparse_test",
size = "small",
srcs = ["embedding_lookup_sparse_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -889,7 +791,6 @@ tf_cc_test(
name = "fully_connected_test",
size = "small",
srcs = ["fully_connected_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -904,7 +805,6 @@ tf_cc_test(
name = "local_response_norm_test",
size = "small",
srcs = ["local_response_norm_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -917,7 +817,6 @@ tf_cc_test(
name = "pooling_test",
size = "small",
srcs = ["pooling_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -930,7 +829,6 @@ tf_cc_test(
name = "softmax_test",
size = "small",
srcs = ["softmax_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -944,9 +842,6 @@ tf_cc_test(
name = "log_softmax_test",
size = "small",
srcs = ["log_softmax_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -960,7 +855,6 @@ tf_cc_test(
name = "lsh_projection_test",
size = "small",
srcs = ["lsh_projection_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -973,7 +867,6 @@ tf_cc_test(
name = "hashtable_lookup_test",
size = "small",
srcs = ["hashtable_lookup_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -987,7 +880,6 @@ tf_cc_test(
name = "layer_norm_lstm_test",
size = "small",
srcs = ["layer_norm_lstm_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1001,7 +893,6 @@ tf_cc_test(
name = "lstm_test",
size = "small",
srcs = ["lstm_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1014,7 +905,6 @@ tf_cc_test(
name = "skip_gram_test",
size = "small",
srcs = ["skip_gram_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1028,7 +918,6 @@ tf_cc_test(
name = "space_to_depth_test",
size = "small",
srcs = ["space_to_depth_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1041,9 +930,6 @@ tf_cc_test(
name = "split_test",
size = "small",
srcs = ["split_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1056,9 +942,6 @@ tf_cc_test(
name = "split_v_test",
size = "small",
srcs = ["split_v_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1071,9 +954,6 @@ tf_cc_test(
name = "squeeze_test",
size = "small",
srcs = ["squeeze_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1086,9 +966,6 @@ tf_cc_test(
name = "strided_slice_test",
size = "small",
srcs = ["strided_slice_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1101,9 +978,6 @@ tf_cc_test(
name = "tile_test",
size = "small",
srcs = ["tile_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1119,9 +993,6 @@ tf_cc_test(
srcs = [
"comparisons_test.cc",
],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1134,9 +1005,6 @@ tf_cc_test(
name = "neg_test",
size = "small",
srcs = ["neg_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1151,9 +1019,6 @@ tf_cc_test(
srcs = [
"select_test.cc",
],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1168,9 +1033,6 @@ tf_cc_test(
srcs = [
"slice_test.cc",
],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1183,9 +1045,6 @@ tf_cc_test(
name = "transpose_conv_test",
size = "small",
srcs = ["transpose_conv_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1199,9 +1058,6 @@ tf_cc_test(
name = "expand_dims_test",
size = "small",
srcs = ["expand_dims_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1215,9 +1071,6 @@ tf_cc_test(
name = "sparse_to_dense_test",
size = "small",
srcs = ["sparse_to_dense_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1231,9 +1084,6 @@ tf_cc_test(
name = "shape_test",
size = "small",
srcs = ["shape_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1247,9 +1097,6 @@ tf_cc_test(
name = "pow_test",
size = "small",
srcs = ["pow_test.cc"],
tags = [
"tflite_not_portable_ios",
],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1263,7 +1110,6 @@ tf_cc_test(
name = "pack_test",
size = "small",
srcs = ["pack_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1277,7 +1123,6 @@ tf_cc_test(
name = "one_hot_test",
size = "small",
srcs = ["one_hot_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1290,7 +1135,6 @@ tf_cc_test(
name = "logical_test",
size = "small",
srcs = ["logical_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1304,7 +1148,6 @@ tf_cc_test(
name = "unpack_test",
size = "small",
srcs = ["unpack_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:builtin_op_data",
@ -1318,7 +1161,6 @@ tf_cc_test(
name = "floor_div_test",
size = "small",
srcs = ["floor_div_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:builtin_op_data",
@ -1332,7 +1174,6 @@ tf_cc_test(
name = "zeros_like_test",
size = "small",
srcs = ["zeros_like_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:builtin_op_data",
@ -1346,7 +1187,6 @@ tf_cc_test(
name = "floor_mod_test",
size = "small",
srcs = ["floor_mod_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:builtin_op_data",
@ -1360,7 +1200,6 @@ tf_cc_test(
name = "range_test",
size = "small",
srcs = ["range_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:builtin_op_data",
@ -1374,7 +1213,6 @@ tf_cc_test(
name = "squared_difference_test",
size = "small",
srcs = ["squared_difference_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",
@ -1387,7 +1225,6 @@ tf_cc_test(
name = "fill_test",
size = "small",
srcs = ["fill_test.cc"],
tags = ["tflite_not_portable_ios"],
deps = [
":builtin_ops",
"//tensorflow/lite:framework",

View File

@ -114,6 +114,7 @@ TEST(BatchToSpaceNDOpTest, SimpleDynamicTest) {
4, 8, 11, 15, 12, 16}));
}
#ifdef GTEST_HAS_DEATH_TEST
TEST(BatchToSpaceNDOpTest, InvalidShapeTest) {
EXPECT_DEATH(BatchToSpaceNDOpConstModel({3, 2, 2, 1}, {2, 2}, {0, 0, 0, 0}),
"Cannot allocate tensors");
@ -131,6 +132,7 @@ TEST(BatchToSpaceNDOpTest, InvalidCropsDynamicTest) {
m.SetCrops({0, 0, -1, 0});
EXPECT_DEATH(m.Invoke(), "crops.2. >= 0 was not true.");
}
#endif
} // namespace
} // namespace tflite

View File

@ -175,6 +175,7 @@ class PadOpDynamicModel : public PadOpModel<float> {
}
};
#ifdef GTEST_HAS_DEATH_TEST
TEST(PadOpTest, TooManyDimensions) {
EXPECT_DEATH(
PadOpConstModel({TensorType_FLOAT32, {1, 2, 3, 4, 5, 6, 7, 8, 9}}, {9, 2},
@ -195,6 +196,7 @@ TEST(PadOpTest, InvalidPadValue) {
{0, 0, 1, -1, 2, -1, 0, 0}, {TensorType_FLOAT32}),
"Pad value has to be greater than equal to 0.");
}
#endif
TEST(PadOpTest, SimpleConstTest) {
// Padding is represented as four 2-D lists representing above padding and
@ -306,6 +308,7 @@ class QuantizedPadOpTest : public ::testing::Test {
}
};
#ifdef GTEST_HAS_DEATH_TEST
TEST_F(QuantizedPadOpTest, ZeroNotInQuantizationRange) {
// The test_util and actual quantization code currently ensure that the range
// must include zero, but if that ever changes, this test will catch it.
@ -314,6 +317,7 @@ TEST_F(QuantizedPadOpTest, ZeroNotInQuantizationRange) {
{TensorType_UINT8, {}, 1.0, 2.0}),
".*Check failed: f_min <= 0.*");
}
#endif
TEST_F(QuantizedPadOpTest, SimpleConstTest) {
// Padding is represented as four 2-D lists representing above padding and
@ -371,6 +375,7 @@ TEST_F(QuantizedPadOpTest, AdvancedDynamicTest) {
EXPECT_THAT(m.GetOutputShape(), ElementsAreArray({1, 4, 7, 1}));
}
#ifdef GTEST_HAS_DEATH_TEST
TEST(PadV2OpTest, TooManyDimensions) {
EXPECT_DEATH(PadV2OpConstModel<float>(
{TensorType_FLOAT32, {1, 2, 3, 4, 5, 6, 7, 8, 9}}, {9, 2},
@ -392,6 +397,7 @@ TEST(PadV2OpTest, InvalidPadValue) {
{TensorType_FLOAT32}),
"Pad value has to be greater than equal to 0.");
}
#endif
TEST(PadV2OpTest, SimpleConstTest) {
// Padding is represented as four 2-D lists representing above padding and
@ -495,6 +501,7 @@ class QuantizedPadV2OpTest : public ::testing::Test {
}
};
#ifdef GTEST_HAS_DEATH_TEST
TEST_F(QuantizedPadV2OpTest, ZeroNotInQuantizationRange) {
// The test_util and actual quantization code currently ensure that the range
// must include zero, but if that ever changes, this test will catch it.
@ -504,6 +511,7 @@ TEST_F(QuantizedPadV2OpTest, ZeroNotInQuantizationRange) {
{TensorType_UINT8, {}, 1.0, 2.0}),
".*Check failed: f_min <= 0.*");
}
#endif
TEST_F(QuantizedPadV2OpTest, SimpleConstTest) {
// Padding is represented as four 2-D lists representing above padding and

View File

@ -123,6 +123,7 @@ class ReshapeOpModel : public SingleOpModel {
int output_;
};
#ifdef GTEST_HAS_DEATH_TEST
TEST_P(ReshapeOpTest, MismatchedDimensions) {
if (GetParam() == kAsTensor) {
ReshapeOpModel<float> m({1, 2, 4, 1}, {2}, {2, 1}, GetParam());
@ -133,12 +134,15 @@ TEST_P(ReshapeOpTest, MismatchedDimensions) {
"num_input_elements != num_output_elements");
}
}
#endif
TEST_P(ReshapeOpTest, TooManyDimensions) {
if (GetParam() == kAsReshapeOption) {
#ifdef GTEST_HAS_DEATH_TEST
EXPECT_DEATH(ReshapeOpModel<float>({1, 1, 2, 1, 1, 1, 1, 1, 1}, {9},
{1, 1, 1, 1, 1, 1, 1, 1, 2}, GetParam()),
"Found too many dimensions");
#endif
} else {
ReshapeOpModel<float> m({1, 1, 2, 1, 1, 1, 1, 1, 1}, {9},
{1, 1, 1, 1, 1, 1, 1, 1, 2}, GetParam());
@ -150,6 +154,7 @@ TEST_P(ReshapeOpTest, TooManyDimensions) {
}
}
#ifdef GTEST_HAS_DEATH_TEST
TEST_P(ReshapeOpTest, TooManySpecialDimensions) {
if (GetParam() != kAsTensor) {
EXPECT_DEATH(
@ -160,6 +165,7 @@ TEST_P(ReshapeOpTest, TooManySpecialDimensions) {
EXPECT_DEATH(m.Invoke(), "stretch_dim != -1");
}
}
#endif
// Create the model with a 2x2 shape. Processing still works because the new
// shape ends up being hardcoded as a flat vector.
@ -202,12 +208,16 @@ TEST_P(ReshapeOpTest, ScalarOutput) {
// and output are scalars.
TEST_P(ReshapeOpTest, LegacyScalarOutput) {
if (GetParam() == kAsConstantTensor) {
#ifdef GTEST_HAS_DEATH_TEST
EXPECT_DEATH(ReshapeOpModel<float>({1}, {1}, {0}, GetParam()),
"num_input_elements != num_output_elements");
#endif
} else if (GetParam() == kAsTensor) {
#ifdef GTEST_HAS_DEATH_TEST
ReshapeOpModel<float> m({1}, {1}, {0}, GetParam());
m.SetInput({3});
EXPECT_DEATH(m.Invoke(), "num_input_elements != num_output_elements");
#endif
} else {
ReshapeOpModel<float> m({1}, {1}, {0}, GetParam());
m.SetInput({3});

View File

@ -106,12 +106,14 @@ class SpaceToBatchNDOpDynamicModel : public SpaceToBatchNDOpModel {
}
};
#ifdef GTEST_HAS_DEATH_TEST
TEST(SpaceToBatchNDOpTest, InvalidShapeTest) {
EXPECT_DEATH(
SpaceToBatchNDOpConstModel({TensorType_FLOAT32, {1, 3, 3, 1}}, {2, 2},
{0, 0, 0, 0}, {TensorType_FLOAT32}),
"Cannot allocate tensors");
}
#endif
TEST(SpaceToBatchNDOpTest, SimpleConstTest) {
SpaceToBatchNDOpConstModel m({TensorType_FLOAT32, {1, 4, 4, 1}}, {2, 2},
@ -220,6 +222,7 @@ class QuantizedSpaceToBatchNDOpTest : public ::testing::Test {
}
};
#ifdef GTEST_HAS_DEATH_TEST
TEST_F(QuantizedSpaceToBatchNDOpTest, ZeroNotInQuantizationRange) {
// The test_util and actual quantization code currently ensure that the range
// must include zero, but if that ever changes, this test will catch it.
@ -228,6 +231,7 @@ TEST_F(QuantizedSpaceToBatchNDOpTest, ZeroNotInQuantizationRange) {
{0, 0, 1, 1, 1, 1, 0, 0}, {TensorType_UINT8, {}, 1.0, 2.0}),
".*Check failed: f_min <= 0.*");
}
#endif
TEST_F(QuantizedSpaceToBatchNDOpTest, SimplePaddingConstTest) {
SpaceToBatchNDOpConstModel m({TensorType_UINT8, {1, 5, 2, 1}, -1.0, 1.0},

View File

@ -50,10 +50,12 @@ class SpaceToDepthOpModel : public SingleOpModel {
int output_;
};
#ifdef GTEST_HAS_DEATH_TEST
TEST(SpaceToDepthOpModel, BadBlockSize) {
EXPECT_DEATH(SpaceToDepthOpModel({TensorType_FLOAT32, {1, 2, 2, 1}}, 3),
"Cannot allocate tensors");
}
#endif
TEST(SpaceToDepthOpModel, Float32) {
SpaceToDepthOpModel m({TensorType_FLOAT32, {1, 2, 2, 2}}, 2);

View File

@ -72,6 +72,7 @@ class StridedSliceOpModel : public SingleOpModel {
int output_;
};
#ifdef GTEST_HAS_DEATH_TEST
TEST(StridedSliceOpTest, UnsupportedInputSize) {
EXPECT_DEATH(
StridedSliceOpModel<>({2, 2, 2, 2, 2}, {5}, {5}, {5}, 0, 0, 0, 0, 0),
@ -84,6 +85,7 @@ TEST(StridedSliceOpTest, UnssupportedArgs) {
EXPECT_DEATH(StridedSliceOpModel<>({3, 2}, {2}, {2}, {2}, 0, 0, 0, 1, 0),
"new_axis_mask is not implemented yet.");
}
#endif
TEST(StridedSliceOpTest, In1D) {
StridedSliceOpModel<> m({4}, {1}, {1}, {1}, 0, 0, 0, 0, 0);

View File

@ -184,6 +184,7 @@ class TransposeOpDynamicModel : public TransposeOpModel {
}
};
#ifdef GTEST_HAS_DEATH_TEST
TEST(TransposeTest, TestUnequalPermSize) {
EXPECT_DEATH(TransposeOpConstModel({1, 3, 3, 1}, {2}, {2, 2}), "2 != 4");
}
@ -194,6 +195,7 @@ TEST(TransposeTest, TestPermOutOfBounds) {
EXPECT_DEATH(TransposeOpConstModel({1, 3, 3, 1}, {4}, {0, 1, 2, 4}),
"Transpose op permutations array is out of bounds.");
}
#endif
TEST(TransposeTest, Test1DInputConstTensor) {
TransposeOpConstModel m({3}, {1}, {0});
@ -252,10 +254,12 @@ TEST(TransposeTest, Test3DInputDynamicTensor) {
2, 6, 10, 14, 18, 22, 3, 7, 11, 15, 19, 23}));
}
#ifdef GTEST_HAS_DEATH_TEST
TEST(TransposeTest, Test5DInputTensor) {
EXPECT_DEATH(TransposeOpConstModel({1, 2, 3, 4, 5}, {5}, {0, 1, 2, 3, 4}),
"Transpose op only supports 1D-4D input arrays.");
}
#endif
TEST(TransposeTest, SimpleTestNoReorderConstTensor) {
TransposeOpConstModel m({1, 2, 3, 1}, {4}, {0, 1, 2, 3});