"git@developer.sourcefind.cn:wangsen/mineru.git" did not exist on "05c0b9b34009121d4d0b4c02662c1acd606f28b2"
Unverified Commit 8428a242 authored by Umang Yadav's avatar Umang Yadav Committed by GitHub
Browse files

Add MIGraphX version inside MXR file (#1866)

parent 0e144f05
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include <migraphx/version.h>
#include <migraphx/compile_options.hpp> #include <migraphx/compile_options.hpp>
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/stringutils.hpp> #include <migraphx/stringutils.hpp>
...@@ -610,16 +611,28 @@ void program::finish() const ...@@ -610,16 +611,28 @@ void program::finish() const
ctx.finish(); ctx.finish();
} }
std::string get_migraphx_version()
{
std::stringstream ss;
ss << std::to_string(MIGRAPHX_VERSION_MAJOR) << "." << std::to_string(MIGRAPHX_VERSION_MINOR)
<< "." << std::to_string(MIGRAPHX_VERSION_PATCH);
return ss.str();
}
/*
program file version is for the data structure or format of the MXR file. Version should be bumped
if any changes occur to the format of the MXR file.
*/
const int program_file_version = 6; const int program_file_version = 6;
value program::to_value() const value program::to_value() const
{ {
value result; value result;
result["version"] = program_file_version; result["version"] = program_file_version;
result["targets"] = migraphx::to_value(this->impl->targets); result["migraphx_version"] = get_migraphx_version();
result["contexts"] = migraphx::to_value(this->impl->contexts); result["targets"] = migraphx::to_value(this->impl->targets);
result["contexts"] = migraphx::to_value(this->impl->contexts);
value module_vals = value::object{}; value module_vals = value::object{};
std::unordered_map<instruction_ref, std::string> names; std::unordered_map<instruction_ref, std::string> names;
for(auto& mod : this->get_modules()) for(auto& mod : this->get_modules())
{ {
...@@ -743,7 +756,19 @@ void program::from_value(const value& v) ...@@ -743,7 +756,19 @@ void program::from_value(const value& v)
auto version = v.at("version").to<int>(); auto version = v.at("version").to<int>();
if(version != program_file_version) if(version != program_file_version)
{ {
MIGRAPHX_THROW("Warning: Program version mismatch"); MIGRAPHX_THROW(
"Error: Program version mismatch. MXR file was created using program file version: " +
std::to_string(version) + ", while installed MIGraphX is using program file version: " +
std::to_string(program_file_version) +
", Try regenerating MXR file using installed MIGraphX and running again.");
}
auto migx_version = v.at("migraphx_version").to<std::string>();
if(migx_version != get_migraphx_version())
{
std::cout << "WARNING: MXR File was created using MIGraphX version: " << migx_version
<< ", while installed MIGraphX is at version: " << get_migraphx_version()
<< ", operators implementation could be mismatched.";
} }
migraphx::from_value(v.at("targets"), this->impl->targets); migraphx::from_value(v.at("targets"), this->impl->targets);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment