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

173 lines
3.7 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) {
class Impl;
2018-10-16 13:45:03 +03:00
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
/**
* @brief A copy constructor
*
* @param data A data object to copy from
*/
Data(const Data& data);
/**
* @brief An assignment operator
*
* @param data A data object to copy from
* @return An assigned object
*/
Data & operator = (const Data& data);
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;
/**
* @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
/**
* @return convenient arbitrary user data holder
*/
const UserValue& getUserObject() const;
2020-02-11 22:48:49 +03:00
/**
* @private
* @brief Don't touch this field. An implementation details for Data object.
2020-02-11 22:48:49 +03:00
*/
std::shared_ptr<Impl> _impl;
2020-02-11 22:48:49 +03:00
private:
2020-02-11 22:48:49 +03:00
/**
* @brief A unique name that identifies this data node
*/
std::string name;
/**
* @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