Skip to content

Commit

Permalink
[luci/import] Revise ImportEx (#13850)
Browse files Browse the repository at this point in the history
This will revise ImportEx ctro with graph builder source and new importModule method.

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark authored Aug 30, 2024
1 parent 5f2f409 commit 7aee01c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions compiler/luci/import/include/luci/ImporterEx.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

#include "luci/IR/Module.h"

// NOTE we should include "luci/Import/GraphBuilderRegistry.h" but
// tizen_gbs build fails if included
// TODO enable include and remove forward declaration
// #include "luci/Import/GraphBuilderRegistry.h"
struct GraphBuilderSource;

#include <memory>
#include <string>

Expand All @@ -30,8 +36,24 @@ class ImporterEx final
public:
ImporterEx() = default;

public:
// TODO remove this after embedded-import-value-test has moved to onert-micro
explicit ImporterEx(const GraphBuilderSource *source) : _source{source}
{
// DO NOTHING
}

public:
std::unique_ptr<Module> importVerifyModule(const std::string &input_path) const;

// NOTE importModule is for embedded-import-value-test
// embedded-import-value-test uses constant data from file(actually ROM)
// so unloading file will break the precondition
// TODO remove this after embedded-import-value-test has moved to onert-micro
std::unique_ptr<Module> importModule(std::vector<char> &model_data) const;

private:
const GraphBuilderSource *_source = nullptr;
};

} // namespace luci
Expand Down
9 changes: 9 additions & 0 deletions compiler/luci/import/src/ImporterEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,13 @@ std::unique_ptr<Module> ImporterEx::importVerifyModule(const std::string &input_
return importer.importModule(circle_model);
}

std::unique_ptr<Module> ImporterEx::importModule(std::vector<char> &model_data) const
{
auto data_data = reinterpret_cast<uint8_t *>(model_data.data());
auto data_size = model_data.size();

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

} // namespace luci

0 comments on commit 7aee01c

Please sign in to comment.