!24447 [MS][LITE]fix bug of tflite model verify

Merge pull request !24447 from mengyuanli/check_third_party_model2
This commit is contained in:
i-robot 2021-09-30 03:27:42 +00:00 committed by Gitee
commit 11fe8954c5
1 changed files with 4 additions and 0 deletions

View File

@ -66,6 +66,10 @@ STATUS TfliteModelParser::TfliteModelVerify() {
for (auto &subgraph : tflite_model_->subgraphs) { for (auto &subgraph : tflite_model_->subgraphs) {
auto all_singraph_tensor_size = subgraph->tensors.size(); auto all_singraph_tensor_size = subgraph->tensors.size();
if (subgraph->inputs.empty() || subgraph->outputs.empty()) {
MS_LOG(ERROR) << "tflite subgraph inputs or outputs is empty.";
return RET_ERROR;
}
if (std::any_of(subgraph->inputs.begin(), subgraph->inputs.end(), [&all_singraph_tensor_size](int32_t index) { if (std::any_of(subgraph->inputs.begin(), subgraph->inputs.end(), [&all_singraph_tensor_size](int32_t index) {
return index >= static_cast<int32_t>(all_singraph_tensor_size) || index < 0; return index >= static_cast<int32_t>(all_singraph_tensor_size) || index < 0;
})) { })) {