Rename singleton objects' getter metohd `instance` to `get`.
(Since it is shorter)
Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
* @brief Get TensorLogger instance
* @return The TensorLogger instance
*/
- static TensorLogger &instance()
+ static TensorLogger &get()
{
static TensorLogger instance;
return instance;
std::cout << "[NNAPI TEST] PASSED" << std::endl;
if (_param.tensor_logging)
- nnfw::tflite::TensorLogger::instance().save(_param.log_path, *tfl_interp);
+ nnfw::tflite::TensorLogger::get().save(_param.log_path, *tfl_interp);
return 0;
}
IMemoryPlanner *MemoryManager::createMemoryPlanner()
{
auto planner_id = util::getConfigString(util::config::CPU_MEMORY_PLANNER);
- return MemoryPlannerFactory::instance().create(planner_id);
+ return MemoryPlannerFactory::get().create(planner_id);
}
void MemoryManager::buildTensor(const model::OperandIndex &ind, const model::OperandInfo &info)
namespace cpu
{
-MemoryPlannerFactory &MemoryPlannerFactory::instance()
+MemoryPlannerFactory &MemoryPlannerFactory::get()
{
static MemoryPlannerFactory instance;
return instance;
class MemoryPlannerFactory
{
public:
- static MemoryPlannerFactory &instance();
+ static MemoryPlannerFactory &get();
private:
MemoryPlannerFactory() = default;
IMemoryPlanner *MemoryManager::createMemoryPlanner()
{
auto planner_id = util::getConfigString(util::config::CPU_MEMORY_PLANNER);
- return MemoryPlannerFactory::instance().create(planner_id);
+ return MemoryPlannerFactory::get().create(planner_id);
}
void MemoryManager::buildTensor(const model::OperandIndex &ind, const model::OperandInfo &info,
namespace srcn
{
-MemoryPlannerFactory &MemoryPlannerFactory::instance()
+MemoryPlannerFactory &MemoryPlannerFactory::get()
{
static MemoryPlannerFactory instance;
return instance;
class MemoryPlannerFactory
{
public:
- static MemoryPlannerFactory &instance();
+ static MemoryPlannerFactory &get();
private:
MemoryPlannerFactory() = default;
namespace backend
{
-BackendManager &BackendManager::instance()
+BackendManager &BackendManager::get()
{
static BackendManager object;
return object;
using backend_create_t = Backend *(*)();
using backend_destroy_t = void (*)(Backend *);
- static BackendManager &instance();
+ static BackendManager &get();
public:
Backend *get(const std::string &key);
std::shared_ptr<model::OperationIndexMap<int64_t>> indexed_ranks;
if (util::getConfigBool(util::config::USE_SCHEDULER))
{
- auto scheduler =
- compiler::HEScheduler(_graph->operands(), backend::BackendManager::instance().getAll(),
- _graph->getKernelBuilder());
+ auto scheduler = compiler::HEScheduler(
+ _graph->operands(), backend::BackendManager::get().getAll(), _graph->getKernelBuilder());
br = scheduler.schedule(*_graph);
indexed_ranks = scheduler.getIndexedRanks();
}
const std::string executor_str = util::getConfigString(util::config::EXECUTOR);
_executor =
- std::shared_ptr<exec::IExecutor>{ExecutorFactory::instance().create(executor_str, *_graph)};
+ std::shared_ptr<exec::IExecutor>{ExecutorFactory::get().create(executor_str, *_graph)};
_executor->setIndexedRanks(indexed_ranks);
/********************************
* Code generation phase finished
namespace compiler
{
-ExecutorFactory &ExecutorFactory::instance()
+ExecutorFactory &ExecutorFactory::get()
{
static ExecutorFactory singleton;
return singleton;
// TODO Add optimization passes
// Initialize constant tensors
- for (const auto backend : backend::BackendManager::instance().getAll())
+ for (const auto backend : backend::BackendManager::get().getAll())
{
linear->getBackendContext(backend)->constant_initializer->run();
}
}
// Initialize constant tensors
- for (const auto backend : backend::BackendManager::instance().getAll())
+ for (const auto backend : backend::BackendManager::get().getAll())
{
graph.backend_resolver()->getBackendContext(backend)->constant_initializer->run();
}
std::move(tensor_mgrs), std::move(code_map)};
if (util::getConfigBool(util::config::PROFILING_MODE))
{
- auto et = std::make_shared<backend::ExecTime>(backend::BackendManager::instance().getAll());
+ auto et = std::make_shared<backend::ExecTime>(backend::BackendManager::get().getAll());
std::unique_ptr<exec::IExecutionObserver> obs =
nnfw::cpp14::make_unique<exec::ProfileObserver>(et);
exec->addObserver(std::move(obs));
class ExecutorFactory
{
public:
- static ExecutorFactory &instance();
+ static ExecutorFactory &get();
public:
exec::IExecutor *create(const std::string &id, graph::Graph &graph);
std::unique_ptr<BackendResolver> ManualScheduler::schedule(const graph::Graph &graph)
{
auto backend_resolver = nnfw::cpp14::make_unique<compiler::BackendResolver>(
- graph.operands(), backend::BackendManager::instance().getAll(), graph.getKernelBuilder());
+ graph.operands(), backend::BackendManager::get().getAll(), graph.getKernelBuilder());
// 1. Backend for All operations
auto backend_all_str = util::getConfigString(util::config::OP_BACKEND_ALLOPS);
while (pos != std::string::npos)
{
backend_all_str = backends_str.substr(prev_pos, pos - prev_pos);
- backend_all = backend::BackendManager::instance().get(backend_all_str);
+ backend_all = backend::BackendManager::get().get(backend_all_str);
if (backend_all != nullptr)
break;
if (backend_all == nullptr && prev_pos < backends_str.size())
{
backend_all_str = backends_str.substr(prev_pos);
- backend_all = backend::BackendManager::instance().get(backend_all_str);
+ backend_all = backend::BackendManager::get().get(backend_all_str);
}
}
else
{
- backend_all = backend::BackendManager::instance().get(backend_all_str);
+ backend_all = backend::BackendManager::get().get(backend_all_str);
}
VERBOSE(ManualScheduler) << "Default backend for all ops: " << backend_all_str << std::endl;
// 2. Backend per operation type
std::unordered_map<std::type_index, backend::Backend *> op_type_map;
// By default, Custom uses cpu backend
- op_type_map[typeid(model::operation::Custom)] = backend::BackendManager::instance().get("cpu");
+ op_type_map[typeid(model::operation::Custom)] = backend::BackendManager::get().get("cpu");
#define OP(InternalName) \
{ \
const auto &backend_str = util::getConfigString(util::config::OP_BACKEND_##InternalName); \
if (!backend_str.empty()) \
{ \
- auto backend = backend::BackendManager::instance().get(backend_str); \
+ auto backend = backend::BackendManager::get().get(backend_str); \
VERBOSE(Lower) << "backend for " << #InternalName << ": " << backend_str << std::endl; \
op_type_map[typeid(model::operation::InternalName)] = backend; \
} \
graph.operations().at(model::OperationIndex{key}); // Check if exist, or this wil throw
backend_resolver->setBackend(model::OperationIndex{key},
- backend::BackendManager::instance().get(val));
+ backend::BackendManager::get().get(val));
}
}
catch (...)
// 4. Operations that are specially handled
// All configuration above will be ignored(overwritten)
- op_type_map[typeid(model::operation::Permute)] = backend::BackendManager::instance().get("cpu");
+ op_type_map[typeid(model::operation::Permute)] = backend::BackendManager::get().get("cpu");
// Dump final assignment
backend_resolver->iterate(
static const auto map = []() {
std::unordered_map<const backend::Backend *, std::string> ret;
uint32_t index = 1; // Start from 1 to avoid 0(red) which is too dark :(
- for (const auto backend : backend::BackendManager::instance().getAll())
+ for (const auto backend : backend::BackendManager::get().getAll())
{
ret.emplace(backend, Node::BG_COLORS[index]);
index = (index + 1) % (sizeof(Node::BG_COLORS) / sizeof(Node::BG_COLORS[0]));
// NOTE Permute may not have specific layout because the layout of input and output may be
// different.
const auto permute_node_layout = model::Layout::UNKNOWN;
- const auto permute_node_backend = backend::BackendManager::instance().getDefault();
+ const auto permute_node_backend = backend::BackendManager::get().getDefault();
const operand::PermuteFactor permute_node_factor{permute_node_backend, permute_node_layout};
// Update LowerInfo of input operand
_operand_usages[outputs[i]] = OperandUsage::OPERATION_OUTPUT;
}
- auto &factory = OperationFactory::instance();
+ auto &factory = OperationFactory::get();
OperationFactory::Param param{inputCount, inputs, outputCount, outputs};
auto node = factory.create(type, param, _model->operands);
_operand_usages[outputs[i]] = OperandUsage::OPERATION_OUTPUT;
}
- auto &factory = OperationFactory::instance();
+ auto &factory = OperationFactory::get();
OperationFactory::Param param{inputCount, inputs, outputCount, outputs};
auto node = factory.create(type, param, _model->operands);
} // namespace
-OperationFactory &OperationFactory::instance()
+OperationFactory &OperationFactory::get()
{
static OperationFactory factory;
return factory;
neurun::model::Operands &)>;
public:
- static OperationFactory &instance();
+ static OperationFactory &get();
private:
OperationFactory();