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

Method to_value

src/program.cpp:690–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

688const int program_file_version = 7;
689
690value program::to_value() const
691{
692 value result;
693 result["version"] = program_file_version;
694 result["migraphx_version"] = get_migraphx_version();
695 result["targets"] = migraphx::to_value(this->impl->targets);
696 result["contexts"] = migraphx::to_value(this->impl->contexts);
697 value module_vals = value::object{};
698 std::unordered_map<instruction_ref, std::string> names;
699 for(auto& mod : this->get_modules())
700 {
701 value mod_val;
702 value nodes;
703 mod_val["name"] = mod->name();
704 names = mod->print(
705 [&](auto ins, auto ins_names) {
706 value node;
707 node["output"] = ins_names.at(ins);
708 node["name"] = ins->name();
709 node["shape"] = migraphx::to_value(ins->get_shape());
710 node["normalized"] = ins->is_normalized();
711 if(ins->name() == "@literal")
712 node["literal"] = migraphx::to_value(ins->get_literal());
713 node["operator"] = ins->get_operator().to_value();
714 std::vector<std::string> inputs;
715 std::transform(ins->inputs().begin(),
716 ins->inputs().end(),
717 std::back_inserter(inputs),
718 [&](auto i) {
719 assert(contains(ins_names, i));
720 return ins_names.at(i);
721 });
722 node["inputs"] = inputs;
723 auto module_args = ins->module_inputs();
724 if(not module_args.empty())
725 {
726 std::vector<std::string> module_inputs;
727 std::transform(module_args.begin(),
728 module_args.end(),
729 std::back_inserter(module_inputs),
730 [&](auto mod_ref) { return mod_ref->name(); });
731 node["module_inputs"] = module_inputs;
732 }
733
734 nodes.push_back(node);
735 },
736 names);
737 mod_val["nodes"] = nodes;
738
739 module_vals[mod->name()] = mod_val;
740 }
741
742 result["modules"] = module_vals;
743
744 return result;
745}
746
747static void mod_from_val(module_ref mod,

Callers 15

migraphx_to_valueFunction · 0.45
TEST_CASEFunction · 0.45
get_event_idMethod · 0.45
get_load_intervalFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
add_quantize_opFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45
TEST_CASEFunction · 0.45

Calls 15

get_modulesMethod · 0.95
get_migraphx_versionFunction · 0.85
containsFunction · 0.85
atMethod · 0.80
is_normalizedMethod · 0.80
to_valueFunction · 0.50
transformFunction · 0.50
nameMethod · 0.45
printMethod · 0.45
get_shapeMethod · 0.45
beginMethod · 0.45
inputsMethod · 0.45

Tested by 6

TEST_CASEFunction · 0.36
get_load_intervalFunction · 0.36
TEST_CASEFunction · 0.36
TEST_CASEFunction · 0.36
add_quantize_opFunction · 0.36
check_compiled_programFunction · 0.36