Moved element_type() to MemoryBlob (#6549)
* Moved element_type() to MemoryBlob * Updated indentation in documentation * Added more fixes for precisions * Fixed documentation for new serialize methods
This commit is contained in:
parent
fb6b5a8275
commit
8b456cb9b4
@ -22,17 +22,17 @@ namespace InferenceEngine {
|
||||
|
||||
namespace gpu {
|
||||
/**
|
||||
* @brief This class represents an abstraction for GPU plugin remote context
|
||||
* which is shared with VA display object.
|
||||
* The plugin object derived from this class can be obtained either with
|
||||
* GetContext() method of Executable network or using CreateContext() Core call.
|
||||
* @note User can also obtain OpenCL context handle from this class.
|
||||
*/
|
||||
* @brief This class represents an abstraction for GPU plugin remote context
|
||||
* which is shared with VA display object.
|
||||
* The plugin object derived from this class can be obtained either with
|
||||
* GetContext() method of Executable network or using CreateContext() Core call.
|
||||
* @note User can also obtain OpenCL context handle from this class.
|
||||
*/
|
||||
class VAContext : public ClContext {
|
||||
public:
|
||||
/**
|
||||
* @brief A smart pointer to the VAContext object
|
||||
*/
|
||||
* @brief A smart pointer to the VAContext object
|
||||
*/
|
||||
using Ptr = std::shared_ptr<VAContext>;
|
||||
|
||||
/**
|
||||
@ -47,16 +47,16 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class represents an abstraction for GPU plugin remote blob
|
||||
* which is shared with VA output surface.
|
||||
* The plugin object derived from this class can be obtained with CreateBlob() call.
|
||||
* @note User can also obtain OpenCL 2D image handle from this class.
|
||||
*/
|
||||
* @brief This class represents an abstraction for GPU plugin remote blob
|
||||
* which is shared with VA output surface.
|
||||
* The plugin object derived from this class can be obtained with CreateBlob() call.
|
||||
* @note User can also obtain OpenCL 2D image handle from this class.
|
||||
*/
|
||||
class VASurfaceBlob : public ClImage2DBlob {
|
||||
public:
|
||||
/**
|
||||
* @brief A smart pointer to the VASurfaceBlob object
|
||||
*/
|
||||
* @brief A smart pointer to the VASurfaceBlob object
|
||||
*/
|
||||
using Ptr = std::shared_ptr<VASurfaceBlob>;
|
||||
|
||||
/**
|
||||
|
@ -11,8 +11,8 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief Definitions required by Khronos headers
|
||||
*/
|
||||
* @brief Definitions required by Khronos headers
|
||||
*/
|
||||
|
||||
#ifndef CL_HPP_ENABLE_EXCEPTIONS
|
||||
# define CL_HPP_ENABLE_EXCEPTIONS
|
||||
|
@ -44,63 +44,65 @@ namespace GPUContextParams {
|
||||
#define DECLARE_GPU_PARAM_KEY(name, ...) \
|
||||
static constexpr auto PARAM_##name = #name
|
||||
/**
|
||||
* @brief Shared device context type: can be either pure OpenCL (OCL)
|
||||
* or shared video decoder (VA_SHARED) context
|
||||
*/
|
||||
* @brief Shared device context type: can be either pure OpenCL (OCL)
|
||||
* or shared video decoder (VA_SHARED) context
|
||||
*/
|
||||
DECLARE_GPU_PARAM_KEY(CONTEXT_TYPE, std::string);
|
||||
/**
|
||||
* @brief Pure OpenCL device context
|
||||
*/
|
||||
* @brief Pure OpenCL device context
|
||||
*/
|
||||
DECLARE_GPU_PARAM_VALUE(OCL);
|
||||
/**
|
||||
* @brief Shared context (video decoder or D3D)
|
||||
*/
|
||||
* @brief Shared context (video decoder or D3D)
|
||||
*/
|
||||
DECLARE_GPU_PARAM_VALUE(VA_SHARED);
|
||||
|
||||
/**
|
||||
* @brief This key identifies OpenCL context handle
|
||||
* in a shared context or shared memory blob parameter map
|
||||
*/
|
||||
* @brief This key identifies OpenCL context handle
|
||||
* in a shared context or shared memory blob parameter map
|
||||
*/
|
||||
DECLARE_GPU_PARAM_KEY(OCL_CONTEXT, gpu_handle_param);
|
||||
|
||||
/**
|
||||
* @brief This key identifies video acceleration device/display handle
|
||||
* in a shared context or shared memory blob parameter map
|
||||
*/
|
||||
* @brief This key identifies video acceleration device/display handle
|
||||
* in a shared context or shared memory blob parameter map
|
||||
*/
|
||||
DECLARE_GPU_PARAM_KEY(VA_DEVICE, gpu_handle_param);
|
||||
|
||||
/**
|
||||
* @brief This key identifies type of internal shared memory
|
||||
* in a shared memory blob parameter map.
|
||||
*/
|
||||
* @brief This key identifies type of internal shared memory
|
||||
* in a shared memory blob parameter map.
|
||||
*/
|
||||
DECLARE_GPU_PARAM_KEY(SHARED_MEM_TYPE, std::string);
|
||||
/**
|
||||
* @brief Shared OpenCL buffer blob
|
||||
*/
|
||||
* @brief Shared OpenCL buffer blob
|
||||
*/
|
||||
DECLARE_GPU_PARAM_VALUE(OCL_BUFFER);
|
||||
/**
|
||||
* @brief Shared OpenCL 2D image blob
|
||||
*/
|
||||
* @brief Shared OpenCL 2D image blob
|
||||
*/
|
||||
DECLARE_GPU_PARAM_VALUE(OCL_IMAGE2D);
|
||||
|
||||
/**
|
||||
* @brief Shared video decoder surface or D3D 2D texture blob
|
||||
*/
|
||||
* @brief Shared video decoder surface or D3D 2D texture blob
|
||||
*/
|
||||
DECLARE_GPU_PARAM_VALUE(VA_SURFACE);
|
||||
|
||||
/**
|
||||
* @brief Shared D3D buffer blob
|
||||
*/
|
||||
* @brief Shared D3D buffer blob
|
||||
*/
|
||||
DECLARE_GPU_PARAM_VALUE(DX_BUFFER);
|
||||
|
||||
/**
|
||||
* @brief This key identifies OpenCL memory handle
|
||||
* in a shared memory blob parameter map
|
||||
*/
|
||||
* @brief This key identifies OpenCL memory handle
|
||||
* in a shared memory blob parameter map
|
||||
*/
|
||||
DECLARE_GPU_PARAM_KEY(MEM_HANDLE, gpu_handle_param);
|
||||
|
||||
/**
|
||||
* @brief This key identifies video decoder surface handle
|
||||
* in a shared memory blob parameter map
|
||||
*/
|
||||
* @brief This key identifies video decoder surface handle
|
||||
* in a shared memory blob parameter map
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
DECLARE_GPU_PARAM_KEY(DEV_OBJECT_HANDLE, gpu_handle_param);
|
||||
#else
|
||||
@ -108,9 +110,9 @@ DECLARE_GPU_PARAM_KEY(DEV_OBJECT_HANDLE, uint32_t);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This key identifies video decoder surface plane
|
||||
* in a shared memory blob parameter map
|
||||
*/
|
||||
* @brief This key identifies video decoder surface plane
|
||||
* in a shared memory blob parameter map
|
||||
*/
|
||||
DECLARE_GPU_PARAM_KEY(VA_PLANE, uint32_t);
|
||||
|
||||
} // namespace GPUContextParams
|
||||
|
@ -335,12 +335,9 @@ public:
|
||||
return size() * element_size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Provides the number of bytes per element.
|
||||
* Abstract method.
|
||||
* @return The number of bytes per element.
|
||||
*/
|
||||
size_t element_size() const noexcept override = 0;
|
||||
size_t element_size() const noexcept override {
|
||||
return tensorDesc.getPrecision().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Allocates memory to store the data.
|
||||
@ -569,10 +566,6 @@ public:
|
||||
*/
|
||||
virtual ~TBlob();
|
||||
|
||||
size_t element_size() const noexcept override {
|
||||
return sizeof(T);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates an new empty rvalue LockedMemory object.
|
||||
*
|
||||
|
@ -200,12 +200,30 @@ public:
|
||||
virtual StatusCode serialize(const std::string& xmlPath, const std::string& binPath, ResponseDesc* resp) const
|
||||
noexcept = 0;
|
||||
|
||||
/**
|
||||
* @deprecated Use InferenceEngine::CNNNetwork wrapper instead
|
||||
* @brief Serialize network to IR and weights files.
|
||||
*
|
||||
* @param xmlStream A stream for xml content (.xml file)
|
||||
* @param binStream A stream for weights content (.bin file)
|
||||
* @param resp Pointer to the response message that holds a description of an error if any occurred
|
||||
* @return Status code of the operation
|
||||
*/
|
||||
INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::CNNNetwork wrapper instead")
|
||||
virtual StatusCode serialize(std::ostream& xmlFile, std::ostream& binFile, ResponseDesc* resp) const
|
||||
virtual StatusCode serialize(std::ostream& xmlStream, std::ostream& binStream, ResponseDesc* resp) const
|
||||
noexcept = 0;
|
||||
|
||||
/**
|
||||
* @deprecated Use InferenceEngine::CNNNetwork wrapper instead
|
||||
* @brief Serialize network to IR and weights files.
|
||||
*
|
||||
* @param xmlStream A stream for xml content (.xml file)
|
||||
* @param binData A blob for weights content (.bin file)
|
||||
* @param resp Pointer to the response message that holds a description of an error if any occurred
|
||||
* @return Status code of the operation
|
||||
*/
|
||||
INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::CNNNetwork wrapper instead")
|
||||
virtual StatusCode serialize(std::ostream& xmlPath, Blob::Ptr& binPath, ResponseDesc* resp) const
|
||||
virtual StatusCode serialize(std::ostream& xmlStream, Blob::Ptr& binData, ResponseDesc* resp) const
|
||||
noexcept = 0;
|
||||
|
||||
/**
|
||||
|
@ -109,11 +109,6 @@ public:
|
||||
template <class T>
|
||||
bool hasStorageType(const char* typeName = nullptr) const noexcept {
|
||||
try {
|
||||
if (precisionInfo.value != BIN) {
|
||||
if (sizeof(T) != size()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#define CASE(x, y) \
|
||||
case x: \
|
||||
return std::is_same<T, y>()
|
||||
@ -247,14 +242,14 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns size of single element of that precision in bits
|
||||
* @brief Returns size of single element of that precision in bytes
|
||||
* @returns Number of bytes per element
|
||||
*/
|
||||
size_t size() const {
|
||||
if (precisionInfo.bitsSize == 0) {
|
||||
IE_THROW() << " cannot estimate element if precision is " << precisionInfo.name;
|
||||
}
|
||||
return precisionInfo.bitsSize >> 3;
|
||||
return (precisionInfo.bitsSize + 7) / 8;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -461,7 +456,7 @@ inline Precision::PrecisionInfo Precision::makePrecisionInfo(const char* name) {
|
||||
Precision::PrecisionInfo info;
|
||||
info.name = name;
|
||||
|
||||
size_t nBits = precision == BIN ? 1 : 8;
|
||||
size_t nBits = precision == BIN ? 1 : (precision == U4 || precision == I4) ? 4 : 8;
|
||||
info.bitsSize = nBits * type_size_or_zero<typename PrecisionTrait<precision>::value_type>();
|
||||
info.isFloat = PrecisionTrait<precision>::is_float;
|
||||
info.value = precision;
|
||||
|
@ -46,10 +46,6 @@ public:
|
||||
*/
|
||||
explicit RemoteBlob(const TensorDesc& tensorDesc): MemoryBlob(tensorDesc) {}
|
||||
|
||||
size_t element_size() const noexcept override {
|
||||
return tensorDesc.getPrecision().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a map of device-specific parameters required for low-level
|
||||
* operations with underlying object.
|
||||
@ -194,3 +190,4 @@ inline RemoteBlob::Ptr make_shared_blob(const TensorDesc& desc, RemoteContext::P
|
||||
}
|
||||
|
||||
} // namespace InferenceEngine
|
||||
|
||||
|
@ -65,17 +65,6 @@ class TPrecision : public Precision {
|
||||
explicit TPrecision(const Precision::ePrecision value) : Precision(value) {}
|
||||
};
|
||||
|
||||
template <class T> TPrecision<T> createTPrecision() {
|
||||
TPrecision<T> cnt(InferenceEngine::Precision::fromType<T>());
|
||||
return cnt;
|
||||
}
|
||||
|
||||
template <InferenceEngine::Precision::ePrecision T>
|
||||
TPrecision<typename InferenceEngine::PrecisionTrait<T>::value_type> createTPrecision() {
|
||||
TPrecision<typename InferenceEngine::PrecisionTrait<T>::value_type> cnt(T);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
// special case for Mixed, or undefined precisions
|
||||
template <>
|
||||
|
Loading…
Reference in New Issue
Block a user