Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / include / ie_network.hpp
similarity index 70%
rename from inference-engine/include/ie_inetwork.hpp
rename to inference-engine/include/ie_network.hpp
index 41c02f0..b33e779 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Intel Corporation
+// Copyright (C) 2018-2019 Intel Corporation
 // SPDX-License-Identifier: Apache-2.0
 //
 
@@ -134,77 +134,152 @@ private:
 };
 
 /**
+ * This class describes port data
+ */
+class INFERENCE_ENGINE_API_CLASS(PortData) {
+public:
+    /**
+     * @brief A shared pointer to the PortData object.
+     */
+    using Ptr = std::shared_ptr<PortData>;
+
+    /**
+     * @brief Default constructor
+     */
+    PortData();
+
+    /**
+     * Creates port data with precision and shape
+     * @param shape Dimensions
+     * @param precision Precision
+     */
+    PortData(const SizeVector& shape, const Precision& precision);
+
+    /**
+     * @brief virtual destructor
+     */
+    virtual ~PortData() = default;
+
+    /**
+     * @brief Returns data
+     * @return Blob with data
+     */
+    const Blob::Ptr& getData() const;
+
+    /**
+     * @brief Sets data
+     * @param data Blob with data
+     */
+    void setData(const Blob::Ptr& data);
+
+    /**
+     * @brief Returns data parameters
+     * @return Map of parameters
+     */
+    const std::map<std::string, Parameter>& getParameters() const noexcept;
+
+    /**
+     * @brief Sets new shapes for data
+     * @param shape New shapes
+     */
+    void setShape(const SizeVector& shape);
+
+private:
+    Blob::Ptr data;
+    std::map<std::string, Parameter> parameters;
+
+    void createData(const TensorDesc& desc);
+};
+
+/**
  * @brief This class is the main object to describe the Inference Engine port.
  */
