diff --git a/build.sh b/build.sh index 877da435b39..33dce9c28c1 100755 --- a/build.sh +++ b/build.sh @@ -571,9 +571,9 @@ build_minddata_lite_deps() build_lite() { - VERSION_MAJOR=`grep "#define MS_VERSION_MAJOR" mindspore/lite/include/version.h | tr -dc "[0-9]"` - VERSION_MINOR=`grep "#define MS_VERSION_MINOR" mindspore/lite/include/version.h | tr -dc "[0-9]"` - VERSION_REVISION=`grep "#define MS_VERSION_REVISION" mindspore/lite/include/version.h | tr -dc "[0-9]"` + VERSION_MAJOR=`grep "const int ms_version_major =" mindspore/lite/include/version.h | tr -dc "[0-9]"` + VERSION_MINOR=`grep "const int ms_version_minor =" mindspore/lite/include/version.h | tr -dc "[0-9]"` + VERSION_REVISION=`grep "const int ms_version_revision =" mindspore/lite/include/version.h | tr -dc "[0-9]"` echo "============ Start building MindSpore Lite ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION} ============" if [ "${ENABLE_GPU}" == "on" ] && [ "${LITE_PLATFORM}" == "arm64" ]; then echo "start build opencl" diff --git a/mindspore/lite/include/version.h b/mindspore/lite/include/version.h index 9e16aafe8eb..f08a55bbbc5 100644 --- a/mindspore/lite/include/version.h +++ b/mindspore/lite/include/version.h @@ -21,16 +21,16 @@ namespace mindspore { namespace lite { -#define MS_VERSION_MAJOR 0 -#define MS_VERSION_MINOR 7 -#define MS_VERSION_REVISION 0 +const int ms_version_major = 0; +const int ms_version_minor = 7; +const int ms_version_revision = 0; /// \brief Global method to get a version string. /// /// \return The version string of MindSpore Lite. -std::string Version() { - return "MindSpore Lite " + std::to_string(MS_VERSION_MAJOR) + "." + std::to_string(MS_VERSION_MINOR) + "." + - std::to_string(MS_VERSION_REVISION); +inline std::string Version() { + return "MindSpore Lite " + std::to_string(ms_version_major) + "." + std::to_string(ms_version_minor) + "." + + std::to_string(ms_version_revision); } } // namespace lite } // namespace mindspore diff --git a/mindspore/lite/schema/model.fbs b/mindspore/lite/schema/model.fbs index e3d33eb0b7a..d9c7a904447 100644 --- a/mindspore/lite/schema/model.fbs +++ b/mindspore/lite/schema/model.fbs @@ -219,6 +219,7 @@ table CNode { table MetaGraph { name: string; + version: string; fmkType: int; // 0:tf,1:caffe inputIndex: [uint]; outputIndex: [uint]; diff --git a/mindspore/lite/tools/benchmark/benchmark.cc b/mindspore/lite/tools/benchmark/benchmark.cc index 60db766accf..2a38e381cd1 100644 --- a/mindspore/lite/tools/benchmark/benchmark.cc +++ b/mindspore/lite/tools/benchmark/benchmark.cc @@ -24,6 +24,7 @@ #include "include/ms_tensor.h" #include "include/context.h" #include "src/runtime/runtime_api.h" +#include "include/version.h" namespace mindspore { namespace lite { @@ -352,6 +353,10 @@ int Benchmark::RunBenchmark(const std::string &deviceType) { return RET_ERROR; } auto model = lite::Model::Import(graphBuf, size); + auto model_version = model->GetMetaGraph()->version()->str(); + if (model_version != Version()) { + MS_LOG(WARNING) << "model version is "<< model_version << ", inference version is " << Version() << " not equal"; + } if (model == nullptr) { MS_LOG(ERROR) << "Import model file failed while running " << modelName.c_str(); std::cerr << "Import model file failed while running " << modelName.c_str() << std::endl; diff --git a/mindspore/lite/tools/converter/converter.cc b/mindspore/lite/tools/converter/converter.cc index c0dae10a15f..620ecdc30f8 100644 --- a/mindspore/lite/tools/converter/converter.cc +++ b/mindspore/lite/tools/converter/converter.cc @@ -33,6 +33,7 @@ #include "tools/converter/parser/onnx/onnx.pb.h" #include "tools/converter/quantizer/post_training_quantizer.h" #include "tools/converter/quantizer/quant_cast.h" +#include "include/version.h" namespace mindspore { namespace lite { @@ -154,6 +155,7 @@ int RunConverter(int argc, const char **argv) { // save graph to file Storage storage; + fb_graph->version = Version(); status = storage.Save(*fb_graph, flags->outputFile); if (status != 0) { MS_LOG(ERROR) << "Save graph failed";