Merge remote-tracking branch 'upstream/3.4' into merge-3.4
[platform/upstream/opencv.git] / modules / dnn / src / onnx / onnx_graph_simplifier.hpp
1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4
5 // Copyright (C) 2020, Intel Corporation, all rights reserved.
6 // Third party copyrights are property of their respective owners.
7
8 #ifndef __OPENCV_DNN_ONNX_SIMPLIFIER_HPP__
9 #define __OPENCV_DNN_ONNX_SIMPLIFIER_HPP__
10
11 #include "../precomp.hpp"
12
13 #if defined(__GNUC__) && __GNUC__ >= 5
14 #pragma GCC diagnostic push
15 #pragma GCC diagnostic ignored "-Wsuggest-override"
16 #endif
17 #include "opencv-onnx.pb.h"
18 #if defined(__GNUC__) && __GNUC__ >= 5
19 #pragma GCC diagnostic pop
20 #endif
21
22 namespace cv { namespace dnn {
23 CV__DNN_INLINE_NS_BEGIN
24
25 void simplifySubgraphs(opencv_onnx::GraphProto& net);
26
27 template<typename T1, typename T2>
28 void convertInt64ToInt32(const T1& src, T2& dst, int size)
29 {
30     for (int i = 0; i < size; i++)
31     {
32         dst[i] = saturate_cast<int32_t>(src[i]);
33     }
34 }
35
36 Mat getMatFromTensor(opencv_onnx::TensorProto& tensor_proto);
37
38 CV__DNN_INLINE_NS_END
39 }}  // namespace dnn, namespace cv
40
41 #endif  // __OPENCV_DNN_ONNX_SIMPLIFIER_HPP__