-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[USMP] Hill Climb allocator #9704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f2423d5
[USMP] Hill Climb allocator
d-smirnov 2b16728
requested changes
d-smirnov eb72b02
Conda-related linter small fixes
d-smirnov 7b4dceb
Moved implementation from greedy.h to greedy.cc
d-smirnov 558eac8
Integrated into test_tir_usmp_algo.py unit test
d-smirnov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| /*! | ||
| * \file include/tvm/tir/usmp/algo/greedy.h | ||
| * \brief This header file contains helper methods used in greedy algorithms | ||
| * for planning memory for USMP | ||
| */ | ||
| #pragma once | ||
| #include <tvm/arith/analyzer.h> | ||
| #include <tvm/runtime/device_api.h> | ||
| #include <tvm/tir/builtin.h> | ||
| #include <tvm/tir/function.h> | ||
| #include <tvm/tir/stmt_functor.h> | ||
| #include <tvm/tir/usmp/utils.h> | ||
|
|
||
| #include <unordered_map> | ||
| #include <vector> | ||
|
|
||
| namespace tvm { | ||
| namespace tir { | ||
| namespace usmp { | ||
| namespace algo { | ||
|
|
||
| /*! | ||
| * \brief This is the base class for Greedy Algorithms where the sorting | ||
| * is specialized in the extended classes based on the greedy criteria. | ||
| */ | ||
| class GreedyBase { | ||
| public: | ||
| GreedyBase() {} | ||
| /*! | ||
| * \brief This function should be implemented by the extended classes to sort the BufferInfo | ||
| * objects based on a criteria and then calling PostSortAllocation. | ||
| */ | ||
| virtual Map<BufferInfo, PoolAllocation> PlanMemory(const Array<BufferInfo>& buffer_info_arr) = 0; | ||
|
|
||
| protected: | ||
| /*! | ||
| * \brief Rounds up the offset to satisfy the alignement requirement | ||
| */ | ||
| size_t round_up_to_byte_alignment(const size_t& non_aligned_byte_offset, | ||
| const int& byte_alignment); | ||
|
|
||
| /*! | ||
| * \brief A helper function check whether a offset is valid given the constraints | ||
| */ | ||
| bool IsValidPlacement(const PoolInfo& candidate_pool, const size_t& next_offset, | ||
| const size_t& size_bytes); | ||
|
|
||
| /*! | ||
| * \brief Selects a pool for placement in the given set of ordered pool candidates | ||
| */ | ||
| PoolInfo SelectPlacementPool( | ||
| const BufferInfo& buf_info, | ||
| const std::unordered_map<PoolInfo, size_t, ObjectPtrHash, ObjectPtrEqual>& pool_offsets); | ||
|
|
||
| /*! | ||
| * \brief This is the base allocation function that works on sorted BufferInfo objects based | ||
| * on the greedy heuristic. The sorting algorithm has to be called before calling this. | ||
| */ | ||
| Map<BufferInfo, PoolAllocation> PostSortAllocation( | ||
| const std::vector<BufferInfo>& buffer_info_vec); | ||
| }; | ||
|
|
||
| } // namespace algo | ||
| } // namespace usmp | ||
| } // namespace tir | ||
| } // namespace tvm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.