diff options
author | Louis Verhaard <louis.verhaard@arm.com> | 2021-01-21 13:16:18 +0100 |
---|---|---|
committer | Louis Verhaard <louis.verhaard@arm.com> | 2021-01-22 14:24:21 +0100 |
commit | d4738e5d68260ed56c0b878cd5dc11c67fdbbfaa (patch) | |
tree | b7bccfbcee2f56d885cee42d5f48dff8107b7d47 /ethosu/tensor_allocator/search_allocator.cpp | |
parent | 606063fb1c37ddb211940b8ad211f31824aaee60 (diff) | |
download | ethos-u-vela-d4738e5d68260ed56c0b878cd5dc11c67fdbbfaa.tar.gz |
MLBEDSW-3843: Segmentation fault search allocator
Vector index could become negative in search allocator.
Change-Id: I3b77474a86fd5f4227d8b2a825d11ec8ec0fb073
Signed-off-by: Louis Verhaard <louis.verhaard@arm.com>
Diffstat (limited to 'ethosu/tensor_allocator/search_allocator.cpp')
-rw-r--r-- | ethosu/tensor_allocator/search_allocator.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ethosu/tensor_allocator/search_allocator.cpp b/ethosu/tensor_allocator/search_allocator.cpp index c7c418a0..5c7492b4 100644 --- a/ethosu/tensor_allocator/search_allocator.cpp +++ b/ethosu/tensor_allocator/search_allocator.cpp @@ -68,7 +68,7 @@ SearchAllocator::SearchAllocator(const std::vector<LiveRange> &live_ranges, uint } } } - target_size = std::max(min_required_size, available_size); + target_size = std::max(min_required_size, size_limit); // Calculate the urgency of each live range lr_urgency.resize(lrs.size()); for (size_t i = 0; i < lrs.size(); ++i) { @@ -217,7 +217,8 @@ void SearchAllocator::attempt_bottleneck_fix(std::vector<size_t> &indices) { // Pick any affecting live range. ix1 = turn_list[rng() % turn_list.size()]; } - size_t ix2 = turn_list[rng() % turn_list.size() - 1]; + // Note: turn_list has always at least 2 elements for bottlenecks + size_t ix2 = turn_list[rng() % (turn_list.size() - 1)]; if (ix1 == ix2) { ix2 = turn_list[turn_list.size() - 1]; } |