1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
7 #include <description_buffer.hpp>
8 #include "ie_built_in_impl.hpp"
17 namespace InferenceEngine {
18 namespace ShapeInfer {
21 *@brief Implementation of Shape inference for Gemm layer
23 class GemmShapeProp : public BuiltInShapeInferImpl {
25 explicit GemmShapeProp(const std::string& type) : BuiltInShapeInferImpl(type) {}
27 void inferShapesImpl(const std::vector<Blob::CPtr>& inBlobs,
28 const std::map<std::string, std::string>& params,
29 const std::map<std::string, Blob::Ptr>& blobs,
30 std::vector<SizeVector>& outShapes) override {
31 // TODO: primitive does not support 5D tensor yet
33 GemmLayer gemmLayer(lp);
34 gemmLayer.params = params;
35 gemmLayer.type = _type;
36 validate(&gemmLayer, inBlobs, params, blobs);
38 auto dims0 = inShapes[0];
39 auto dims1 = inShapes[1];
42 for (int idx = 0; idx < dims0.size() - 2; idx++) {
43 unsigned long max_dim = dims0[idx] > dims1[idx] ? dims0[idx] : dims1[idx];
45 if (inShapes.size() == 3) {
46 auto dims2 = inShapes[2];
47 max_dim = max_dim > dims2[idx] ? max_dim : dims2[idx];
50 shapes.push_back(max_dim);
53 unsigned long xAxis = dims0.size() - 1;
54 unsigned long yAxis = dims0.size() - 2;
56 shapes.push_back(dims0[yAxis]);
57 shapes.push_back(dims1[xAxis]);
58 outShapes.push_back(shapes);
62 } // namespace ShapeInfer
63 } // namespace InferenceEngine