| 814 | } |
| 815 | |
| 816 | void program::from_value(const value& v) |
| 817 | { |
| 818 | auto version = v.at("version").to<int>(); |
| 819 | if(version != program_file_version) |
| 820 | { |
| 821 | MIGRAPHX_THROW( |
| 822 | "Error: Program version mismatch. MXR file was created using program file version: " + |
| 823 | std::to_string(version) + ", while installed MIGraphX is using program file version: " + |
| 824 | std::to_string(program_file_version) + |
| 825 | ", Try regenerating MXR file using installed MIGraphX and running again."); |
| 826 | } |
| 827 | |
| 828 | auto migx_version = v.at("migraphx_version").to<std::string>(); |
| 829 | if(migx_version != get_migraphx_version()) |
| 830 | { |
| 831 | std::cerr << "[WARNING]: MXR File was created using MIGraphX version: " << migx_version |
| 832 | << ", while installed MIGraphX is at version: " << get_migraphx_version() |
| 833 | << ", operators implementation could be mismatched.\n"; |
| 834 | } |
| 835 | |
| 836 | migraphx::from_value(v.at("targets"), this->impl->targets); |
| 837 | |
| 838 | for(auto i : range(this->impl->targets.size())) |
| 839 | { |
| 840 | this->impl->contexts.push_back(this->impl->targets[i].get_context()); |
| 841 | this->impl->contexts.back().from_value(v.at("contexts")[i]); |
| 842 | } |
| 843 | |
| 844 | auto module_vals = v.at("modules"); |
| 845 | for(const auto& vv : module_vals) |
| 846 | { |
| 847 | const auto& name = vv.get_key(); |
| 848 | if(name == "main") |
| 849 | continue; |
| 850 | impl->modules.emplace(name, name); |
| 851 | } |
| 852 | std::unordered_map<std::string, module_ref> map_mods; |
| 853 | std::transform(impl->modules.begin(), |
| 854 | impl->modules.end(), |
| 855 | std::inserter(map_mods, map_mods.end()), |
| 856 | [&](auto&& pp) { return std::make_pair(pp.first, &pp.second); }); |
| 857 | |
| 858 | std::unordered_map<std::string, instruction_ref> map_insts; |
| 859 | auto* mm = get_main_module(); |
| 860 | mod_from_val(mm, module_vals, map_insts, map_mods); |
| 861 | |
| 862 | // Finalize a compiled model |
| 863 | if(not this->impl->contexts.empty()) |
| 864 | this->finalize(); |
| 865 | } |
| 866 | |
| 867 | static double common_average(const std::vector<double>& v) |
| 868 | { |
no test coverage detected