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

Function find_instructions_between

src/instruction.cpp:695–727  ·  view source on GitHub ↗

Return set of all instructions that are connected to both start and end nodes (inclusive)

Source from the content-addressed store, hash-verified

693
694// Return set of all instructions that are connected to both start and end nodes (inclusive)
695std::unordered_set<instruction_ref>
696find_instructions_between(instruction_ref start, instruction_ref end, const_module_ref m)
697{
698 assert(reaches(start, end, m));
699 std::unordered_set<instruction_ref> result;
700 std::unordered_set<instruction_ref> inss;
701
702 fix<void>([&](auto self, auto ins) {
703 if(not m->has_instruction(ins))
704 return;
705 if(ins->inputs().empty())
706 return;
707 if(not inss.insert(ins).second)
708 return;
709 if(ins == start)
710 return;
711 for(auto input : ins->inputs())
712 self(input);
713 })(end);
714
715 fix<void>([&](auto self, auto ins) {
716 if(ins == end)
717 return;
718 if(ins != start and not contains(inss, ins))
719 return;
720 if(not result.insert(ins).second)
721 return;
722 for(auto output : ins->outputs())
723 self(output);
724 })(start);
725 result.insert(end);
726 return result;
727}
728
729} // namespace MIGRAPHX_INLINE_NS
730} // namespace migraphx

Callers 4

TEST_CASEFunction · 0.85
get_attn_instructionsMethod · 0.85
hoist_external_inputsMethod · 0.85
applyMethod · 0.85

Calls 7

reachesFunction · 0.85
containsFunction · 0.85
outputsMethod · 0.80
has_instructionMethod · 0.45
emptyMethod · 0.45
inputsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected