Insert match::opaque into deep matchers to fix large symbol names on windows and debug gcc builds - #5124
Insert match::opaque into deep matchers to fix large symbol names on windows and debug gcc builds#5124pfultz2 wants to merge 14 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a targeted way to reduce C++ template symbol size by selectively type-erasing “deep” matchers via a new match::opaque wrapper, primarily to address Windows and debug-build toolchain limitations, while keeping matcher performance on platforms that don’t require it.
Changes:
- Added
MIGRAPHX_USE_TYPE_ERASED_OPAQUEandmatch::opaque()to optionally type-erase specific matchers. - Wrapped several deeply-nested matchers (algebra simplification, GELU rewrites, attention fusion) with
match::opaqueto reduce instantiation depth/symbol size. - Switched Windows/CIs compile definitions from full matcher type-erasure to opaque-only type-erasure.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/include/migraphx/matcher.hpp | Adds MIGRAPHX_USE_TYPE_ERASED_OPAQUE and match::opaque() helper for selective type-erasure. |
| src/simplify_algebra.cpp | Inserts match::opaque in several complex algebraic matchers to reduce type depth. |
| src/rewrite_gelu.cpp | Wraps GELU matchers with match::opaque to reduce symbol size. |
| src/include/migraphx/match/gelu_tanh.hpp | Applies opaque() to internal GELU-tanh matcher subexpressions. |
| src/include/migraphx/match/gelu_erf.hpp | Applies opaque() to internal GELU-erf matcher subexpressions. |
| src/fuse_attention.cpp | Applies match::opaque to deep attention-pattern matchers. |
| src/CMakeLists.txt | Enables opaque type-erasure for Windows builds via compile definition. |
| .github/workflows/ci.yaml | Enables opaque type-erasure for a debug CI build via CXXFLAGS. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| template <class M> | ||
| auto opaque(M m) | ||
| { | ||
| #ifdef MIGRAPHX_USE_TYPE_ERASED_OPAQUE | ||
| return any_matcher{m}; | ||
| #else | ||
| return m; | ||
| #endif | ||
| } |
| if(WIN32) | ||
| # Due to compilation crashing, we need to use type-erased matchers on Windows. | ||
| target_compile_definitions(migraphx PUBLIC MIGRAPHX_USE_TYPE_ERASED_MATCHERS=1) | ||
| target_compile_definitions(migraphx PUBLIC MIGRAPHX_USE_TYPE_ERASED_OPAQUE=1) | ||
| endif() |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5124 +/- ##
========================================
Coverage 93.12% 93.12%
========================================
Files 625 625
Lines 33162 33171 +9
========================================
+ Hits 30879 30889 +10
+ Misses 2283 2282 -1
🚀 New features to boost your workflow:
|
Regressions detected 🔴 * No develop baseline was found for this PR's branch point; compared against the latest available develop run instead. |
|
Motivation
Rather than type erasing every matcher which can slow matching way down. We insert
match::opaquein certain places to reduce the symbol name. On platforms(like unix-based) that do not create such large symbol names thematch::opaqueis a no-op.Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot ApplicableFollow the LLVM AI Tool Use Policy for contributions using AI.