Files
openvino/inference-engine/include/ie_data.h

178 lines
4.3 KiB
C
Raw Normal View History

2020-02-11 22:48:49 +03:00
// Copyright (C) 2018-2020 Intel Corporation
2018-10-16 13:45:03 +03:00
// SPDX-License-Identifier: Apache-2.0
//
/**
* @brief This header file defines the main Data representation node.
2020-02-11 22:48:49 +03:00
*
2018-10-16 13:45:03 +03:00
* @file ie_data.h
*/
#pragma once
#include <map>
#include <memory>
2020-02-11 22:48:49 +03:00
#include <string>
2018-10-16 13:45:03 +03:00
#include <vector>
2020-02-11 22:48:49 +03:00
#include "details/ie_exception.hpp"
2018-10-16 13:45:03 +03:00
#include "ie_api.h"
#include "ie_common.h"
#include "ie_layouts.h"
2020-02-11 22:48:49 +03:00
#include "ie_precision.hpp"
2018-10-16 13:45:03 +03:00
namespace InferenceEngine {
/**
* @brief This class represents the main Data representation node.
*
* The NN graphs are di-graphs consisting of data nodes and layer nodes.
*/
2020-02-11 22:48:49 +03:00
2018-10-16 13:45:03 +03:00
class INFERENCE_ENGINE_API_CLASS(Data) {
public:
/**
* @brief An empty constructor (dimensionless)
2020-02-11 22:48:49 +03:00
*
2018-10-16 13:45:03 +03:00
* @param name Name of the data node
* @param _precision Precision of the data
2019-10-04 19:26:43 +03:00
* @param layout Data layout
2018-10-16 13:45:03 +03:00
*/
2020-02-11 22:48:49 +03:00
Data(const std::string& name, Precision _precision, Layout layout = NCHW);
2018-10-16 13:45:03 +03:00
/**
* @brief A constructor with tensor descriptor
2020-02-11 22:48:49 +03:00
*
2018-10-16 13:45:03 +03:00
* @param name Name of the data node
* @param desc Tensor descriptor
*/
2020-02-11 22:48:49 +03:00
Data(const std::string& name, const TensorDesc& desc);
2018-10-16 13:45:03 +03:00
2019-08-09 19:02:42 +03:00
/**
2020-02-11 22:48:49 +03:00
* @brief A virtual destructor
2019-08-09 19:02:42 +03:00
*/
2020-02-11 22:48:49 +03:00
virtual ~Data() = default;
2019-08-09 19:02:42 +03:00
2018-10-16 13:45:03 +03:00
/**
* @brief Checks if the current node is resolved
2020-02-11 22:48:49 +03:00
*
2018-10-16 13:45:03 +03:00
* @return true if resolved, false otherwise.
*/
bool isInitialized() const;
/**
* @brief Sets the data dimensions.
2020-02-11 22:48:49 +03:00
*
2018-10-16 13:45:03 +03:00
* After the current node is marked as resolved.
2020-02-11 22:48:49 +03:00
*
2018-10-16 13:45:03 +03:00
* @param a_dims Tensor dimensions to set
*/
2020-02-11 22:48:49 +03:00
void setDims(const SizeVector& a_dims);
2018-10-16 13:45:03 +03:00
/**
2020-02-11 22:48:49 +03:00
* @brief Sets the layout value for this Data instance
*
* @param layout Layout value to set
*/
2018-10-16 13:45:03 +03:00
void setLayout(Layout layout);
2019-04-12 18:25:53 +03:00
/**
* @brief changes dims and layout at same time
2020-02-11 22:48:49 +03:00
*
2019-04-12 18:25:53 +03:00
* @param dims new dimensions
* @param layout new layout
*/
2020-02-11 22:48:49 +03:00
void reshape(const SizeVector& dims, Layout layout);
2019-04-12 18:25:53 +03:00
2018-10-16 13:45:03 +03:00
/**
2020-02-11 22:48:49 +03:00
* @brief Gets the layout value for this Data instance
*/
2018-10-16 13:45:03 +03:00
Layout getLayout() const;
/**
2020-02-11 22:48:49 +03:00
* @brief Gets Tensor descriptor reference
*
* @return reference to TensorDesc
*/
2018-10-16 13:45:03 +03:00
const TensorDesc& getTensorDesc() const;
/**
* @brief Gets a precision type of this Data instance
2020-02-11 22:48:49 +03:00
*
2018-10-16 13:45:03 +03:00
* @return Precision type
*/
const Precision& getPrecision() const;
/**
2019-08-09 19:02:42 +03:00
* @brief Sets a precision type of this Data instance
2020-02-11 22:48:49 +03:00
*
2019-08-09 19:02:42 +03:00
* @param precision Precision of the data
2018-10-16 13:45:03 +03:00
*/
void setPrecision(const Precision& precision);
/**
* @return data dimensions
*/
const SizeVector& getDims() const;
/**
* @deprecated Migrate to IR v10 and work with ngraph::Function directly. The method will be removed in 2021.1
2020-04-13 21:17:23 +03:00
* @brief Returns an owner of this data layer, parent layer in di-graph
* @return A weak pointer to CNNLayer that creates this data
2018-10-16 13:45:03 +03:00
*/
2020-04-13 21:17:23 +03:00
INFERENCE_ENGINE_INTERNAL("Migrate to IR v10 and work with ngraph::Function directly")
2020-02-11 22:48:49 +03:00
virtual CNNLayerWeakPtr& getCreatorLayer();
2018-10-16 13:45:03 +03:00
/**
* @return name of the data object
*/
const std::string& getName() const;
2019-08-09 19:02:42 +03:00
/**
* @brief Sets a name the Data object
2020-02-11 22:48:49 +03:00
*
2019-10-04 19:26:43 +03:00
* @param newName Name of the data node
2019-08-09 19:02:42 +03:00
*/
void setName(const std::string& newName);
2018-10-16 13:45:03 +03:00
/**
* @deprecated Migrate to IR v10 and work with ngraph::Function directly. The method will be removed in 2021.1
2020-04-13 21:17:23 +03:00
* @brief Privates child layers in di-graph
* @return A map of child layers
2018-10-16 13:45:03 +03:00
*/
2020-04-13 21:17:23 +03:00
INFERENCE_ENGINE_INTERNAL("Migrate to IR v10 and work with ngraph::Function directly")
2020-02-11 22:48:49 +03:00
virtual std::map<std::string, CNNLayerPtr>& getInputTo();
2018-10-16 13:45:03 +03:00
/**
* @return convenient arbitrary user data holder
*/
const UserValue& getUserObject() const;
2020-02-11 22:48:49 +03:00
2018-10-16 13:45:03 +03:00
private:
2020-02-11 22:48:49 +03:00
/**
* @brief A pointer to the layer that creates this data element, null for input data elements
*/
CNNLayerWeakPtr creatorLayer;
/**
* @brief A unique name that identifies this data node
*/
std::string name;
/**
* @brief A map of layers that use this node as input.
* It is useful for recursive NN graph traversal.
*/
std::map<std::string, CNNLayerPtr> inputTo;
/**
* @brief A user utility place holder
*/
UserValue userObject;
/**
* @brief A tensor descriptor
*/
mutable TensorDesc tensorDesc;
2018-10-16 13:45:03 +03:00
};
} // namespace InferenceEngine