if (backend_all_str.compare("none") != 0)
{
VERBOSE(BackendResolver) << "Use backend for all ops: " << backend_all_str << std::endl;
-#define OP(InternalName, IsNnApi) \
- if (IsNnApi) \
- { \
- auto backend = _backend_manager->get(backend_all_str); \
- _gen_map[typeid(model::operation::InternalName)] = backend; \
+#define OP(InternalName, IsNnApi) \
+ if (IsNnApi) \
+ { \
+ auto backend = _backend_manager->get(backend_all_str); \
+ _gen_map_deprecated[typeid(model::operation::InternalName)] = backend; \
}
#include "model/Operations.lst"
#undef OP
auto backend = _backend_manager->get(backend_str); \
VERBOSE(BackendResolver) << "backend for " << #InternalName << ": " << backend_str \
<< std::endl; \
- _gen_map[typeid(model::operation::InternalName)] = backend; \
+ _gen_map_deprecated[typeid(model::operation::InternalName)] = backend; \
}
#include "model/Operations.lst"
}
public:
- const backend::Backend *getBackend(const std::type_index &type) { return _gen_map[type]; }
+ const backend::Backend *getBackend(const std::type_index &type)
+ {
+ return _gen_map_deprecated[type];
+ }
const backend::Backend *getDefaultBackend() const
{
backend::Backend *default_backend = _backend_manager->get("cpu");
return default_backend;
}
+ const backend::Backend *getBackend(const model::OperationIndex &index)
+ {
+ return _gen_map.at(index);
+ }
+
+ void setBackend(const model::OperationIndex &index, const backend::Backend *backend)
+ {
+ _gen_map[index] = backend;
+ }
+
private:
- std::unordered_map<std::type_index, backend::Backend *> _gen_map;
+ // TODO: remove all usage of _gen_map_deprecated
+ std::unordered_map<std::type_index, backend::Backend *> _gen_map_deprecated;
+ std::unordered_map<model::OperationIndex, const backend::Backend *> _gen_map;
std::shared_ptr<backend::BackendManager> _backend_manager;
};