16-bit support for reference kernels:
MAX/MIN element-wise reference operators PACK UNPACK
This commit is contained in:
parent
46c271b15d
commit
9bbc41c554
@ -119,6 +119,9 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
|
||||
case kTfLiteInt64:
|
||||
TFLiteOperation<int64_t, OpType>(context, node, op_context);
|
||||
break;
|
||||
case kTfLiteInt16:
|
||||
TFLiteOperation<int16_t, OpType>(context, node, op_context);
|
||||
break;
|
||||
default:
|
||||
context->ReportError(context,
|
||||
"Type %d is currently not supported by Maximum.",
|
||||
|
@ -123,6 +123,17 @@ TEST(MaxMinOpTest, Int8Test) {
|
||||
data1, data2, {0, 0, 1, 11, 2, 1});
|
||||
}
|
||||
|
||||
TEST(MaxMinOpTest, Int16Test) {
|
||||
std::initializer_list<int16_t> data1 = {-32768, 0, 2, 11, 2, 23};
|
||||
std::initializer_list<int16_t> data2 = {0, 0, 1, 32767, 123, 1};
|
||||
TestModel<int16_t>(BuiltinOperator_MAXIMUM, {TensorType_INT16, {3, 1, 2}},
|
||||
{TensorType_INT16, {3, 1, 2}}, {TensorType_INT16, {3, 1, 2}},
|
||||
data1, data2, {0, 0, 2, 32767, 123, 23});
|
||||
TestModel<int16_t>(BuiltinOperator_MINIMUM, {TensorType_INT16, {3, 1, 2}},
|
||||
{TensorType_INT16, {3, 1, 2}}, {TensorType_INT16, {3, 1, 2}},
|
||||
data1, data2, {-32768, 0, 1, 11, 2, 1});
|
||||
}
|
||||
|
||||
TEST(MaximumOpTest, FloatWithBroadcastTest) {
|
||||
std::initializer_list<float> data1 = {1.0, 0.0, -1.0, -2.0, -1.44, 11.0};
|
||||
std::initializer_list<float> data2 = {0.5, 2.0};
|
||||
|
@ -116,6 +116,10 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
|
||||
return PackImpl<int8_t>(context, node, output, data->values_count,
|
||||
data->axis);
|
||||
}
|
||||
case kTfLiteInt16: {
|
||||
return PackImpl<int16_t>(context, node, output, data->values_count,
|
||||
data->axis);
|
||||
}
|
||||
case kTfLiteInt32: {
|
||||
return PackImpl<int32_t>(context, node, output, data->values_count,
|
||||
data->axis);
|
||||
|
@ -191,9 +191,22 @@ TEST(PackOpTest, Int64MultilDimensions) {
|
||||
4LL, 5LL, 6LL, 10LL, 11LL, 12LL}));
|
||||
}
|
||||
|
||||
// uint8
|
||||
TEST(PackOpTest, Uint8ThreeInputs) {
|
||||
PackOpModel<uint8_t> model({TensorType_UINT8, {2}}, 0, 3);
|
||||
template <typename InputType>
|
||||
struct PackOpTestInt : public ::testing::Test {
|
||||
using TypeToTest = InputType;
|
||||
TensorType TENSOR_TYPE =
|
||||
std::is_same<InputType, int16_t>::value
|
||||
? TensorType_INT16
|
||||
: (std::is_same<InputType, uint8_t>::value ? TensorType_UINT8
|
||||
: TensorType_INT8);
|
||||
};
|
||||
|
||||
using TestTypes = testing::Types<int8_t, uint8_t, int16_t>;
|
||||
TYPED_TEST_CASE(PackOpTestInt, TestTypes);
|
||||
|
||||
TYPED_TEST(PackOpTestInt, ThreeInputs) {
|
||||
PackOpModel<typename TestFixture::TypeToTest> model(
|
||||
{TestFixture::TENSOR_TYPE, {2}}, 0, 3);
|
||||
model.SetInput(0, {1, 4});
|
||||
model.SetInput(1, {2, 5});
|
||||
model.SetInput(2, {3, 6});
|
||||
@ -202,8 +215,9 @@ TEST(PackOpTest, Uint8ThreeInputs) {
|
||||
EXPECT_THAT(model.GetOutput(), ElementsAreArray({1, 4, 2, 5, 3, 6}));
|
||||
}
|
||||
|
||||
TEST(PackOpTest, Uint8ThreeInputsDifferentAxis) {
|
||||
PackOpModel<uint8_t> model({TensorType_UINT8, {2}}, 1, 3);
|
||||
TYPED_TEST(PackOpTestInt, ThreeInputsDifferentAxis) {
|
||||
PackOpModel<typename TestFixture::TypeToTest> model(
|
||||
{TestFixture::TENSOR_TYPE, {2}}, 1, 3);
|
||||
model.SetInput(0, {1, 4});
|
||||
model.SetInput(1, {2, 5});
|
||||
model.SetInput(2, {3, 6});
|
||||
@ -212,8 +226,9 @@ TEST(PackOpTest, Uint8ThreeInputsDifferentAxis) {
|
||||
EXPECT_THAT(model.GetOutput(), ElementsAreArray({1, 2, 3, 4, 5, 6}));
|
||||
}
|
||||
|
||||
TEST(PackOpTest, Uint8ThreeInputsNegativeAxis) {
|
||||
PackOpModel<uint8_t> model({TensorType_UINT8, {2}}, -1, 3);
|
||||
TYPED_TEST(PackOpTestInt, ThreeInputsNegativeAxis) {
|
||||
PackOpModel<typename TestFixture::TypeToTest> model(
|
||||
{TestFixture::TENSOR_TYPE, {2}}, -1, 3);
|
||||
model.SetInput(0, {1, 4});
|
||||
model.SetInput(1, {2, 5});
|
||||
model.SetInput(2, {3, 6});
|
||||
@ -222,49 +237,9 @@ TEST(PackOpTest, Uint8ThreeInputsNegativeAxis) {
|
||||
EXPECT_THAT(model.GetOutput(), ElementsAreArray({1, 2, 3, 4, 5, 6}));
|
||||
}
|
||||
|
||||
TEST(PackOpTest, Uint8MultilDimensions) {
|
||||
PackOpModel<uint8_t> model({TensorType_UINT8, {2, 3}}, 1, 2);
|
||||
model.SetInput(0, {1, 2, 3, 4, 5, 6});
|
||||
model.SetInput(1, {7, 8, 9, 10, 11, 12});
|
||||
model.Invoke();
|
||||
EXPECT_THAT(model.GetOutputShape(), ElementsAre(2, 2, 3));
|
||||
EXPECT_THAT(model.GetOutput(),
|
||||
ElementsAreArray({1, 2, 3, 7, 8, 9, 4, 5, 6, 10, 11, 12}));
|
||||
}
|
||||
|
||||
// int8
|
||||
TEST(PackOpTest, Int8ThreeInputs) {
|
||||
PackOpModel<int8_t> model({TensorType_INT8, {2}}, 0, 3);
|
||||
model.SetInput(0, {1, 4});
|
||||
model.SetInput(1, {2, 5});
|
||||
model.SetInput(2, {3, 6});
|
||||
model.Invoke();
|
||||
EXPECT_THAT(model.GetOutputShape(), ElementsAre(3, 2));
|
||||
EXPECT_THAT(model.GetOutput(), ElementsAreArray({1, 4, 2, 5, 3, 6}));
|
||||
}
|
||||
|
||||
TEST(PackOpTest, Int8ThreeInputsDifferentAxis) {
|
||||
PackOpModel<int8_t> model({TensorType_INT8, {2}}, 1, 3);
|
||||
model.SetInput(0, {1, 4});
|
||||
model.SetInput(1, {2, 5});
|
||||
model.SetInput(2, {3, 6});
|
||||
model.Invoke();
|
||||
EXPECT_THAT(model.GetOutputShape(), ElementsAre(2, 3));
|
||||
EXPECT_THAT(model.GetOutput(), ElementsAreArray({1, 2, 3, 4, 5, 6}));
|
||||
}
|
||||
|
||||
TEST(PackOpTest, Int8ThreeInputsNegativeAxis) {
|
||||
PackOpModel<int8_t> model({TensorType_INT8, {2}}, -1, 3);
|
||||
model.SetInput(0, {1, 4});
|
||||
model.SetInput(1, {2, 5});
|
||||
model.SetInput(2, {3, 6});
|
||||
model.Invoke();
|
||||
EXPECT_THAT(model.GetOutputShape(), ElementsAre(2, 3));
|
||||
EXPECT_THAT(model.GetOutput(), ElementsAreArray({1, 2, 3, 4, 5, 6}));
|
||||
}
|
||||
|
||||
TEST(PackOpTest, Int8MultilDimensions) {
|
||||
PackOpModel<int8_t> model({TensorType_INT8, {2, 3}}, 1, 2);
|
||||
TYPED_TEST(PackOpTestInt, MultilDimensions) {
|
||||
PackOpModel<typename TestFixture::TypeToTest> model(
|
||||
{TestFixture::TENSOR_TYPE, {2, 3}}, 1, 2);
|
||||
model.SetInput(0, {1, 2, 3, 4, 5, 6});
|
||||
model.SetInput(1, {7, 8, 9, 10, 11, 12});
|
||||
model.Invoke();
|
||||
|
@ -44,7 +44,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
|
||||
TF_LITE_ENSURE(context, 0 <= axis && axis < NumDimensions(input));
|
||||
if (input->type != kTfLiteInt32 && input->type != kTfLiteFloat32 &&
|
||||
input->type != kTfLiteUInt8 && input->type != kTfLiteInt8 &&
|
||||
input->type != kTfLiteBool) {
|
||||
input->type != kTfLiteInt16 && input->type != kTfLiteBool) {
|
||||
context->ReportError(context, "Type '%s' is not supported by unpack.",
|
||||
TfLiteTypeGetName(input->type));
|
||||
return kTfLiteError;
|
||||
@ -117,6 +117,10 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
|
||||
UnpackImpl<bool>(context, node, input, data->num, data->axis);
|
||||
break;
|
||||
}
|
||||
case kTfLiteInt16: {
|
||||
UnpackImpl<int16_t>(context, node, input, data->num, data->axis);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
context->ReportError(context, "Type '%s' is not supported by unpack.",
|
||||
TfLiteTypeGetName(input->type));
|
||||
|
@ -83,213 +83,75 @@ void Check(int axis, const std::initializer_list<int>& input_shape,
|
||||
EXPECT_THAT(m.GetOutputDatas(), ElementsAreArray(exp_output_data));
|
||||
}
|
||||
|
||||
// float32 tests.
|
||||
TEST(UnpackOpTest, FloatThreeOutputs) {
|
||||
Check<float>(/*axis=*/0, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{2}, {2}, {2}},
|
||||
/*exp_output_data=*/{{1, 2}, {3, 4}, {5, 6}});
|
||||
template <typename InputType>
|
||||
struct UnpackOpTest : public ::testing::Test {
|
||||
using TypeToTest = InputType;
|
||||
TensorType TENSOR_TYPE =
|
||||
std::is_same<InputType, int16_t>::value
|
||||
? TensorType_INT16
|
||||
: std::is_same<InputType, uint8_t>::value
|
||||
? TensorType_UINT8
|
||||
: std::is_same<InputType, int8_t>::value
|
||||
? TensorType_INT8
|
||||
: std::is_same<InputType, int32_t>::value
|
||||
? TensorType_INT32
|
||||
: TensorType_FLOAT32;
|
||||
};
|
||||
|
||||
using TestTypes = testing::Types<float, int32_t, int8_t, uint8_t, int16_t>;
|
||||
TYPED_TEST_CASE(UnpackOpTest, TestTypes);
|
||||
|
||||
TYPED_TEST(UnpackOpTest, ThreeOutputs) {
|
||||
Check<typename TestFixture::TypeToTest>(
|
||||
/*axis=*/0, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{2}, {2}, {2}},
|
||||
/*exp_output_data=*/{{1, 2}, {3, 4}, {5, 6}}, TestFixture::TENSOR_TYPE);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, FloatThreeOutputsAxisOne) {
|
||||
Check<float>(/*axis=*/1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{3}, {3}},
|
||||
/*exp_output_data=*/{{1, 3, 5}, {2, 4, 6}});
|
||||
TYPED_TEST(UnpackOpTest, ThreeOutputsAxisOne) {
|
||||
Check<typename TestFixture::TypeToTest>(
|
||||
/*axis=*/1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{3}, {3}},
|
||||
/*exp_output_data=*/{{1, 3, 5}, {2, 4, 6}}, TestFixture::TENSOR_TYPE);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, FloatThreeOutputsNegativeAxisOne) {
|
||||
Check<float>(/*axis=*/-1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{3}, {3}},
|
||||
/*exp_output_data=*/{{1, 3, 5}, {2, 4, 6}});
|
||||
TYPED_TEST(UnpackOpTest, ThreeOutputsNegativeAxisOne) {
|
||||
Check<typename TestFixture::TypeToTest>(
|
||||
/*axis=*/-1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{3}, {3}},
|
||||
/*exp_output_data=*/{{1, 3, 5}, {2, 4, 6}}, TestFixture::TENSOR_TYPE);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, FloatThreeOutputsNegativeAxisTwo) {
|
||||
Check<float>(/*axis=*/-2, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{2}, {2}, {2}},
|
||||
/*exp_output_data=*/{{1, 2}, {3, 4}, {5, 6}});
|
||||
TYPED_TEST(UnpackOpTest, OneOutput) {
|
||||
Check<typename TestFixture::TypeToTest>(
|
||||
/*axis=*/0, /*input_shape=*/{1, 6},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{6}},
|
||||
/*exp_output_data=*/{{1, 2, 3, 4, 5, 6}}, TestFixture::TENSOR_TYPE);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, FloatOneOutput) {
|
||||
Check<float>(/*axis=*/0, /*input_shape=*/{1, 6},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{6}},
|
||||
/*exp_output_data=*/{{1, 2, 3, 4, 5, 6}});
|
||||
TYPED_TEST(UnpackOpTest, ThreeDimensionsOutputs) {
|
||||
Check<typename TestFixture::TypeToTest>(
|
||||
/*axis=*/2, /*input_shape=*/{2, 2, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6, 7, 8},
|
||||
/*exp_output_shape=*/{{2, 2}, {2, 2}},
|
||||
/*exp_output_data=*/{{1, 3, 5, 7}, {2, 4, 6, 8}},
|
||||
TestFixture::TENSOR_TYPE);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, FloatThreeDimensionsOutputs) {
|
||||
Check<float>(/*axis=*/2, /*input_shape=*/{2, 2, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6, 7, 8},
|
||||
/*exp_output_shape=*/{{2, 2}, {2, 2}},
|
||||
/*exp_output_data=*/{{1, 3, 5, 7}, {2, 4, 6, 8}});
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, FloatVectorToScalar) {
|
||||
Check<float>(/*axis=*/0, /*input_shape=*/{5},
|
||||
/*input_data=*/{1, 2, 3, 4, 5},
|
||||
/*exp_output_shape=*/{{}, {}, {}, {}, {}},
|
||||
/*exp_output_data=*/{{1}, {2}, {3}, {4}, {5}});
|
||||
}
|
||||
|
||||
// int32 tests.
|
||||
TEST(UnpackOpTest, IntThreeOutputs) {
|
||||
Check<int32_t>(/*axis=*/0, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{2}, {2}, {2}},
|
||||
/*exp_output_data=*/{{1, 2}, {3, 4}, {5, 6}},
|
||||
/*type=*/TensorType_INT32);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, IntThreeOutputsAxisOne) {
|
||||
Check<int32_t>(/*axis=*/1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{3}, {3}},
|
||||
/*exp_output_data=*/{{1, 3, 5}, {2, 4, 6}},
|
||||
/*type=*/TensorType_INT32);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, IntOneOutput) {
|
||||
Check<int32_t>(/*axis=*/0, /*input_shape=*/{1, 6},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{6}},
|
||||
/*exp_output_data=*/{{1, 2, 3, 4, 5, 6}},
|
||||
/*type=*/TensorType_INT32);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, IntThreeDimensionsOutputs) {
|
||||
Check<int32_t>(/*axis=*/2, /*input_shape=*/{2, 2, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6, 7, 8},
|
||||
/*exp_output_shape=*/{{2, 2}, {2, 2}},
|
||||
/*exp_output_data=*/{{1, 3, 5, 7}, {2, 4, 6, 8}},
|
||||
/*type=*/TensorType_INT32);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, IntVectorToScalar) {
|
||||
Check<int32_t>(/*axis=*/0, /*input_shape=*/{5},
|
||||
/*input_data=*/{1, 2, 3, 4, 5},
|
||||
/*exp_output_shape=*/{{}, {}, {}, {}, {}},
|
||||
/*exp_output_data=*/{{1}, {2}, {3}, {4}, {5}},
|
||||
/*type=*/TensorType_INT32);
|
||||
}
|
||||
|
||||
// uint8 tests.
|
||||
TEST(UnpackOpTest, Uint8ThreeOutputs) {
|
||||
Check<uint8_t>(/*axis=*/0, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{2}, {2}, {2}},
|
||||
/*exp_output_data=*/{{1, 2}, {3, 4}, {5, 6}},
|
||||
/*type=*/TensorType_UINT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Uint8ThreeOutputsAxisOne) {
|
||||
Check<uint8_t>(/*axis=*/1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{3}, {3}},
|
||||
/*exp_output_data=*/{{1, 3, 5}, {2, 4, 6}},
|
||||
/*type=*/TensorType_UINT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Uint8ThreeOutputsNegativeAxisOne) {
|
||||
Check<uint8_t>(/*axis=*/-1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{3}, {3}},
|
||||
/*exp_output_data=*/{{1, 3, 5}, {2, 4, 6}},
|
||||
/*type=*/TensorType_UINT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Uint8ThreeOutputsNegativeAxisTwo) {
|
||||
Check<uint8_t>(/*axis=*/-2, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{2}, {2}, {2}},
|
||||
/*exp_output_data=*/{{1, 2}, {3, 4}, {5, 6}},
|
||||
/*type=*/TensorType_UINT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Uint8OneOutput) {
|
||||
Check<uint8_t>(/*axis=*/0, /*input_shape=*/{1, 6},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{6}},
|
||||
/*exp_output_data=*/{{1, 2, 3, 4, 5, 6}},
|
||||
/*type=*/TensorType_UINT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Uint8ThreeDimensionsOutputs) {
|
||||
Check<uint8_t>(/*axis=*/2, /*input_shape=*/{2, 2, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6, 7, 8},
|
||||
/*exp_output_shape=*/{{2, 2}, {2, 2}},
|
||||
/*exp_output_data=*/{{1, 3, 5, 7}, {2, 4, 6, 8}},
|
||||
/*type=*/TensorType_UINT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Uint8VectorToScalar) {
|
||||
Check<uint8_t>(/*axis=*/0, /*input_shape=*/{5},
|
||||
/*input_data=*/{1, 2, 3, 4, 5},
|
||||
/*exp_output_shape=*/{{}, {}, {}, {}, {}},
|
||||
/*exp_output_data=*/{{1}, {2}, {3}, {4}, {5}},
|
||||
/*type=*/TensorType_UINT8);
|
||||
}
|
||||
|
||||
// int8 tests.
|
||||
TEST(UnpackOpTest, Int8ThreeOutputs) {
|
||||
Check<int8_t>(/*axis=*/0, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{2}, {2}, {2}},
|
||||
/*exp_output_data=*/{{1, 2}, {3, 4}, {5, 6}},
|
||||
/*type=*/TensorType_INT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Int8ThreeOutputsAxisOne) {
|
||||
Check<int8_t>(/*axis=*/1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{3}, {3}},
|
||||
/*exp_output_data=*/{{1, 3, 5}, {2, 4, 6}},
|
||||
/*type=*/TensorType_INT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Int8ThreeOutputsNegativeAxisOne) {
|
||||
Check<int8_t>(/*axis=*/-1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{3}, {3}},
|
||||
/*exp_output_data=*/{{1, 3, 5}, {2, 4, 6}},
|
||||
/*type=*/TensorType_INT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Int8ThreeOutputsNegativeAxisTwo) {
|
||||
Check<int8_t>(/*axis=*/-2, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{2}, {2}, {2}},
|
||||
/*exp_output_data=*/{{1, 2}, {3, 4}, {5, 6}},
|
||||
/*type=*/TensorType_INT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Int8OneOutput) {
|
||||
Check<int8_t>(/*axis=*/0, /*input_shape=*/{1, 6},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6},
|
||||
/*exp_output_shape=*/{{6}},
|
||||
/*exp_output_data=*/{{1, 2, 3, 4, 5, 6}},
|
||||
/*type=*/TensorType_INT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Int8ThreeDimensionsOutputs) {
|
||||
Check<int8_t>(/*axis=*/2, /*input_shape=*/{2, 2, 2},
|
||||
/*input_data=*/{1, 2, 3, 4, 5, 6, 7, 8},
|
||||
/*exp_output_shape=*/{{2, 2}, {2, 2}},
|
||||
/*exp_output_data=*/{{1, 3, 5, 7}, {2, 4, 6, 8}},
|
||||
/*type=*/TensorType_INT8);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, Int8VectorToScalar) {
|
||||
Check<int8_t>(/*axis=*/0, /*input_shape=*/{5},
|
||||
/*input_data=*/{1, 2, 3, 4, 5},
|
||||
/*exp_output_shape=*/{{}, {}, {}, {}, {}},
|
||||
/*exp_output_data=*/{{1}, {2}, {3}, {4}, {5}},
|
||||
/*type=*/TensorType_INT8);
|
||||
TYPED_TEST(UnpackOpTest, VectorToScalar) {
|
||||
Check<typename TestFixture::TypeToTest>(
|
||||
/*axis=*/0, /*input_shape=*/{5},
|
||||
/*input_data=*/{1, 2, 3, 4, 5},
|
||||
/*exp_output_shape=*/{{}, {}, {}, {}, {}},
|
||||
/*exp_output_data=*/{{1}, {2}, {3}, {4}, {5}}, TestFixture::TENSOR_TYPE);
|
||||
}
|
||||
|
||||
// bool tests.
|
||||
TEST(UnpackOpTest, BoolThreeOutputs) {
|
||||
TEST(UnpackOpTestBool, BoolThreeOutputs) {
|
||||
Check<bool>(
|
||||
/*axis=*/0, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{true, false, true, false, true, false},
|
||||
@ -298,7 +160,7 @@ TEST(UnpackOpTest, BoolThreeOutputs) {
|
||||
/*type=*/TensorType_BOOL);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, BoolThreeOutputsAxisOne) {
|
||||
TEST(UnpackOpTestBool, BoolThreeOutputsAxisOne) {
|
||||
Check<bool>(
|
||||
/*axis=*/1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{true, false, true, false, true, false},
|
||||
@ -307,7 +169,7 @@ TEST(UnpackOpTest, BoolThreeOutputsAxisOne) {
|
||||
/*type=*/TensorType_BOOL);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, BoolThreeOutputsNegativeAxisOne) {
|
||||
TEST(UnpackOpTestBool, BoolThreeOutputsNegativeAxisOne) {
|
||||
Check<bool>(
|
||||
/*axis=*/-1, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{true, false, true, false, true, false},
|
||||
@ -316,7 +178,7 @@ TEST(UnpackOpTest, BoolThreeOutputsNegativeAxisOne) {
|
||||
/*type=*/TensorType_BOOL);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, BoolThreeOutputsNegativeAxisTwo) {
|
||||
TEST(UnpackOpTestBool, BoolThreeOutputsNegativeAxisTwo) {
|
||||
Check<bool>(
|
||||
/*axis=*/-2, /*input_shape=*/{3, 2},
|
||||
/*input_data=*/{true, false, true, false, true, false},
|
||||
@ -325,7 +187,7 @@ TEST(UnpackOpTest, BoolThreeOutputsNegativeAxisTwo) {
|
||||
/*type=*/TensorType_BOOL);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, BoolOneOutput) {
|
||||
TEST(UnpackOpTestBool, BoolOneOutput) {
|
||||
Check<bool>(
|
||||
/*axis=*/0, /*input_shape=*/{1, 6},
|
||||
/*input_data=*/{true, false, true, false, true, false},
|
||||
@ -334,7 +196,7 @@ TEST(UnpackOpTest, BoolOneOutput) {
|
||||
/*type=*/TensorType_BOOL);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, BoolThreeDimensionsOutputs) {
|
||||
TEST(UnpackOpTestBool, BoolThreeDimensionsOutputs) {
|
||||
Check<bool>(
|
||||
/*axis=*/2, /*input_shape=*/{2, 2, 2},
|
||||
/*input_data=*/{true, false, true, false, true, false, true, false},
|
||||
@ -344,7 +206,7 @@ TEST(UnpackOpTest, BoolThreeDimensionsOutputs) {
|
||||
/*type=*/TensorType_BOOL);
|
||||
}
|
||||
|
||||
TEST(UnpackOpTest, BoolVectorToScalar) {
|
||||
TEST(UnpackOpTestBool, BoolVectorToScalar) {
|
||||
Check<bool>(/*axis=*/0, /*input_shape=*/{5},
|
||||
/*input_data=*/{true, false, true, false, true},
|
||||
/*exp_output_shape=*/{{}, {}, {}, {}, {}},
|
||||
|
Loading…
Reference in New Issue
Block a user