ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
onert::compiler::CompilerOptions Struct Reference

#include <CompilerOptions.h>

Collaboration diagram for onert::compiler::CompilerOptions:

Public Member Functions

void forceInternalOptions ()
 Force default values of CompilerOptions for correct compilations.
 
void verboseOptions ()
 Print option value.
 

Static Public Member Functions

static std::unique_ptr< CompilerOptionsfromGlobalConfig ()
 Set default values for CompilerOptions.
 

Data Fields

std::vector< std::string > backend_list
 
int graph_dump_level
 
std::string executor
 
ManualSchedulerOptions manual_scheduler_options
 
bool he_scheduler
 
bool he_profiling_mode
 
bool fp16_enable
 
std::string workspace_dir
 

Detailed Description

Definition at line 40 of file CompilerOptions.h.

Member Function Documentation

◆ forceInternalOptions()

void onert::compiler::CompilerOptions::forceInternalOptions ( )

Force default values of CompilerOptions for correct compilations.

Note
This should be called after CompilerOptions setting is finished to prevent value overwriting

Definition at line 111 of file CompilerOptions.cc.

112{
113 // Set control flow backend for control flow operators
114 auto &builtin_id = backend::builtin::Config::ID;
115 manual_scheduler_options.opcode_to_backend[ir::OpCode::If] = builtin_id;
116 manual_scheduler_options.opcode_to_backend[ir::OpCode::While] = builtin_id;
117 manual_scheduler_options.opcode_to_backend[ir::OpCode::Permute] = builtin_id;
118
119 // FIXME This is a workaround for bcq operations, should remove it
120 manual_scheduler_options.opcode_to_backend[ir::OpCode::BCQFullyConnected] = "bcq";
121 manual_scheduler_options.opcode_to_backend[ir::OpCode::BCQGather] = "bcq";
122
123 // FIXME This is a workaround for bulk operations, should remove it
124 manual_scheduler_options.opcode_to_backend[ir::OpCode::Bulk] = "trix";
125}
static std::string ID
Definition Config.h:30
ManualSchedulerOptions manual_scheduler_options
std::unordered_map< ir::OpCode, std::string > opcode_to_backend

References onert::backend::builtin::Config::ID, manual_scheduler_options, and onert::compiler::ManualSchedulerOptions::opcode_to_backend.

Referenced by onert::compiler::Compiler::compile(), onert::compiler::MultiModelCompiler::compile(), and onert::compiler::train::TrainingCompiler::compile().

◆ fromGlobalConfig()

std::unique_ptr< CompilerOptions > onert::compiler::CompilerOptions::fromGlobalConfig ( )
static

Set default values for CompilerOptions.

Returns
Generated CompileOption
Note
All these default values should not be fetched from Env when we stop supporting Android NNAPI.

Definition at line 75 of file CompilerOptions.cc.

76{
77 auto o = std::make_unique<CompilerOptions>();
78 o->backend_list = nnfw::misc::split(util::getConfigString(util::config::BACKENDS), ';');
79 o->graph_dump_level = util::getConfigInt(util::config::GRAPH_DOT_DUMP);
80 o->executor = util::getConfigString(util::config::EXECUTOR);
81 o->he_scheduler = util::getConfigBool(util::config::USE_SCHEDULER);
82 o->he_profiling_mode = util::getConfigBool(util::config::PROFILING_MODE);
83 o->fp16_enable = util::getConfigBool(util::config::FP16_ENABLE);
84 o->workspace_dir = util::getConfigString(util::config::WORKSPACE_DIR);
85 {
86 // Backend for all
87 auto &ms_options = o->manual_scheduler_options;
88
89 // Default value for op_backend_all is first element in the backend list
90 ms_options.backend_for_all = util::getConfigString(util::config::OP_BACKEND_ALLOPS);
91
92// Opcode to Backend
93#define OP(OpName) \
94 { \
95 const auto &backend_str = util::getConfigString(util::config::OP_BACKEND_##OpName); \
96 if (!backend_str.empty()) \
97 { \
98 ms_options.opcode_to_backend[ir::OpCode::OpName] = backend_str; \
99 } \
100 }
101#include "ir/Operations.lst"
102#undef OP
103
104 // Index to Backend
105 auto map_str = util::getConfigString(util::config::OP_BACKEND_MAP);
106 ms_options.setBackendMap(map_str);
107 }
108 return o;
109}
std::vector< std::string > split(const std::string &s, char delim)
bool getConfigBool(const std::string &key)
std::string getConfigString(const std::string &key)
int getConfigInt(const std::string &key)

References onert::util::getConfigBool(), onert::util::getConfigInt(), onert::util::getConfigString(), and nnfw::misc::split().

◆ verboseOptions()

void onert::compiler::CompilerOptions::verboseOptions ( )

Print option value.

Definition at line 127 of file CompilerOptions.cc.

128{
129 VERBOSE(Compiler) << std::boolalpha << "==== Compiler Options ====" << std::endl;
130 VERBOSE(Compiler) << "backend_list : "
131 << nnfw::misc::join(backend_list.begin(), backend_list.end(), "/") << std::endl;
132 VERBOSE(Compiler) << "graph_dump_level : " << graph_dump_level << std::endl;
133 VERBOSE(Compiler) << "executor : " << executor << std::endl;
134 VERBOSE(Compiler) << "manual backend_for_all : " << manual_scheduler_options.backend_for_all
135 << std::endl;
136 VERBOSE(Compiler) << "manual_scheduler_options : "
137 << getOpBackends(manual_scheduler_options.opcode_to_backend) << std::endl;
138 VERBOSE(Compiler) << "he_scheduler : " << he_scheduler << std::endl;
139 VERBOSE(Compiler) << "he_profiling_mode : " << he_profiling_mode << std::endl;
140 VERBOSE(Compiler) << "fp16_enable : " << fp16_enable << std::endl
141 << std::noboolalpha;
142}
#define VERBOSE(name, lv)
Definition Log.h:71
std::string join(InputIt first, InputIt last, const std::string &concat)
std::vector< std::string > backend_list

References onert::compiler::ManualSchedulerOptions::backend_for_all, backend_list, executor, fp16_enable, graph_dump_level, he_profiling_mode, he_scheduler, nnfw::misc::join(), manual_scheduler_options, onert::compiler::ManualSchedulerOptions::opcode_to_backend, and VERBOSE.

Referenced by onert::compiler::Compiler::compile(), onert::compiler::MultiModelCompiler::compile(), and onert::compiler::train::TrainingCompiler::compile().

Field Documentation

◆ backend_list

std::vector<std::string> onert::compiler::CompilerOptions::backend_list

Definition at line 65 of file CompilerOptions.h.

Referenced by onert::compiler::ManualScheduler::schedule(), and verboseOptions().

◆ executor

std::string onert::compiler::CompilerOptions::executor

◆ fp16_enable

bool onert::compiler::CompilerOptions::fp16_enable

Definition at line 73 of file CompilerOptions.h.

Referenced by verboseOptions().

◆ graph_dump_level

int onert::compiler::CompilerOptions::graph_dump_level

◆ he_profiling_mode

bool onert::compiler::CompilerOptions::he_profiling_mode

◆ he_scheduler

bool onert::compiler::CompilerOptions::he_scheduler

◆ manual_scheduler_options

ManualSchedulerOptions onert::compiler::CompilerOptions::manual_scheduler_options

◆ workspace_dir

std::string onert::compiler::CompilerOptions::workspace_dir

Definition at line 74 of file CompilerOptions.h.


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