Publishing 2020.1 content
[platform/upstream/dldt.git] / inference-engine / include / ie_icnn_network_stats.hpp
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 /**
6  * @brief This is a header file for the ICNNNetworkStats class
7  *
8  * @file ie_icnn_network_stats.hpp
9  */
10 #pragma once
11
12 #include <limits>
13 #include <map>
14 #include <memory>
15 #include <string>
16 #include <vector>
17
18 #include "details/ie_irelease.hpp"
19
20 namespace InferenceEngine {
21
22 class NetworkNodeStats;
23 /**
24  * @brief A shared pointer to the NetworkNodeStats object
25  */
26 using NetworkNodeStatsPtr = std::shared_ptr<NetworkNodeStats>;
27 /**
28  * @brief A smart pointer to the NetworkNodeStats object
29  */
30 using NetworkNodeStatsWeakPtr = std::weak_ptr<NetworkNodeStats>;
31 /**
32  * @brief A map of pairs: name of a layer and related statistics
33  */
34 using NetworkStatsMap = std::map<std::string, NetworkNodeStatsPtr>;
35 /**
36  * @class ICNNNetworkStats
37  * @brief This is the interface to describe the NN topology scoring statistics
38  */
39 class ICNNNetworkStats : public details::IRelease {
40 public:
41     /**
42      * @brief Sets a map which contains layers with statistics
43      *
44      * @param stats A map which is set
45      * Abstract method
46      */
47     virtual void setNodesStats(const NetworkStatsMap& stats) = 0;
48     /**
49      * @brief Gets a map which contains layers with statistics
50      *
51      * Abstract method
52      * @return A NetworkStatsMap object
53      */
54     virtual const NetworkStatsMap& getNodesStats() const = 0;
55     /**
56      * @brief Checks if a container is empty
57      *
58      * Abstract method
59      * @return A bool value which shows whether a container is empty
60      */
61     virtual bool isEmpty() const = 0;
62 };
63
64 /**
65  * @class NetworkNodeStats
66  * @brief This class implements a container which stores statistics for a layer
67  */
68 class NetworkNodeStats {
69 public:
70     /**
71      * @brief The constructor which creates NetworkNodeStats object
72      */
73     NetworkNodeStats() {}
74     /**
75      * @brief The constructor which creates NetworkNodeStats object with filled statistics
76      *
77      * @param statCount The number of minimum/maximum values in statistics
78      */
79     explicit NetworkNodeStats(int statCount) {
80         float mn = (std::numeric_limits<float>::max)();
81         float mx = (std::numeric_limits<float>::min)();
82
83         for (int i = 0; i < statCount; i++) {
84             _minOutputs.push_back(mn);
85             _maxOutputs.push_back(mx);
86         }
87     }
88
89 public:
90     /**
91      * @brief Vector of floats which contains minimum values of layers activations
92      */
93     std::vector<float> _minOutputs;
94     /**
95      * @brief Vector of floats which contains maximum values of layers activations
96      */
97     std::vector<float> _maxOutputs;
98 };
99
100 }  // namespace InferenceEngine