-
Notifications
You must be signed in to change notification settings - Fork 144
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
95
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 all commits
Commits
Show all changes
95 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 b3f334f
Revert "Adding compile modes to migraphx.h"
pnikolic-amd f62d878
Merge branch 'develop' into compile-modes
pnikolic-amd df3b65d
Merge branch 'develop' into compile-modes
pnikolic-amd 4130813
Update src/api/include/migraphx/migraphx.hpp
pnikolic-amd f01d575
Update tools/api/api.cpp
pnikolic-amd 46e0756
Fix compile-modes CI failures: add missing C API declarations, fix na…
pnikolic-amd 46dee31
Update src/api/include/migraphx/migraphx.h
pnikolic-amd 9d5b0b0
Update src/api/include/migraphx/migraphx.hpp
pnikolic-amd 9132684
Update tools/api/api.cpp
pnikolic-amd 657acc1
API fixes
pnikolic-amd 7b18952
Merge develop
pnikolic-amd d9cc0ad
Revert const auto
pnikolic-amd 7de62a8
Merge fix
pnikolic-amd c3e2f7d
Revert pipeline factory
pnikolic-amd b0809be
Return pipelines
pnikolic-amd 22aaaf6
Fix eager mode
pnikolic-amd bca3d94
Merge branch 'develop' into compile-modes
pnikolic-amd 00453f4
Update src/api/api.cpp
pnikolic-amd c2fbcbf
Update src/targets/gpu/target.cpp
pnikolic-amd d0d58cc
Fix python bindings
pnikolic-amd 18deaa8
Add unit tests for compile modes
pnikolic-amd cdaf448
Merge branch 'develop' into compile-modes
pnikolic-amd 7394430
Update year
pnikolic-amd 212591a
Add unit test to imrpove coverage, fix tidy error
pnikolic-amd dae9c54
Merge branch 'develop' into compile-modes
pnikolic-amd 18cd797
Merge develop
pnikolic-amd ba3b464
Add support for eager mode in new pipelines for get passes function
pnikolic-amd eb6a350
Update src/targets/gpu/target.cpp
pnikolic-amd b93c8a6
Update src/targets/gpu/target.cpp
pnikolic-amd 06aef33
Merge branch 'develop' into compile-modes
pnikolic-amd 2c41af3
Merge branch 'develop' into compile-modes
pnikolic-amd 2c2de32
Add tests for compile modes
pnikolic-amd 3df2ce4
Test bug fix
pnikolic-amd 0d7f4ea
Tests bug fix
pnikolic-amd 7d34a4f
Merge branch 'develop' into compile-modes
pnikolic-amd f5566b0
Update test/gpu/compile_modes.cpp
pnikolic-amd ad63bdf
Update test/gpu/compile_modes.cpp
pnikolic-amd 1826da6
Merge branch 'compile-modes' of https://github.com/ROCm/AMDMIGraphX i…
pnikolic-amd 6af72d0
Merge develop
pnikolic-amd c987058
Update src/targets/gpu/compile_ops.cpp
pnikolic-amd 0b1ee3b
Merge develop
pnikolic-amd 3dce523
Removing unecessary static_cast, removing unecessary tests
pnikolic-amd 56ee02d
Add second variat for every verify test to run in eager mode
pnikolic-amd 599b930
Merge branch 'develop' into compile-modes
pnikolic-amd 7d71fe7
Update src/compile_modes.cpp
pnikolic-amd 7ba654d
Merge branch 'develop' into compile-modes
pnikolic-amd 4f9e3fb
Update licence
pnikolic-amd 327ff69
Merge branch 'develop' into compile-modes
pnikolic-amd 15306c4
Update licence
pnikolic-amd 03dacef
Merge branch 'compile-modes' of https://github.com/ROCm/AMDMIGraphX i…
pnikolic-amd ae8f775
Merge branch 'develop' into compile-modes
pnikolic-amd 3418f19
Add passes for softmax in eager, add test for compile_modes
pnikolic-amd a27f54e
Merge branch 'develop' into compile-modes
pnikolic-amd f3b2c5f
Update src/targets/gpu/target.cpp
pnikolic-amd 6d96d35
update fro licence
pnikolic-amd 1178a67
Merge develop
pnikolic-amd e6f8fac
Update pipleine for eager mode
pnikolic-amd 2c7d374
Skip some tests in eager mode
pnikolic-amd 4a6665d
Update src/api/include/migraphx/migraphx.hpp
pnikolic-amd 807ca67
Update src/include/migraphx/compile_options.hpp
pnikolic-amd f63d33b
Update src/py/migraphx_py.cpp
pnikolic-amd d22f478
Merge branch 'compile-modes' of https://github.com/ROCm/AMDMIGraphX i…
pnikolic-amd 9874a76
Merge branch 'develop' into compile-modes
pnikolic-amd ab47383
Fix mispelling
pnikolic-amd d079644
Formating and remove test
pnikolic-amd 5b25ce2
Generate api
pnikolic-amd 16a9ff7
Merge branch 'develop' into compile-modes
pnikolic-amd 5fc2665
Update test/verify/main.cpp
pnikolic-amd 6771c9c
Update test/verify/run_verify.cpp
pnikolic-amd 9198f2a
Remove skiping tests in eager mode, modify eager mode to not remove a…
pnikolic-amd b74f5c6
Merge branch 'develop' into compile-modes
pnikolic-amd 5ef99b3
Update src/targets/gpu/target.cpp
pnikolic-amd 0d567d7
Fix formatting
pnikolic-amd 5c11284
Merge branch 'compile-modes' of https://github.com/ROCm/AMDMIGraphX i…
pnikolic-amd 2f46744
Putting just necessary passes in eager mode for tests to pass
pnikolic-amd 6c516a0
Foramting fixes
pnikolic-amd 5c44724
Merge branch 'develop' into compile-modes
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
Some comments aren't visible on the classic Files Changed page.
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
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,78 @@ | ||
| /* | ||
| * 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 <migraphx/errors.hpp> | ||
| #include <migraphx/functional.hpp> | ||
| #include <migraphx/logger.hpp> | ||
| #include <migraphx/stringutils.hpp> | ||
| #include <cstdlib> | ||
| #include <algorithm> | ||
| #include <array> | ||
|
|
||
| namespace migraphx { | ||
| inline namespace MIGRAPHX_INLINE_NS { | ||
|
|
||
| compile_modes convert_to_compile_mode(uint8_t mode) | ||
| { | ||
| int clamped = std::clamp<int>(mode, 0, 100); | ||
| if(clamped != mode) | ||
| log::warn() << "Compile mode value " << mode << " out of range [0, 100], clamping to " | ||
| << clamped; | ||
|
|
||
| static const std::array<compile_modes, 3> modes = { | ||
| compile_modes::eager, compile_modes::balanced, compile_modes::max}; | ||
|
|
||
| // NOLINTNEXTLINE(readability-qualified-auto) | ||
| auto it = std::find_if(modes.begin(), modes.end(), [&](compile_modes m) { | ||
| return static_cast<int>(m) == clamped; | ||
| }); | ||
| if(it != modes.end()) | ||
| return *it; | ||
|
|
||
| log::warn() << "Compile mode value " << clamped | ||
| << " does not match a known mode, using closest match"; | ||
| return *std::min_element(modes.begin(), modes.end(), by(std::less<>{}, [&](compile_modes m) { | ||
| return std::abs(clamped - static_cast<int>(m)); | ||
| })); | ||
| } | ||
|
|
||
| compile_modes convert_to_compile_mode(const std::string& mode) | ||
| { | ||
| auto lower = to_lower(mode); | ||
| if(lower == "eager") | ||
| return compile_modes::eager; | ||
| if(lower == "balanced") | ||
| return compile_modes::balanced; | ||
| if(lower == "max") | ||
| return compile_modes::max; | ||
|
|
||
| int val = std::stoi(mode); | ||
| if(val < 0 or val > 100) | ||
| log::warn() << "Compile mode value " << val << " out of range [0, 100], clamping to " | ||
| << std::clamp(val, 0, 100); | ||
| return convert_to_compile_mode(std::clamp(val, 0, 100)); | ||
| } | ||
|
|
||
| } // 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,47 @@ | ||
| /* | ||
| * 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> | ||
| #include <string> | ||
|
|
||
| namespace migraphx { | ||
| inline namespace MIGRAPHX_INLINE_NS { | ||
|
|
||
| enum class compile_modes | ||
| { | ||
| eager = 0, | ||
| balanced = 50, | ||
| max = 100 | ||
| }; | ||
|
|
||
| MIGRAPHX_EXPORT compile_modes convert_to_compile_mode(uint8_t mode); | ||
| MIGRAPHX_EXPORT compile_modes convert_to_compile_mode(const std::string& mode); | ||
|
|
||
| } // 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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit tests should be added for these functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are added in test/compile_modes.cpp