Fix elementwise with const tensor parsing.
PiperOrigin-RevId: 303164498 Change-Id: Ic2698fe46b9753ee614b291d187ab5074958629a
This commit is contained in:
parent
fccc0ae3f8
commit
e410e94e52
@ -1092,11 +1092,15 @@ class ElementwiseOperationParser : public TFLiteOperationParser {
|
|||||||
/*runtime_inputs=*/1,
|
/*runtime_inputs=*/1,
|
||||||
/*const_inputs=*/0,
|
/*const_inputs=*/0,
|
||||||
/*outputs=*/1));
|
/*outputs=*/1));
|
||||||
} else if (IsTwoArgumentOperation()) {
|
// For some elementwise operations (currently only for SUB operation)
|
||||||
RETURN_IF_ERROR(CheckInputsConstsOutputs(context, tflite_node,
|
// second condition may be false. But it's worth checking the next case
|
||||||
|
// with const input, which may be supported.
|
||||||
|
} else if (IsTwoArgumentOperation() &&
|
||||||
|
CheckInputsConstsOutputs(context, tflite_node,
|
||||||
/*runtime_inputs=*/2,
|
/*runtime_inputs=*/2,
|
||||||
/*const_inputs=*/0,
|
/*const_inputs=*/0,
|
||||||
/*outputs=*/1));
|
/*outputs=*/1)
|
||||||
|
.ok()) {
|
||||||
} else if (IsTwoArgumentOperationWithConst()) {
|
} else if (IsTwoArgumentOperationWithConst()) {
|
||||||
RETURN_IF_ERROR(CheckInputsConstsOutputs(context, tflite_node,
|
RETURN_IF_ERROR(CheckInputsConstsOutputs(context, tflite_node,
|
||||||
/*runtime_inputs=*/1,
|
/*runtime_inputs=*/1,
|
||||||
@ -1124,11 +1128,13 @@ class ElementwiseOperationParser : public TFLiteOperationParser {
|
|||||||
/*outputs=*/1));
|
/*outputs=*/1));
|
||||||
|
|
||||||
RETURN_IF_ERROR(reader->AddInput(node, 0));
|
RETURN_IF_ERROR(reader->AddInput(node, 0));
|
||||||
} else if (IsTwoArgumentOperation()) {
|
} else if (IsTwoArgumentOperation() &&
|
||||||
RETURN_IF_ERROR(reader->VerifyInputsConstsOutputs(tflite_node,
|
reader
|
||||||
|
->VerifyInputsConstsOutputs(tflite_node,
|
||||||
/*runtime_inputs=*/2,
|
/*runtime_inputs=*/2,
|
||||||
/*const_inputs=*/0,
|
/*const_inputs=*/0,
|
||||||
/*outputs=*/1));
|
/*outputs=*/1)
|
||||||
|
.ok()) {
|
||||||
if (tflite_node->inputs->size != 2) {
|
if (tflite_node->inputs->size != 2) {
|
||||||
return absl::InvalidArgumentError("Applies only two input tensors");
|
return absl::InvalidArgumentError("Applies only two input tensors");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user