1 // Copyright (C) 2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
7 #include "ie_built_in_impl.hpp"
14 namespace InferenceEngine {
15 namespace ShapeInfer {
18 *@brief Implementation of Shape inference for Range layer
20 class RangeShapeProp : public BuiltInShapeInferImpl {
22 explicit RangeShapeProp(const std::string& type) : BuiltInShapeInferImpl(type) {}
24 void inferShapesImpl(const std::vector<Blob::CPtr>& inBlobs,
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 RangeLayer rangeLayer(lp);
30 rangeLayer.params = params;
31 rangeLayer.type = _type;
32 validate(&rangeLayer, inBlobs, params, blobs);
34 const size_t RANGE_START = 0;
35 const size_t RANGE_LIMIT = 1;
36 const size_t RANGE_DELTA = 2;
38 float start = (inBlobs[RANGE_START]->cbuffer().as<float*>() +
39 inBlobs[RANGE_START]->getTensorDesc().getBlockingDesc().getOffsetPadding())[0];
40 float limit = (inBlobs[RANGE_LIMIT]->cbuffer().as<float*>() +
41 inBlobs[RANGE_LIMIT]->getTensorDesc().getBlockingDesc().getOffsetPadding())[0];
42 float delta = (inBlobs[RANGE_DELTA]->cbuffer().as<float*>() +
43 inBlobs[RANGE_DELTA]->getTensorDesc().getBlockingDesc().getOffsetPadding())[0];
44 size_t work_amount_dst = std::floor(std::abs((limit - start) / delta));
45 outShapes = {{work_amount_dst}};
49 } // namespace ShapeInfer
50 } // namespace InferenceEngine