| 443 | } |
| 444 | |
| 445 | TfLiteStatus Subgraph::CheckTensorIndices(const char* label, const int* indices, |
| 446 | int length) { |
| 447 | // Making sure kOptionalTensor is not re-defined to something other than -1. |
| 448 | static_assert(kOptionalTensor == -1, "kOptionalTensor should be defined -1"); |
| 449 | |
| 450 | for (int i = 0; i < length; i++) { |
| 451 | int index = indices[i]; |
| 452 | // Continue if index == kOptionalTensor before additional comparisons below, |
| 453 | // size_t(-1) is always >= context_tensors_size. |
| 454 | if (index == kOptionalTensor) { |
| 455 | continue; |
| 456 | } |
| 457 | if (index < 0 || static_cast<size_t>(index) >= context_.tensors_size) { |
| 458 | ReportError( |
| 459 | "Invalid tensor index %d in %s. The subgraph has %d tensors\n", index, |
| 460 | label, context_.tensors_size); |
| 461 | consistent_ = false; |
| 462 | return kTfLiteError; |
| 463 | } |
| 464 | } |
| 465 | return kTfLiteOk; |
| 466 | } |
| 467 | |
| 468 | // We have two arrays and we need to check that elements from one array don't |
| 469 | // show up in the other. We could sort both arrays and then iterate with two |
nothing calls this directly
no test coverage detected