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::IODesc, ir::Layoutinput_layout
 
std::unordered_map< ir::IODesc, ir::Layoutoutput_layout
 
std::unordered_map< ir::IODesc, ir::TypeInfoinput_type
 
std::unordered_map< ir::IODesc, 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 41 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 108 of file CompilerOptions.cc.

109{
110 // Set builtin backend for control flow operators
111 auto &builtin_id = backend::builtin::Config::ID;
112 manual_scheduler_options.opcode_to_backend[ir::OpCode::If] = builtin_id;
113 manual_scheduler_options.opcode_to_backend[ir::OpCode::While] = builtin_id;
114 manual_scheduler_options.opcode_to_backend[ir::OpCode::Call] = builtin_id;
115 manual_scheduler_options.opcode_to_backend[ir::OpCode::Permute] = builtin_id;
116
117 // Set builtin backend for custom operator
118 manual_scheduler_options.opcode_to_backend[ir::OpCode::Custom] = builtin_id;
119}
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// Opcode to Backend
90#define OP(OpName) \
91 { \
92 const auto &backend_str = util::getConfigString(util::config::OP_BACKEND_##OpName); \
93 if (!backend_str.empty()) \
94 { \
95 ms_options.opcode_to_backend[ir::OpCode::OpName] = backend_str; \
96 } \
97 }
98#include "ir/Operations.lst"
99#undef OP
100
101 // Index to Backend
102 auto map_str = util::getConfigString(util::config::OP_BACKEND_MAP);
103 ms_options.setBackendMap(map_str);
104 }
105 return o;
106}
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 121 of file CompilerOptions.cc.

122{
123 VERBOSE(Compiler) << std::boolalpha << "==== Compiler Options ====" << std::endl;
124 VERBOSE(Compiler) << "backend_list : "
125 << nnfw::misc::join(backend_list.begin(), backend_list.end(), "/") << std::endl;
126 VERBOSE(Compiler) << "graph_dump_level : " << graph_dump_level << std::endl;
127 VERBOSE(Compiler) << "executor : " << executor << std::endl;
128 VERBOSE(Compiler) << "manual_scheduler_options : "
129 << getOpBackends(manual_scheduler_options.opcode_to_backend) << std::endl;
130 VERBOSE(Compiler) << "he_scheduler : " << he_scheduler << std::endl;
131 VERBOSE(Compiler) << "he_profiling_mode : " << he_profiling_mode << std::endl;
132 VERBOSE(Compiler) << "internal_output_alloc : " << internal_output_alloc << std::endl;
133 VERBOSE(Compiler) << "fp16_enable : " << fp16_enable << std::endl
134 << std::noboolalpha;
135}
#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 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 66 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 80 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::IODesc, ir::Layout> onert::compiler::CompilerOptions::input_layout

Definition at line 67 of file CompilerOptions.h.

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

◆ input_type

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

Definition at line 69 of file CompilerOptions.h.

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

◆ internal_output_alloc

bool onert::compiler::CompilerOptions::internal_output_alloc

Definition at line 78 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::IODesc, ir::Layout> onert::compiler::CompilerOptions::output_layout

Definition at line 68 of file CompilerOptions.h.

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

◆ output_type

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

Definition at line 70 of file CompilerOptions.h.

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

◆ workspace_dir

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

Definition at line 81 of file CompilerOptions.h.


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