MCPcopy Create free account
hub / github.com/Samsung/ONE / ReadModule

Function ReadModule

compiler/luci/tester/src/ReadModule.cpp:31–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29#include <vector>
30
31std::unique_ptr<luci::Module> ReadModule(std::string &input_path)
32{
33 // Load model from the file
34 foder::FileLoader file_loader{input_path};
35 std::vector<char> model_data = file_loader.load();
36
37 auto *data_data = reinterpret_cast<uint8_t *>(model_data.data());
38 luci::Importer importer;
39 auto module = importer.importModule(data_data, model_data.size());
40 if (module == nullptr)
41 {
42 std::cerr << "ERROR: Failed to load circle '" << input_path << "'" << std::endl;
43 return nullptr;
44 }
45 assert(module->size() > 0);
46
47 for (size_t g = 0; g < module->size(); ++g)
48 {
49 auto graph = module->graph(g);
50 if (graph == nullptr)
51 return nullptr;
52
53 {
54 logo::Phase phase;
55
56 phase.emplace_back(std::make_unique<luci::CircleShapeInferencePass>());
57 phase.emplace_back(std::make_unique<luci::CircleTypeInferencePass>());
58
59 logo::PhaseRunner<logo::PhaseStrategy::Saturate> phase_runner{graph};
60 phase_runner.run(phase);
61 }
62
63 if (!luci::validate(graph))
64 return nullptr;
65 }
66 return module;
67}

Callers 2

entryFunction · 0.85
entryFunction · 0.85

Calls 8

validateFunction · 0.50
loadMethod · 0.45
dataMethod · 0.45
importModuleMethod · 0.45
sizeMethod · 0.45
graphMethod · 0.45
emplace_backMethod · 0.45
runMethod · 0.45

Tested by 2

entryFunction · 0.68
entryFunction · 0.68