mmdeploy/csrc/graph/common.h
lzhangzz a494a6f6ff
[SDK] sync changes according to performance benchmarks (#297)
* sync SDK changes according to performance benchmarks

* fix end-of-file lint

* fix clang-format issue

* fix clang-format by adding 'clang-format off'

* remove useless casts

* remove 'data' argument of 'operator()'

* change 'Tensor2Img' to 'TensorToImg' according to spec

* correct tensor's name according spec

Co-authored-by: lvhan028 <lvhan_028@163.com>
2021-12-16 13:51:22 +08:00

37 lines
951 B
C++

// Copyright (c) OpenMMLab. All rights reserved.
#ifndef MMDEPLOY_SRC_GRAPH_COMMON_H_
#define MMDEPLOY_SRC_GRAPH_COMMON_H_
#include "core/graph.h"
#include "core/module.h"
#include "core/registry.h"
#include "core/value.h"
namespace mmdeploy::graph {
template <typename EntryType, typename RetType = typename Creator<EntryType>::ReturnType>
inline Result<RetType> CreateFromRegistry(const Value& config, const char* key = "type") {
INFO("config: {}", config);
auto type = config[key].get<std::string>();
auto creator = Registry<EntryType>::Get().GetCreator(type);
if (!creator) {
return Status(eEntryNotFound);
}
auto inst = creator->Create(config);
if (!inst) {
ERROR("failed to create module: {}", type);
return Status(eFail);
}
return std::move(inst);
}
class BaseNode : public Node {
protected:
explicit BaseNode(const Value& cfg);
};
} // namespace mmdeploy::graph
#endif // MMDEPLOY_SRC_GRAPH_COMMON_H_