Fix NNAPI delegation error on models with MAX/MIN operations with scalar quantized operators

PiperOrigin-RevId: 317266736
Change-Id: Ieed8a77685d4ca0d51389b5976addf0de167cfcf
This commit is contained in:
Stefano Galarraga 2020-06-19 01:21:24 -07:00 committed by TensorFlower Gardener
parent 9f20b156bc
commit 051d1b70f5
2 changed files with 13 additions and 0 deletions
tensorflow/lite

View File

@ -160,6 +160,8 @@ bool IsScalarInputSupported(int builtin_code) {
case kTfLiteBuiltinLess:
case kTfLiteBuiltinLessEqual:
case kTfLiteBuiltinPow:
case kTfLiteBuiltinMaximum:
case kTfLiteBuiltinMinimum:
return true;
default:
return false;

View File

@ -190,6 +190,17 @@ TEST(MaximumOpTest, Int32WithBroadcastTest_ScalarY) {
data1, data2, {1, 0, -1, -2, 2, 2}, /*is_constant=*/true);
}
TEST(MaximumOpTest, Int8WithBroadcastTest_ScalarY) {
std::initializer_list<int8_t> data1 = {1, 0, -1, -2, 3, 11};
std::initializer_list<int8_t> data2 = {2};
TestModel<int8_t>(BuiltinOperator_MAXIMUM, {TensorType_INT8, {3, 1, 2}},
{TensorType_INT8, {}}, {TensorType_INT8, {3, 1, 2}}, data1,
data2, {2, 2, 2, 2, 3, 11}, /*is_constant=*/true);
TestModel<int8_t>(BuiltinOperator_MINIMUM, {TensorType_INT8, {3, 1, 2}},
{TensorType_INT8, {}}, {TensorType_INT8, {3, 1, 2}}, data1,
data2, {1, 0, -1, -2, 2, 2}, /*is_constant=*/true);
}
TEST(MaxMinOpTest, Int8Test8D) {
std::initializer_list<int8_t> data1 = {1, 0, 2, 11, 2, 23};
std::initializer_list<int8_t> data2 = {0, 0, 1, 12, 123, 1};