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

Method get_target_assignments

src/program.cpp:183–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183target_assignments program::get_target_assignments(const std::vector<target>& targets,
184 assignment_options options)
185{
186 const auto m = options.metric;
187
188 target_assignments p;
189
190 const auto* mod = get_main_module();
191 std::vector<std::pair<target, supported_segments>> target_subgraphs;
192 target_subgraphs.reserve(targets.size());
193 std::transform(targets.begin(),
194 targets.end(),
195 std::back_inserter(target_subgraphs),
196 [&](const auto& t) { return std::make_pair(t, t.find_supported(mod, m)); });
197
198 for(const auto ins : iterator_for(*mod))
199 {
200 if(contains(p, ins))
201 {
202 continue;
203 }
204
205 for(const auto& [target, subgraph] : target_subgraphs)
206 {
207 // can't pass a structured binding into lambda in C++17 so create a variable for it
208 const auto& t = target;
209 for(const auto& segment : subgraph)
210 {
211 const auto& instructions = segment.instructions;
212 if(not contains(instructions, ins))
213 {
214 continue;
215 }
216 std::transform(instructions.begin(),
217 instructions.end(),
218 std::inserter(p, p.end()),
219 [&](auto instr) { return std::make_pair(instr, t.name()); });
220 }
221 }
222 }
223 return p;
224}
225
226bool program::is_compiled() const { return not this->impl->contexts.empty(); }
227

Callers 1

TEST_CASEFunction · 0.80

Calls 9

get_main_moduleFunction · 0.85
iterator_forFunction · 0.85
containsFunction · 0.85
transformFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
find_supportedMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected