// // Copyright © 2021 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #pragma once #include #include #include #include #include #include namespace armnn { /// SingleAxisPriorityList sorts the MemBlocks according to some priority, /// then trys to place them into as few bins as possible class SingleAxisPriorityList : public IMemoryOptimizerStrategy { public: SingleAxisPriorityList() : m_Name(std::string("SingleAxisPriorityList")) , m_MemBlockStrategyType(MemBlockStrategyType::SingleAxisPacking) {} std::string GetName() const override; MemBlockStrategyType GetMemBlockStrategyType() const override; std::vector Optimize(std::vector& memBlocks) override; private: // Tracks all memBlocks and their positions in a bin as well as their maximum memSize struct BinTracker; // PlaceBlocks takes a list of MemBlock* and fits them into n bins. // A block can only fit into an existing bin if it's lifetime does not overlap with the lifetime of the // blocks already in a bin. // If no appropriate bin is available a new one is created. void PlaceBlocks(const std::list& priorityList, std::vector& placedBlocks, const unsigned int maxLifetime); std::string m_Name; MemBlockStrategyType m_MemBlockStrategyType; }; } // namespace armnn