Tensor1: memorize size_alignment when tracking the ahwb usage.

When CPU/GPU buffer allocated and the tracker selects Ahwb storage to be used then the properly recorded alignment must be used.

PiperOrigin-RevId: 498264759
This commit is contained in:
Nikolay Chirkov
2022-12-28 16:09:02 -08:00
committed by Copybara-Service
parent 1924f1cdff
commit 2d9a969d10
4 changed files with 78 additions and 5 deletions
+6 -1
View File
@@ -266,7 +266,12 @@ Tensor::AHardwareBufferView Tensor::GetAHardwareBufferWriteView(
bool Tensor::AllocateAHardwareBuffer(int size_alignment) const {
// Mark current tracking key as Ahwb-use.
ahwb_usage_track_.insert(ahwb_tracking_key_);
if (auto it = ahwb_usage_track_.find(ahwb_tracking_key_);
it != ahwb_usage_track_.end()) {
size_alignment = it->second;
} else if (ahwb_tracking_key_ != 0) {
ahwb_usage_track_.insert({ahwb_tracking_key_, size_alignment});
}
use_ahwb_ = true;
if (__builtin_available(android 26, *)) {