Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / inference_engine / shape_infer / const_infer / ie_const_infer_holder.hpp
1 // Copyright (C) 2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <string>
8 #include <vector>
9 #include <list>
10 #include <map>
11 #include <memory>
12
13 #include <ie_iextension.h>
14 #include "details/caseless.hpp"
15 #include <description_buffer.hpp>
16 #include "ie_const_infer_impl.hpp"
17
18 namespace InferenceEngine {
19 namespace ShapeInfer {
20
21 /**
22  *@brief Holder of const infer implementations for build-in IE layers, that plugins support out-of-the-box
23  */
24 class INFERENCE_ENGINE_API_CLASS(ConstInferHolder) {
25     struct ImplsHolder {
26         using Ptr = std::shared_ptr<ImplsHolder>;
27         InferenceEngine::details::caseless_map<std::string, IConstInferImpl::Ptr> list;
28     };
29 public:
30     std::list<std::string> getConstInferTypes();
31
32     IConstInferImpl::Ptr getConstInferImpl(const std::string& type);
33
34     static void AddImpl(const std::string& name, const IConstInferImpl::Ptr& impl);
35
36 private:
37     static ImplsHolder::Ptr GetImplsHolder();
38 };
39
40 template<typename Impl>
41 class ImplRegisterBase {
42 public:
43     explicit ImplRegisterBase(const std::string& type) {
44         ConstInferHolder::AddImpl(type, std::make_shared<Impl>(type));
45     }
46 };
47
48 #define REG_CONST_INFER_FOR_TYPE(__prim, __type) \
49 static ImplRegisterBase<__prim> __ci_reg__##__type(#__type)
50
51 }  // namespace ShapeInfer
52 }  // namespace InferenceEngine