-
Notifications
You must be signed in to change notification settings - Fork 128
Adding compilation mode #4770
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
Open
pnikolic-amd
wants to merge
18
commits into
develop
Choose a base branch
from
compile-modes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Adding compilation mode #4770
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6743461
Compile modes init version
pnikolic-amd 58b364c
Removed passes for eager mod
pnikolic-amd 755844d
Implement support for compile modes in mgx apis
pnikolic-amd 63a9c15
Fix driver command and add compile mode to api
pnikolic-amd e3aec3a
Remove layout_convolution pass for eager mode
pnikolic-amd a152941
Add option for skiping benchmarks
pnikolic-amd f85f74e
Remove unecesary code
pnikolic-amd 6461326
Refactor get passes to remove duplicates
pnikolic-amd 91fd7bd
Fix missing argument
pnikolic-amd 308e237
Merge develop
pnikolic-amd 0f1169a
Fix merge passes
pnikolic-amd 6a39c41
Updated types and setting
pnikolic-amd 8f7bb08
Create pipeline factory to remove duplications and hadle passes list
pnikolic-amd 1f76942
Context ptr fix
pnikolic-amd 6719b2c
Clang foramt chages
pnikolic-amd 0014161
Update copyright
pnikolic-amd 99c72f2
Merge branch 'develop' into compile-modes
pnikolic-amd 0160c2b
Adding compile modes to migraphx.h
pnikolic-amd 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
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
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
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,58 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2015-2026 Advanced Micro Devices, Inc. All rights reserved. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| */ | ||
| #include <migraphx/compile_modes.hpp> | ||
| #include <cstdlib> | ||
| #include <algorithm> | ||
|
|
||
| namespace migraphx { | ||
| inline namespace MIGRAPHX_INLINE_NS { | ||
|
|
||
| compile_modes convert_to_compile_mode(uint8_t mode) | ||
| { | ||
| // If mode is not in range 0-100, return BALANCED | ||
| if(mode > 100) | ||
| return compile_modes::BALANCED; | ||
|
|
||
| // Define the enum values as integers for comparison | ||
| constexpr uint8_t eager_val = static_cast<uint8_t>(compile_modes::EAGER); | ||
| constexpr uint8_t balanced_val = static_cast<uint8_t>(compile_modes::BALANCED); | ||
| constexpr uint8_t max_val = static_cast<uint8_t>(compile_modes::MAX); | ||
|
pnikolic-amd marked this conversation as resolved.
Outdated
|
||
|
|
||
| // Calculate distances to each enum value | ||
| uint8_t dist_to_eager = std::abs(mode - eager_val); | ||
| uint8_t dist_to_balanced = std::abs(mode - balanced_val); | ||
| uint8_t dist_to_max = std::abs(mode - max_val); | ||
| // Find the minimum distance | ||
| uint8_t min_dist = std::min({dist_to_eager, dist_to_balanced, dist_to_max}); | ||
|
|
||
| // Return the enum value with minimum distance | ||
| if(min_dist == dist_to_eager) | ||
| return compile_modes::EAGER; | ||
| if(min_dist == dist_to_balanced) | ||
| return compile_modes::BALANCED; | ||
| return compile_modes::MAX; | ||
| } | ||
|
|
||
| } // namespace MIGRAPHX_INLINE_NS | ||
| } // namespace migraphx | ||
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
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,45 @@ | ||
| /* | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2015-2026 Advanced Micro Devices, Inc. All rights reserved. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| */ | ||
| #ifndef MIGRAPHX_GUARD_MIGRAPHX_COMPILE_MODES_HPP | ||
| #define MIGRAPHX_GUARD_MIGRAPHX_COMPILE_MODES_HPP | ||
|
|
||
| #include <migraphx/config.hpp> | ||
| #include <cstdint> | ||
|
|
||
| namespace migraphx { | ||
| inline namespace MIGRAPHX_INLINE_NS { | ||
|
|
||
| enum class compile_modes | ||
| { | ||
| EAGER = 0, | ||
| BALANCED = 50, | ||
| MAX = 100 | ||
|
pnikolic-amd marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| MIGRAPHX_EXPORT compile_modes convert_to_compile_mode(uint8_t mode); | ||
|
pnikolic-amd marked this conversation as resolved.
Outdated
|
||
|
|
||
| } // namespace MIGRAPHX_INLINE_NS | ||
| } // namespace migraphx | ||
|
|
||
| #endif // MIGRAPHX_GUARD_MIGRAPHX_COMPILE_MODES_HPP | ||
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
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
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
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.