ie_icnn_network_stats.hpp
Go to the documentation of this file.
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  */
69 public:
70  /**
71  * @brief The constructor which creates NetworkNodeStats object
72  */
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
NetworkNodeStats()
The constructor which creates NetworkNodeStats object.
Definition: ie_icnn_network_stats.hpp:73
std::map< std::string, NetworkNodeStatsPtr > NetworkStatsMap
A map of pairs: name of a layer and related statistics.
Definition: ie_icnn_network_stats.hpp:34
Inference Engine API.
Definition: ie_argmax_layer.hpp:15
std::weak_ptr< NetworkNodeStats > NetworkNodeStatsWeakPtr
A smart pointer to the NetworkNodeStats object.
Definition: ie_icnn_network_stats.hpp:30
std::vector< float > _maxOutputs
Vector of floats which contains maximum values of layers activations.
Definition: ie_icnn_network_stats.hpp:97
virtual const NetworkStatsMap & getNodesStats() const =0
Gets a map which contains layers with statistics.
virtual void setNodesStats(const NetworkStatsMap &stats)=0
Sets a map which contains layers with statistics.
virtual bool isEmpty() const =0
Checks if a container is empty.
std::shared_ptr< NetworkNodeStats > NetworkNodeStatsPtr
A shared pointer to the NetworkNodeStats object.
Definition: ie_icnn_network_stats.hpp:26
This class implements a container which stores statistics for a layer.
Definition: ie_icnn_network_stats.hpp:68
A header file for the Inference Engine plugins destruction mechanism.
This is the interface to describe the NN topology scoring statistics.
Definition: ie_icnn_network_stats.hpp:39
NetworkNodeStats(int statCount)
The constructor which creates NetworkNodeStats object with filled statistics.
Definition: ie_icnn_network_stats.hpp:79
std::vector< float > _minOutputs
Vector of floats which contains minimum values of layers activations.
Definition: ie_icnn_network_stats.hpp:93