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
 
std::unordered_map< ir::IOIndex, ir::Layoutinput_layout
 
std::unordered_map< ir::IOIndex, ir::Layoutoutput_layout
 
std::unordered_map< ir::IOIndex, ir::TypeInfoinput_type
 
std::unordered_map< ir::IOIndex, ir::TypeInfooutput_type
 
int graph_dump_level
 
std::string executor
 
ManualSchedulerOptions manual_scheduler_options
 
bool he_scheduler
 
bool he_profiling_mode
 
bool internal_output_alloc
 
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 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::Call] = builtin_id;
118 manual_scheduler_options.opcode_to_backend[ir::OpCode::Permute] = builtin_id;
119
120 // FIXME This is a workaround for bcq operations, should remove it
121 manual_scheduler_options.opcode_to_backend[ir::OpCode::BCQFullyConnected] = "bcq";
122 manual_scheduler_options.opcode_to_backend[ir::OpCode::BCQGather] = "bcq";
123
124 // FIXME This is a workaround for bulk operations, should remove it
125 manual_scheduler_options.opcode_to_backend[ir::OpCode::Bulk] = "trix";
126}
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(), 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 128 of file CompilerOptions.cc.

129{
130 VERBOSE(Compiler) << std::boolalpha << "==== Compiler Options ====" << std::endl;
131 VERBOSE(Compiler) << "backend_list : "
132 << nnfw::misc::join(backend_list.begin(), backend_list.end(), "/") << std::endl;
133 VERBOSE(Compiler) << "graph_dump_level : " << graph_dump_level << std::endl;
134 VERBOSE(Compiler) << "executor : " << executor << std::endl;
135 VERBOSE(Compiler) << "manual backend_for_all : " << manual_scheduler_options.backend_for_all
136 << std::endl;
137 VERBOSE(Compiler) << "manual_scheduler_options : "
138 << getOpBackends(manual_scheduler_options.opcode_to_backend) << std::endl;
139 VERBOSE(Compiler) << "he_scheduler : " << he_scheduler << std::endl;
140 VERBOSE(Compiler) << "he_profiling_mode : " << he_profiling_mode << std::endl;
141 VERBOSE(Compiler) << "internal_output_alloc : " << internal_output_alloc << 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, internal_output_alloc, nnfw::misc::join(), manual_scheduler_options, onert::compiler::ManualSchedulerOptions::opcode_to_backend, and VERBOSE.

Referenced by onert::compiler::Compiler::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 81 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

◆ input_layout

std::unordered_map<ir::IOIndex, ir::Layout> onert::compiler::CompilerOptions::input_layout

Definition at line 68 of file CompilerOptions.h.

Referenced by onert::compiler::pass::PermutationIOPass::run().

◆ input_type

std::unordered_map<ir::IOIndex, ir::TypeInfo> onert::compiler::CompilerOptions::input_type

Definition at line 70 of file CompilerOptions.h.

Referenced by onert::compiler::pass::PermutationIOPass::run().

◆ internal_output_alloc

bool onert::compiler::CompilerOptions::internal_output_alloc

Definition at line 79 of file CompilerOptions.h.

Referenced by onert::compiler::Compiler::compile(), and verboseOptions().

◆ manual_scheduler_options

ManualSchedulerOptions onert::compiler::CompilerOptions::manual_scheduler_options

◆ output_layout

std::unordered_map<ir::IOIndex, ir::Layout> onert::compiler::CompilerOptions::output_layout

Definition at line 69 of file CompilerOptions.h.

Referenced by onert::compiler::pass::PermutationIOPass::run().

◆ output_type

std::unordered_map<ir::IOIndex, ir::TypeInfo> onert::compiler::CompilerOptions::output_type

Definition at line 71 of file CompilerOptions.h.

Referenced by onert::compiler::pass::PermutationIOPass::run().

◆ workspace_dir

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

Definition at line 82 of file CompilerOptions.h.


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