[IE][VPU]: Shape compression (#3500)

* This change prevents saving the same shapes in a blob. If more than one data have the same shapes, only one will be saved in the blob.
This commit is contained in:
George Zlobin 2020-12-21 15:21:19 +03:00 committed by GitHub
parent b2399ce0d9
commit 935549035e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

@ -126,6 +126,8 @@ private:
DataMap<allocator::MemChunk*> _memChunksPerData;
std::map<std::pair<DimVector, DimValues>, int> _staticShapeOffsets;
int _blobMemOffset = 0;
int _inputMemOffset = 0;
int _outputMemOffset = 0;

View File

@ -338,8 +338,8 @@ public:
if (_flags[ind] != other._flags[ind]) {
return !_flags[ind];
}
if (_flags[ind] && _values[ind].second < other._values[ind].second) {
return true;
if (_flags[ind] && _values[ind].second != other._values[ind].second) {
return _values[ind].second < other._values[ind].second;
}
}
return false;

View File

@ -316,8 +316,18 @@ ShapeLocation Allocator::allocateShape(const Data& data) {
} else {
// Static allocation
shapeLocation.dimsLocation = Location::Blob;
// Prevent allocation of same shapes multiple times
auto dimOrder = data->desc().dimsOrder().toPermutation();
auto dimValues = data->desc().dims();
auto itr = _staticShapeOffsets.find({dimOrder, dimValues});
if (itr != _staticShapeOffsets.end()) {
shapeLocation.dimsOffset = itr->second;
} else {
shapeLocation.dimsOffset = _blobMemOffset;
_blobMemOffset += dimsByteSize;
_staticShapeOffsets.insert({{dimOrder, dimValues}, shapeLocation.dimsOffset});
}
}