Merge pull request #129 from asuhov/2019-r1
[platform/upstream/dldt.git] / inference-engine / src / inference_engine / shape_infer / const_infer / ie_shape_const_infer.hpp
1 // Copyright (C) 2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <ie_blob.h>
8 #include <map>
9 #include <memory>
10 #include <string>
11 #include <vector>
12 #include <ie_layers.h>
13
14 namespace InferenceEngine {
15 namespace ShapeInfer {
16
17 /**
18  *@brief Implementation of Const inference for TBD layer
19  */
20 class ShapeConstInfer : public ConstInferImpl {
21 public:
22     explicit ShapeConstInfer(const std::string& type) : ConstInferImpl(type) {}
23
24     void inferImpl(const std::vector<Blob::CPtr>& inData,
25                    const std::map<std::string, std::string>& params,
26                    const std::map<std::string, Blob::Ptr>& blobs,
27                    std::vector<Blob::Ptr>& outData) override {
28         SizeVector inShape = (*inData.begin())->getTensorDesc().getDims();
29         auto outBlob = *outData.begin();
30         if (inShape.size() != outBlob->size()) THROW_IE_EXCEPTION << "Number of shapes don't match size of output";
31         auto* outBuffer = outBlob->buffer().as<float*>();
32         for (int i = 0; i < outBlob->size(); i++) {
33             outBuffer[i] = inShape[i];
34         }
35     }
36 };
37
38 }  // namespace ShapeInfer
39 }  // namespace InferenceEngine