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

Method eval

src/program.cpp:588–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586}
587
588std::vector<argument> program::eval(const parameter_map& params,
589 execution_environment exec_env) const
590{
591 auto& contexts = this->impl->contexts;
592
593 auto trace_level = value_of(MIGRAPHX_TRACE_EVAL{});
594 std::vector<argument> ret;
595
596 if(exec_env.async)
597 {
598 assert(contexts.size() == 1);
599 contexts.front().wait_for(exec_env.queue);
600 }
601
602 if(trace_level > 0)
603 {
604 std::unordered_map<instruction_ref, std::string> ins_out;
605 // get instruction names
606 this->print([&](auto x, const auto& ins_names) {
607 std::stringstream ss;
608 instruction::print(ss, x, ins_names);
609 ins_out[x] = ss.str();
610 });
611 ret = generic_eval(*this, contexts, params, [&](instruction_ref ins, auto f) {
612 const auto& ctx = contexts[ins->get_target_id()];
613 ctx.finish();
614 std::cout << "Run instruction: " << ins_out.at(ins) << std::endl;
615 timer t{};
616 auto result = f();
617 double t1 = t.record<milliseconds>();
618 ctx.finish();
619 double t2 = t.record<milliseconds>();
620 std::cout << "Time: " << t1 << "ms, " << t2 << "ms" << std::endl;
621 if(trace_level > 1 and ins->name().front() != '@' and ins->name() != "load" and
622 not result.empty())
623 {
624 migraphx::argument buffer;
625 try
626 {
627 const target& tgt = this->impl->targets.at(ins->get_target_id());
628 buffer = tgt.copy_from(result);
629 }
630 catch(const migraphx::exception&)
631 {
632 // instruction was run on host then no need to copy buffer from target
633 buffer = result;
634 }
635 catch(...)
636 {
637 MIGRAPHX_THROW("MIGraphX program execution with MIGRAPHX_TRACE_EVAL failed.\n");
638 }
639 if(trace_level == 2)
640 {
641 std::cout << "Output has " << to_string_range(classify_argument(buffer))
642 << std::endl;
643 std::cout << "Output: ";
644 preview_argument(std::cout, buffer);
645 std::cout << std::endl;

Callers 15

run_asyncFunction · 0.45
runFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45

Calls 15

printMethod · 0.95
generic_evalFunction · 0.85
to_string_rangeFunction · 0.85
classify_argumentFunction · 0.85
preview_argumentFunction · 0.85
print_statisticsFunction · 0.85
frontMethod · 0.80
get_target_idMethod · 0.80
atMethod · 0.80
value_ofFunction · 0.70
printFunction · 0.50
sizeMethod · 0.45

Tested by 15

TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
evalFunction · 0.36