Improvements in Blob API (#6490)

This commit is contained in:
Ilya Lavrenov 2021-07-02 10:02:52 +03:00 committed by GitHub
parent 38d8cc2112
commit 0c4c57db27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 37 deletions

View File

@ -243,17 +243,6 @@ protected:
* @return The allocator for allocator-based blobs or nullptr if there is none
*/
virtual const std::shared_ptr<IAllocator>& getAllocator() const noexcept = 0;
/**
* @brief Gets a handle to allocated memory
*
* @return The handle to allocated memory for allocator-based blobs or nullptr if there is none
*/
virtual void* getHandle() const noexcept = 0;
/// private
template <typename>
friend class TBlobProxy;
};
/**
@ -472,7 +461,7 @@ protected:
*
* @return The handle to allocated memory for allocator-based blobs or if there is none then a nullptr.
*/
void* getHandle() const noexcept override = 0;
virtual void* getHandle() const noexcept = 0;
/// private
template <typename>
@ -610,7 +599,7 @@ public:
*/
void allocate() noexcept override {
const auto allocator = getAllocator();
const auto rawHandle = allocator->alloc(size() * sizeof(T));
const auto rawHandle = allocator->alloc(byteSize());
if (rawHandle == nullptr) {
return;
@ -761,6 +750,7 @@ protected:
template <class S>
LockedMemory<S> lockme() const {
return LockedMemory<S>(_allocator.get(), getHandle(), 0);
// getTensorDesc().getBlockingDesc().getOffsetPadding());
}
/**

View File

@ -113,11 +113,6 @@ protected:
* @brief Returns nullptr as CompoundBlob is not allocator-based
*/
const std::shared_ptr<IAllocator>& getAllocator() const noexcept override;
/**
* @brief Returns nullptr as CompoundBlob is not allocator-based
*/
void* getHandle() const noexcept override;
};
/**

View File

@ -47,7 +47,7 @@ static void blob_copy_4d_t(Blob::Ptr src, Blob::Ptr dst) {
const auto H_dst_stride = dst_l == NHWC ? dst_strides[1] : dst_strides[2];
const auto W_dst_stride = dst_l == NHWC ? dst_strides[2] : dst_strides[3];
src_ptr += dst_blk_desc.getOffsetPadding();
dst_ptr += dst_blk_desc.getOffsetPadding();
#ifdef HAVE_SSE
if (src->getTensorDesc().getLayout() == NHWC && dst->getTensorDesc().getLayout() == NCHW && C == 3 &&

View File

@ -361,10 +361,6 @@ const std::shared_ptr<IAllocator>& CompoundBlob::getAllocator() const noexcept {
return _allocator;
};
void* CompoundBlob::getHandle() const noexcept {
return nullptr;
}
NV12Blob::NV12Blob(const Blob::Ptr& y, const Blob::Ptr& uv)
: CompoundBlob(verifyNV12BlobInput(y, uv)) {
this->_blobs = {y, uv};

View File

@ -56,7 +56,7 @@ public:
* @param offset Offset in memory
* @param dims Dimensions of the given blob
*/
TBlobProxy(Precision p, Layout l, const Blob::Ptr& blob, size_t offset, const SizeVector& dims)
TBlobProxy(Precision p, Layout l, const MemoryBlob::Ptr& blob, size_t offset, const SizeVector& dims)
: base(TensorDesc(p, dims, l)), realObject(blob), offset(offset * blob->element_size()) {
checkWindow();
}
@ -79,7 +79,7 @@ public:
* @return LockedMemory instance of type void
*/
LockedMemory<void> buffer() noexcept override {
return {getAllocator().get(), getHandle(), offset};
return {getAllocator().get(), realObject->getHandle(), offset};
}
/**
@ -87,7 +87,7 @@ public:
* @return LockedMemory instance of type const void
*/
LockedMemory<const void> cbuffer() const noexcept override {
return {getAllocator().get(), getHandle(), offset};
return {getAllocator().get(), realObject->getHandle(), offset};
}
/**
@ -95,7 +95,7 @@ public:
* @return LockedMemory instance of the given type
*/
LockedMemory<T> data() noexcept override {
return {getAllocator().get(), getHandle(), offset};
return {getAllocator().get(), realObject->getHandle(), offset};
}
/**
@ -103,7 +103,7 @@ public:
* @return Read-only LockedMemory instance of the given type
*/
LockedMemory<const T> readOnly() const noexcept override {
return {getAllocator().get(), getHandle(), offset};
return {getAllocator().get(), realObject->getHandle(), offset};
}
protected:
@ -115,14 +115,6 @@ protected:
return realObject->getAllocator();
}
/**
* @brief Gets a handle pointer
* @return A handle pointer
*/
void* getHandle() const noexcept override {
return realObject->getHandle();
}
/**
* @brief Checks whether proxy can be created with the requested offset and size parameters
*/
@ -149,7 +141,7 @@ protected:
}
private:
typename Blob::Ptr realObject;
typename MemoryBlob::Ptr realObject;
size_t offset;
};
} // namespace InferenceEngine