Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[luci/import] Revise importVerifyModule #13869

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions compiler/luci/import/src/ImporterEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,18 @@ std::unique_ptr<Module> ImporterEx::importVerifyModule(const std::string &input_
return nullptr;
}

flatbuffers::Verifier verifier{reinterpret_cast<uint8_t *>(model_data.data()), model_data.size()};
auto data_data = reinterpret_cast<uint8_t *>(model_data.data());
auto data_size = model_data.size();

flatbuffers::Verifier verifier{data_data, data_size};
if (!circle::VerifyModelBuffer(verifier))
{
std::cerr << "ERROR: Invalid input file '" << input_path << "'" << std::endl;
return nullptr;
}

const circle::Model *circle_model = circle::GetModel(model_data.data());
if (circle_model == nullptr)
{
std::cerr << "ERROR: Failed to load circle '" << input_path << "'" << std::endl;
return nullptr;
}

Importer importer;
return importer.importModule(circle_model);
Importer importer(_source);
return importer.importModule(data_data, data_size);
}

std::unique_ptr<Module> ImporterEx::importModule(std::vector<char> &model_data) const
Expand Down