Merge pull request #129 from asuhov/2019-r1
[platform/upstream/dldt.git] / inference-engine / src / inference_engine / shape_infer / const_infer / ie_const_infer_holder.cpp
1 // Copyright (C) 2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #ifdef __INTEL_COMPILER
6 #pragma warning disable: 2586
7 #endif
8
9
10 #include "ie_const_infer_holder.hpp"
11 #include "ie_mul_const_infer.hpp"
12 #include "ie_add_const_infer.hpp"
13 #include "ie_div_const_infer.hpp"
14 #include "ie_const_const_infer.hpp"
15 #include "ie_shape_const_infer.hpp"
16 #include "ie_power_const_infer.hpp"
17 #include "ie_tile_const_infer.hpp"
18 #include "ie_reshape_const_infer.hpp"
19 #include "ie_gather_const_infer.hpp"
20 #include "ie_split_const_infer.hpp"
21 #include "ie_concat_const_infer.hpp"
22 #include "ie_in_place_const_infer.hpp"
23 #include "ie_strided_slice_const_infer.hpp"
24 #include "ie_fill_const_infer.hpp"
25 #include "ie_range_const_infer.hpp"
26 #include <list>
27 #include <memory>
28 #include <string>
29
30 namespace InferenceEngine {
31 namespace ShapeInfer {
32
33 ConstInferHolder::ImplsHolder::Ptr ConstInferHolder::GetImplsHolder() {
34     static ImplsHolder::Ptr localHolder;
35     if (localHolder == nullptr) {
36         localHolder = std::make_shared<ImplsHolder>();
37     }
38     return localHolder;
39 }
40
41 void ConstInferHolder::AddImpl(const std::string& name, const IConstInferImpl::Ptr& impl) {
42     GetImplsHolder()->list[name] = impl;
43 }
44
45 std::list<std::string> ConstInferHolder::getConstInferTypes() {
46     std::list<std::string> types;
47     auto& factories = GetImplsHolder()->list;
48     for (const auto& factory : factories) {
49         types.push_back(factory.first);
50     }
51     return types;
52 }
53
54 IConstInferImpl::Ptr ConstInferHolder::getConstInferImpl(const std::string& type) {
55     auto& impls = ConstInferHolder::GetImplsHolder()->list;
56     if (impls.find(type) != impls.end()) {
57         return impls[type];
58     }
59     return nullptr;
60 }
61
62 REG_CONST_INFER_FOR_TYPE(MulConstInfer, Mul);
63 REG_CONST_INFER_FOR_TYPE(AddConstInfer, Add);
64 REG_CONST_INFER_FOR_TYPE(DivConstInfer, Div);
65 REG_CONST_INFER_FOR_TYPE(ShapeConstInfer, Shape);
66 REG_CONST_INFER_FOR_TYPE(ConstConstInfer, Const);
67 REG_CONST_INFER_FOR_TYPE(PowerConstInfer, Power);
68 REG_CONST_INFER_FOR_TYPE(TileConstInfer, Tile);
69 REG_CONST_INFER_FOR_TYPE(ReshapeConstInfer, Reshape);
70 REG_CONST_INFER_FOR_TYPE(GatherConstInfer, Gather);
71 REG_CONST_INFER_FOR_TYPE(SplitConstInfer, Split);
72 REG_CONST_INFER_FOR_TYPE(ConcatConstInfer, Concat);
73 REG_CONST_INFER_FOR_TYPE(InPlaceConstInfer, Unsqueeze);
74 REG_CONST_INFER_FOR_TYPE(InPlaceConstInfer, Squeeze);
75 REG_CONST_INFER_FOR_TYPE(StridedSliceConstInfer, StridedSlice);
76 REG_CONST_INFER_FOR_TYPE(FillConstInfer, Fill);
77 REG_CONST_INFER_FOR_TYPE(RangeConstInfer, Range);
78
79 }  // namespace ShapeInfer
80 }  // namespace InferenceEngine