ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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 42 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 113 of file CompilerOptions.cc.

114{
115 // Set control flow backend for control flow operators
116 auto &builtin_id = backend::builtin::Config::ID;
117 manual_scheduler_options.opcode_to_backend[ir::OpCode::If] = builtin_id;
118 manual_scheduler_options.opcode_to_backend[ir::OpCode::While] = builtin_id;
119 manual_scheduler_options.opcode_to_backend[ir::OpCode::Permute] = builtin_id;
120
121 // FIXME This is a workaround for bcq operations, should remove it
122 manual_scheduler_options.opcode_to_backend[ir::OpCode::BCQFullyConnected] = "bcq";
123 manual_scheduler_options.opcode_to_backend[ir::OpCode::BCQGather] = "bcq";
124
125 // FIXME This is a workaround for bulk operations, should remove it
126 manual_scheduler_options.opcode_to_backend[ir::OpCode::Bulk] = "trix";
127}
static std::string ID
Definition Config.h:34
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 77 of file CompilerOptions.cc.

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

130{
131 VERBOSE(Compiler) << std::boolalpha << "==== Compiler Options ====" << std::endl;
132 VERBOSE(Compiler) << "backend_list : "
133 << nnfw::misc::join(backend_list.begin(), backend_list.end(), "/") << std::endl;
134 VERBOSE(Compiler) << "graph_dump_level : " << graph_dump_level << std::endl;
135 VERBOSE(Compiler) << "executor : " << executor << std::endl;
136 VERBOSE(Compiler) << "manual backend_for_all : " << manual_scheduler_options.backend_for_all
137 << std::endl;
138 VERBOSE(Compiler) << "manual_scheduler_options : "
139 << getOpBackends(manual_scheduler_options.opcode_to_backend) << std::endl;
140 VERBOSE(Compiler) << "he_scheduler : " << he_scheduler << std::endl;
141 VERBOSE(Compiler) << "he_profiling_mode : " << he_profiling_mode << std::endl;
142 VERBOSE(Compiler) << "fp16_enable : " << fp16_enable << std::endl
143 << std::noboolalpha;
144}
#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 67 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 75 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 76 of file CompilerOptions.h.


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