// // PluginKernel.cpp // MNN // // Created by MNN on 2020/04/07. // Copyright © 2018, Alibaba Group Holding Limited // #ifdef MNN_WITH_PLUGIN #include #include #include "MNN/plugin/PluginKernel.hpp" namespace MNN { namespace plugin { CPUKernelContext::CPUKernelContext(const std::string& op_type, // NOLINT Backend* backend, // NOLINT const std::vector& inputs, // NOLINT const std::vector& outputs, const std::string& dir_path) // NOLINT : op_type_(op_type), backend_(backend), dir_path_(dir_path), PluginContext(inputs, outputs) { } template using Factory = typename ComputeKernelRegistry::Factory; template /*static*/ auto ComputeKernelRegistry::getFactoryMap() // NOLINT -> std::unordered_map* { static std::unordered_map gFactoryMap; return &gFactoryMap; } template /*static*/ bool ComputeKernelRegistry::add( // NOLINT const std::string& name, Factory factory) { auto* gFactoryMap = ComputeKernelRegistry::getFactoryMap(); if (gFactoryMap->count(name)) { MNN_PRINT("Factory has been registered for name %s.", name.c_str()); } return gFactoryMap->emplace(name, factory).second; } template /*static*/ PluginKernelT* ComputeKernelRegistry::get( // NOLINT const std::string& name) { auto* gFactoryMap = ComputeKernelRegistry::getFactoryMap(); if (!gFactoryMap->count(name)) { MNN_PRINT("Factory has not been registered for name %s.", name.c_str()); return nullptr; } return gFactoryMap->at(name)(); } template class ComputeKernelRegistry; } // namespace plugin } // namespace MNN #endif // #ifdef MNN_WITH_PLUGIN