1 // Copyright (C) 2018 Intel Corporation
3 // SPDX-License-Identifier: Apache-2.0
8 #include "ie_built_in_holder.hpp"
14 namespace InferenceEngine {
15 namespace ShapeInfer {
18 *@brief Implementation of Shape inference for Crop layer
20 class CropShapeProp : public BuiltInShapeInferImpl {
22 explicit CropShapeProp(const std::string& type) : BuiltInShapeInferImpl(type) {}
24 void inferShapesImpl(const std::vector<SizeVector>& inShapes,
25 const std::map<std::string, std::string>& params,
26 const std::map<std::string, Blob::Ptr>& blobs,
27 std::vector<SizeVector>& outShapes) override {
29 CropLayer cropLayer(lp);
30 cropLayer.params = params;
31 cropLayer.type = _type;
32 validate(&cropLayer, inShapes, params, blobs);
34 if (inShapes.size() != 2)
35 THROW_IE_EXCEPTION << "second input is required to infer shapes, re-generate IR with latest MO";
36 SizeVector cropShapes = inShapes[1];
37 outShapes.push_back(inShapes[0]);
38 for (size_t i = 0; i < cropLayer.axis.size(); i++) {
39 if (cropLayer.axis[i] >= outShapes[0].size())
40 THROW_IE_EXCEPTION << "Axis can't be more then number of output shapes";
41 outShapes[0][cropLayer.axis[i]] = cropShapes[cropLayer.axis[i]];
46 } // namespace ShapeInfer
47 } // namespace InferenceEngine