ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
luci::ImporterEx Class Referencefinal

#include <ImporterEx.h>

Public Member Functions

 ImporterEx ()
 
 ImporterEx (const std::function< void(const std::exception &)> &error_handler)
 
 ImporterEx (const GraphBuilderSource *source)
 
std::unique_ptr< ModuleimportVerifyModule (const std::string &input_path) const
 
std::unique_ptr< ModuleimportModule (const std::vector< char > &model_data) const
 

Detailed Description

Definition at line 35 of file ImporterEx.h.

Constructor & Destructor Documentation

◆ ImporterEx() [1/3]

luci::ImporterEx::ImporterEx ( )

Definition at line 37 of file ImporterEx.cpp.

38 : _error_handler{[](const std::exception &e) { std::cerr << e.what() << std::endl; }}
39{
40}

◆ ImporterEx() [2/3]

luci::ImporterEx::ImporterEx ( const std::function< void(const std::exception &)> &  error_handler)

Definition at line 42 of file ImporterEx.cpp.

43 : _error_handler{error_handler}
44{
45 if (!error_handler)
46 {
47 throw std::runtime_error{"The error handler passed to ImporterEx is invalid"};
48 }
49}

◆ ImporterEx() [3/3]

luci::ImporterEx::ImporterEx ( const GraphBuilderSource source)
explicit

Definition at line 51 of file ImporterEx.cpp.

51: ImporterEx{} { _source = source; }

Member Function Documentation

◆ importModule()

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

Definition at line 85 of file ImporterEx.cpp.

86{
87 auto data_data = reinterpret_cast<const uint8_t *>(model_data.data());
88 auto data_size = model_data.size();
89
90 Importer importer(_source);
91 return importer.importModule(data_data, data_size);
92}
model_data
Definition infer.py:82

Referenced by entry().

◆ importVerifyModule()

std::unique_ptr< Module > luci::ImporterEx::importVerifyModule ( const std::string &  input_path) const

Definition at line 53 of file ImporterEx.cpp.

54{
55 foder::FileLoader file_loader{input_path};
56 std::vector<char> model_data;
57
58 try
59 {
60 model_data = file_loader.load();
61 }
62 catch (const std::runtime_error &err)
63 {
64 _error_handler(err);
65 return nullptr;
66 }
67
68 auto data_data = reinterpret_cast<uint8_t *>(model_data.data());
69 auto data_size = model_data.size();
70
71 if (data_size < FLATBUFFERS_SIZE_MAX)
72 {
73 flatbuffers::Verifier verifier{data_data, data_size};
74 if (!circle::VerifyModelBuffer(verifier))
75 {
76 _error_handler(std::runtime_error{"ERROR: Invalid input file '" + input_path + "'"});
77 return nullptr;
78 }
79 }
80
81 Importer importer(_source);
82 return importer.importModule(data_data, data_size);
83}
constexpr uint64_t FLATBUFFERS_SIZE_MAX

References FLATBUFFERS_SIZE_MAX.

Referenced by mpqsolver::core::H5FileDataProvider::H5FileDataProvider(), dalgona::Dalgona::initialize(), and record_minmax::RecordMinMax::initialize().


The documentation for this class was generated from the following files: