ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::odc::CodegenManager Class Reference

#include <CodegenManager.h>

Public Member Functions

 CodegenManager ()=default
 
 CodegenManager (CodegenManager const &)=delete
 
CodegenManageroperator= (CodegenManager const &)=delete
 
void exportModelPath (const std::string &model_path)
 Set model path to export compiled model.
 
const std::string & exportModelPath () const
 Get model path to export compiled model.
 
bool codegen (const std::string &model_path, const char *target, CodegenPreference pref)
 Execute code generator.
 

Detailed Description

Definition at line 36 of file CodegenManager.h.

Constructor & Destructor Documentation

◆ CodegenManager() [1/2]

onert::odc::CodegenManager::CodegenManager ( )
default

◆ CodegenManager() [2/2]

onert::odc::CodegenManager::CodegenManager ( CodegenManager const &  )
delete

Member Function Documentation

◆ codegen()

bool onert::odc::CodegenManager::codegen ( const std::string &  model_path,
const char *  target,
CodegenPreference  pref 
)

Execute code generator.

Parameters
model[in]Model to be compiled
target[in]Target backend name This target string will be used to find a backend library. The name of target backend library should follow the following rules: 'lib' + {backend extension} + '-gen' + {lib extension} And the target string should be a name except 'lib' and {lib extension}. For example, if the backend extension is 'aaa', the backend library name should be 'libaaa-gen.so', and the target string should be 'aaa-gen'.
prefCodegenPreference Codegen preference

Definition at line 29 of file CodegenManager.cc.

31{
32 if (target == nullptr)
33 throw std::runtime_error("Target string is not set");
34
35 if (_export_model_path.empty())
36 throw std::runtime_error("Export model path is not set");
37
38 if (model_path.empty())
39 throw std::runtime_error("Model path does not exist");
40
41 // codegen function is thread-unsafe
42 static std::mutex lock;
43 std::lock_guard<std::mutex> guard(lock);
44
45 auto &codegen_loader = CodegenLoader::instance();
46 codegen_loader.loadLibrary(target);
47 const auto code_generator = codegen_loader.get();
48 const auto result = code_generator->codegen(model_path.c_str(), _export_model_path.c_str());
49 codegen_loader.unloadLibrary();
50
51 return (result == 0);
52}
static CodegenLoader & instance()
Get singleton instance of CodegenLoader.
result
Definition infer.py:103

References onert::odc::CodegenLoader::instance().

◆ exportModelPath() [1/2]

const std::string & onert::odc::CodegenManager::exportModelPath ( ) const
inline

Get model path to export compiled model.

Returns
Model path to export compiled model

Definition at line 57 of file CodegenManager.h.

57{ return _export_model_path; }

◆ exportModelPath() [2/2]

void onert::odc::CodegenManager::exportModelPath ( const std::string &  model_path)
inline

Set model path to export compiled model.

Parameters
model_pathModel path to export compiled model

Definition at line 50 of file CodegenManager.h.

50{ _export_model_path = model_path; }

◆ operator=()

CodegenManager & onert::odc::CodegenManager::operator= ( CodegenManager const &  )
delete

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