Skip to content

Commit

Permalink
CVS-102308 Read tflite model to vector (openvinotoolkit#17048)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgenya Stepyreva authored Apr 19, 2023
1 parent d7083fb commit 497a19e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
11 changes: 3 additions & 8 deletions src/frontends/tensorflow_lite/src/graph_iterator_flatbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@ GraphIteratorFlatBuffer::GraphIteratorFlatBuffer(const std::wstring& path)
#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT

GraphIteratorFlatBuffer::GraphIteratorFlatBuffer(const std::string& path) {
std::ifstream model_file;
model_file.open(path, std::ios::binary | std::ios::in);
std::ifstream model_file(path, std::ios::binary | std::ios::in);
FRONT_END_GENERAL_CHECK(model_file && model_file.is_open(), "Model file does not exist: ", path);

model_file.seekg(0, std::ios::end);
auto length = model_file.tellg();
model_file.seekg(0, std::ios::beg);
char* data = new char[length];
model_file.read(data, length);
m_data = {(std::istreambuf_iterator<char>(model_file)), std::istreambuf_iterator<char>()};
model_file.close();

m_model = std::shared_ptr<tflite::Model>(tflite::GetMutableModel(data), [](tflite::Model* p) {});
m_model = tflite::GetModel(m_data.data());
const auto subgraphs = m_model->subgraphs();
FRONT_END_GENERAL_CHECK(subgraphs->size() == 1,
"Number of sub-graphs in the model is ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ struct TensorInfo {

class GraphIteratorFlatBuffer {
size_t node_index = 0;
std::vector<uint8_t> m_data;
std::vector<const tflite::Operator*> m_nodes;
std::shared_ptr<tflite::Model> m_model;
const tflite::Model* m_model;

public:
explicit GraphIteratorFlatBuffer(const std::string& path);
Expand Down

0 comments on commit 497a19e

Please sign in to comment.