Add NN API delegate support for minimum and maximum ops.

PiperOrigin-RevId: 250673700
This commit is contained in:
A. Unique TensorFlower 2019-05-30 05:52:48 -07:00 committed by TensorFlower Gardener
parent babc6fd531
commit f6ab7c08e5
3 changed files with 19 additions and 0 deletions
tensorflow/lite

View File

@ -1380,6 +1380,22 @@ class NNAPIDelegateKernel {
return BasicMappingFn<ANEURALNETWORKS_HASHTABLE_LOOKUP>;
}
break;
case kTfLiteBuiltinMaximum: {
const auto input_type = context->tensors[node->inputs->data[0]].type;
if (version == 1 && android_sdk_version >= kMinSdkVersionForNNAPI12 &&
(input_type == kTfLiteFloat32 || input_type == kTfLiteUInt8 ||
input_type == kTfLiteInt32)) {
return BasicMappingFn<ANEURALNETWORKS_MAXIMUM>;
}
} break;
case kTfLiteBuiltinMinimum: {
const auto input_type = context->tensors[node->inputs->data[0]].type;
if (version == 1 && android_sdk_version >= kMinSdkVersionForNNAPI12 &&
(input_type == kTfLiteFloat32 || input_type == kTfLiteUInt8 ||
input_type == kTfLiteInt32)) {
return BasicMappingFn<ANEURALNETWORKS_MINIMUM>;
}
} break;
case kTfLiteBuiltinPrelu:
if (version == 1 && android_sdk_version >= kMinSdkVersionForNNAPI12) {
if (!IsFloatOrUint8Operator(context, node)) {

View File

@ -876,6 +876,7 @@ cc_test(
name = "maximum_minimum_test",
size = "small",
srcs = ["maximum_minimum_test.cc"],
tags = ["tflite_nnapi"],
deps = [
":builtin_ops",
":test_main",

View File

@ -90,6 +90,8 @@ enum {
ANEURALNETWORKS_ABS = 38,
ANEURALNETWORKS_EXP = 49,
ANEURALNETWORKS_LOG = 60,
ANEURALNETWORKS_MAXIMUM = 65,
ANEURALNETWORKS_MINIMUM = 66,
ANEURALNETWORKS_PAD_V2 = 69,
ANEURALNETWORKS_PRELU = 71,
ANEURALNETWORKS_RSQRT = 83,