| 511 | } |
| 512 | |
| 513 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
| 514 | auto* op_data = reinterpret_cast<OpData*>(node->user_data); |
| 515 | BufferMap* buffer_map = op_data->buffer_map; |
| 516 | |
| 517 | // Insert a tensor in the buffer map for all inputs that are not constant. |
| 518 | // Constants were handled in Prepare() already. |
| 519 | for (auto tensor_index : op_data->subgraph_inputs) { |
| 520 | TfLiteTensor* tensor = &context->tensors[tensor_index]; |
| 521 | if (!IsConstantTensor(tensor)) { |
| 522 | // If this tensor is part of an earlier TF subgraph we should not add it |
| 523 | // to the BufferMap again, because TF already knows about it and its |
| 524 | // contents are kept automatically up-to-date. |
| 525 | if (!buffer_map->IsTensorFlowTensor(tensor_index)) { |
| 526 | buffer_map->SetFromTfLite(tensor_index, tensor); |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | // Execute the TensorFlow Ops sequentially. |
| 532 | for (auto& node_data : op_data->nodes) { |
| 533 | TFLITE_SCOPED_TAGGED_OPERATOR_PROFILE( |
| 534 | reinterpret_cast<Profiler*>(context->profiler), |
| 535 | node_data->name().c_str(), node_data->index()); |
| 536 | |
| 537 | auto status = ExecuteFlexOp(context, buffer_map, node_data.get()); |
| 538 | TF_LITE_ENSURE_OK(context, ConvertStatus(context, status)); |
| 539 | } |
| 540 | |
| 541 | for (auto tensor_index : op_data->subgraph_outputs) { |
| 542 | if (!buffer_map->HasTensor(tensor_index)) { |
| 543 | context->ReportError(context, "Cannot write to invalid tensor index %d", |
| 544 | tensor_index); |
| 545 | return kTfLiteError; |
| 546 | } |
| 547 | |
| 548 | TfLiteTensor* tensor = &context->tensors[tensor_index]; |
| 549 | TF_LITE_ENSURE_OK( |
| 550 | context, |
| 551 | CopyShapeAndType(context, buffer_map->GetTensor(tensor_index), tensor)); |
| 552 | tensor->buffer_handle = tensor_index; |
| 553 | tensor->data_is_stale = true; |
| 554 | } |
| 555 | |
| 556 | return kTfLiteOk; |
| 557 | } |
| 558 | |
| 559 | } // namespace kernel |
| 560 |
nothing calls this directly
no test coverage detected