MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / apply

Method apply

src/fuse_attention.cpp:783–816  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

781} // namespace
782
783void fuse_attention::apply(module_pass_manager& mpm) const
784{
785 std::size_t counter = 0;
786
787 // Fuse kv-cache attention by default
788 match::find_matches(mpm, find_kv_cache_attention{.counter = &counter});
789 mpm.get_module().sort();
790 mpm.run_pass(dead_code_elimination{});
791
792 // Only fuse plain attention when requested
793 if(attn_enabled)
794 {
795 match::find_matches(mpm, find_attention{.counter = &counter});
796 mpm.get_module().sort();
797 mpm.run_pass(dead_code_elimination{});
798 }
799
800 std::size_t num_splits = 0;
801 if(flash_decoding_num_splits.has_value())
802 {
803 // Use the value from the constructor (for testing)
804 num_splits = *flash_decoding_num_splits;
805 }
806 else
807 {
808 // Default behavior: read from the env var (for non-test use)
809 num_splits = get_num_splits();
810 }
811 if(num_splits > 1)
812 {
813 match::find_matches(mpm, find_flash_decoding{.groups = num_splits});
814 mpm.run_pass(dead_code_elimination{});
815 }
816}
817
818} // namespace MIGRAPHX_INLINE_NS
819} // namespace migraphx

Callers 1

applyMethod · 0.45

Calls 5

find_matchesClass · 0.85
get_num_splitsFunction · 0.85
get_moduleMethod · 0.80
sortMethod · 0.45
run_passMethod · 0.45

Tested by

no test coverage detected