-class Port {
+class INFERENCE_ENGINE_API_CLASS(Port) {
 public:
     /**
      * @brief Default constructor of a port object.
      */
-    Port() = default;
+    Port();
     /**
      * @brief Constructor of a port object with shapes.
      * @param shapes port shapes
+     * @param precision Port precision
      */
-    explicit Port(const SizeVector& shapes): pShapes(shapes) {}
+    explicit Port(const SizeVector& shapes,
+                  const Precision& precision = Precision::UNSPECIFIED);
 
     /**
      * @brief Copy constructor.
      * @param port object to copy
      */
-    Port(const Port& port) {
-        this->pShapes = port.pShapes;
-    }
+    Port(const Port& port);
+
+    /**
+     * @brief Virtual destructor
+     */
+    virtual ~Port() = default;
+
+    /**
+     * @brief Compares the given Port with the current one
+     * @param rhs Port to compare with
+     * @return true if the given Port is equal to the current one, false - otherwise
+     */
+    bool operator== (const Port& rhs) const;
+
+    /**
+     * @brief Compares the given Port with the current one
+     * @param rhs Port to compare with
+     * @return true if the given Port is NOT equal to the current one, false - otherwise
+     */
+    bool operator!= (const Port& rhs) const;
 
     /**
      * @brief Returns a constant reference to a vector with shapes.
      * Shapes should be initialized if shape is empty.
      * @return constant reference to shapes
      */
-    const SizeVector& shape() const noexcept {
-        return pShapes;
-    }
+    const SizeVector& shape() const noexcept;
 
     /**
-     * @brief Returns a reference to a vector with shapes.
-     * Shapes should be initialized if shape is empty.
-     * @return reference to shapes
+     * @brief Sets new shapes for current port
+     * @param shape New shapes
      */
-    SizeVector& shape() noexcept {
-        return pShapes;
-    }
+    void setShape(const SizeVector& shape);
 
-private:
-    SizeVector pShapes;
-};
+    /**
+     * @brief Returns a constant reference to parameters
+     * @return Map with parameters
+     */
+    const std::map<std::string, Parameter>& getParameters() const noexcept;
 
-/**
- * @brief This class is the main interface to describe the Inference Engine layer parameters.
- * All methods here are constant and do not throw exceptions.
- */
-class IParameters {
-public:
     /**
-     * @brief A shared pointer to the IParameters object.
+     * @brief Sets new parameters for current port
+     * @param params New parameters
      */
-    using Ptr = std::shared_ptr<IParameters>;
+    void setParameters(const std::map<std::string, Parameter>& params) noexcept;
 
     /**
-     * @brief Virtual destructor for the parameters interface
+     * @brief Sets the new parameter for current port
+     * @param name Name of parameter
+     * @param param New value
      */
-    virtual ~IParameters() = default;
+    void setParameter(const std::string& name, const Parameter& param);
 
     /**
-     * @brief Returns a constant reference to a map with parameters.
-     * @return Map of parameters
+     * @brief Returns port data
+     * @return Port data
      */
-    virtual const std::map<std::string, Parameter>& getParameters() const noexcept = 0;
+    const PortData::Ptr& getData() const noexcept;
 
     /**
-     * @brief Returns a constant reference to a constant pointers to constant data.
-     * @return Map of constant pointers to constant data
+     * @brief Sets new port data for current port
+     * @param data Port data
      */
-    virtual const std::map<std::string, Blob::CPtr>& getConstantData() const noexcept = 0;
+    void setData(const PortData::Ptr& data);
+
+private:
+    std::map<std::string, Parameter> parameters;
+    PortData::Ptr data;
 };
 
 class INetwork;
@@ -218,10 +293,6 @@ class INetwotkIterator;
 class ILayer {
 public:
     /**
-     * @brief A shared pointer to the ILayer object
-     */
-    using Ptr = std::shared_ptr<ILayer>;
-    /**
      * @brief A shared pointer to the const ILayer object
      */
     using CPtr = std::shared_ptr<const ILayer>;
@@ -250,16 +321,10 @@ public:
     virtual const std::string& getType() const noexcept = 0;
 
     /**
-     * @brief Returns a constant smart pointer reference to a Network interface.
-     * @return Network interface smart pointer
-     */
-     virtual const std::shared_ptr<INetwork>& getGraph() const noexcept = 0;
-
-    /**
      * @brief Returns a constant smart pointer reference to a Parameters interface.
      * @return Parameters interface smart pointer
      */
-    virtual const IParameters::Ptr& getParameters() const noexcept = 0;
+    virtual const std::map<std::string, Parameter>& getParameters() const noexcept = 0;
 
     /**
      * @brief Returns a constant reference to a vector with input ports.
@@ -289,11 +354,11 @@ class INetworkIterator;
 class INetwork {
 public:
     /**
-     * @brief A shared pointer to the INetwork object.
+     * @brief A shared pointer to the constant INetwork object.
      */
-    using Ptr = std::shared_ptr<INetwork>;
+    using CPtr = std::shared_ptr<const INetwork>;
     /**
-     * @brief A constant iterator for INetwork objects definition
+     * @brief A constant iterator for INetwork definition
      */
     using const_iterator = details::INetworkIterator<const INetwork, const ILayer>;
 
@@ -326,19 +391,19 @@ public:
      * @param id Id of the Layer
      * @return Layer interface smart pointer
      */
-    virtual const ILayer::Ptr getLayer(idx_t id) const noexcept = 0;
+    virtual const ILayer::CPtr getLayer(idx_t id) const noexcept = 0;
 
     /**
      * @brief Returns a constant vector of input layers.
      * @return Vector of input layers
      */
-    virtual const std::vector<ILayer::Ptr> getInputs() const noexcept = 0;
+    virtual const std::vector<ILayer::CPtr> getInputs() const noexcept = 0;
 
     /**
      * @brief Returns a constant vector of output layers.
      * @return Vector of output layers
      */
-    virtual const std::vector<ILayer::Ptr> getOutputs() const noexcept = 0;
+    virtual const std::vector<ILayer::CPtr> getOutputs() const noexcept = 0;
 
     /**
      * @brief Returns a constant vector of connections for specific layer.