blob: b9b547fc6d199e6b007983e804c009c1dc8a0f36 [file] [log] [blame]
Louis Verhaard9bfe0f82020-12-03 12:26:25 +01001# Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
2#
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the License); you may
6# not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an AS IS BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# Description:
18# Unit tests for tensor_allocator.
19from ethosu import tensor_allocator
20
21
22def test_allocate():
23 """Tests the search allocator"""
24 # Create an input that requires a search to produce a perfect allocation.
25 # Should result in size 16016
26 lrs = [(0, 100, 8000), (0, 1, 8016), (100, 110, 2000), (108, 110, 4000), (109, 110, 6000)]
27 input = [x for lr in lrs for x in lr]
28 res = tensor_allocator.allocate(input, 0)
29 assert len(res) == len(lrs)
30 assert max(addr + lr[2] for addr, lr in zip(res, lrs)) == 16016