[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:
parent
b2399ce0d9
commit
935549035e
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -316,8 +316,18 @@ ShapeLocation Allocator::allocateShape(const Data& data) {
|
||||
} else {
|
||||
// Static allocation
|
||||
shapeLocation.dimsLocation = Location::Blob;
|
||||
shapeLocation.dimsOffset = _blobMemOffset;
|
||||
_blobMemOffset += dimsByteSize;
|
||||
|
||||
// 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});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user