diff --git a/mace/examples/example.cc b/mace/examples/example.cc index 52809a4fc217de50ceca7df2635836625fc7cacf..424f06ec188d6570e5db084a39abb3862afe0e8a 100644 --- a/mace/examples/example.cc +++ b/mace/examples/example.cc @@ -47,7 +47,10 @@ extern void UnloadModelData(const unsigned char *model_data); extern NetDef CreateNet(const unsigned char *model_data); +extern const std::string ModelName(); extern const std::string ModelChecksum(); +extern const std::string ModelBuildTime(); +extern const std::string ModelBuildOptions(); } // namespace MACE_MODEL_TAG } // namespace mace @@ -246,7 +249,10 @@ int Main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); LOG(INFO) << "mace version: " << MaceVersion(); + LOG(INFO) << "model name: " << mace::MACE_MODEL_TAG::ModelName(); LOG(INFO) << "model checksum: " << mace::MACE_MODEL_TAG::ModelChecksum(); + LOG(INFO) << "build time: " << mace::MACE_MODEL_TAG::ModelBuildTime(); + LOG(INFO) << "build options: " << mace::MACE_MODEL_TAG::ModelBuildOptions(); LOG(INFO) << "input node: " << FLAGS_input_node; LOG(INFO) << "input shape: " << FLAGS_input_shape; LOG(INFO) << "output node: " << FLAGS_output_node; diff --git a/mace/python/tools/converter.py b/mace/python/tools/converter.py index b14d891250069194e78dbf657bdc8649b3b7b8d4..056a0b2c1077ea4dc45abcfe68e9c47d6cb25ea4 100644 --- a/mace/python/tools/converter.py +++ b/mace/python/tools/converter.py @@ -84,7 +84,7 @@ def main(unused_args): source_converter_lib.convert_to_source( output_graph_def, model_checksum, FLAGS.template, FLAGS.obfuscate, FLAGS.model_tag, FLAGS.output, FLAGS.runtime, - FLAGS.embed_model_data) + FLAGS.embed_model_data, FLAGS.winograd) else: with open(FLAGS.output, "wb") as f: f.write(output_graph_def.SerializeToString()) diff --git a/mace/python/tools/model.jinja2 b/mace/python/tools/model.jinja2 index b72f84e0cfb1770c969c7a78664517521e8fad14..3555b20513fc3bdeabfc1a51f8a8ce73c32d1dd3 100644 --- a/mace/python/tools/model.jinja2 +++ b/mace/python/tools/model.jinja2 @@ -154,9 +154,22 @@ NetDef CreateNet(const unsigned char *model_data) { return net_def; } +const std::string ModelName() { + return {{ tag|tojson }}; +} + const std::string ModelChecksum() { return {{ model_pb_checksum|tojson }}; } +const std::string ModelBuildTime() { + return {{ build_time|tojson }}; +} + +const std::string ModelBuildOptions() { + return {{ "runtime: {}, obfuscate: {}, embed_model_data: {}, winograd: {}" + .format(runtime, obfuscate, embed_model_data, winograd_conv)|tojson }}; +} + } // namespace {{tag}} } // namespace mace diff --git a/mace/python/tools/model_header.jinja2 b/mace/python/tools/model_header.jinja2 index 8ef977dbe14172ce9373ca9a9024811f67a14c34..ace89933f014658a2777a4723921ecb504562a16 100644 --- a/mace/python/tools/model_header.jinja2 +++ b/mace/python/tools/model_header.jinja2 @@ -30,8 +30,14 @@ void UnloadModelData(const unsigned char *model_data); NetDef CreateNet(const unsigned char *model_data); +const std::string ModelName(); + const std::string ModelChecksum(); +const std::string ModelBuildTime(); + +const std::string ModelBuildOptions(); + } // namespace {{ tag }} } // namespace mace diff --git a/mace/python/tools/source_converter_lib.py b/mace/python/tools/source_converter_lib.py index 9d6bc8970d84b4c77303cce66798a4d3bb5bedb2..c9fda3de87fdb76e2a9109a984510c566564259c 100644 --- a/mace/python/tools/source_converter_lib.py +++ b/mace/python/tools/source_converter_lib.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import datetime import os import uuid import numpy as np @@ -124,7 +125,8 @@ def stringfy(value): def convert_to_source(net_def, mode_pb_checksum, template_dir, obfuscate, - model_tag, output, runtime, embed_model_data): + model_tag, output, runtime, embed_model_data, + winograd_conv): if obfuscate: obfuscate_name(net_def) else: @@ -193,6 +195,7 @@ def convert_to_source(net_def, mode_pb_checksum, template_dir, obfuscate, counter += 1 # generate model source files + build_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') template_name = 'model.jinja2' tensors = [ TensorInfo(i, net_def.tensors[i], runtime) @@ -203,7 +206,11 @@ def convert_to_source(net_def, mode_pb_checksum, template_dir, obfuscate, net=net_def, tag=model_tag, runtime=runtime, - model_pb_checksum=mode_pb_checksum) + obfuscate=obfuscate, + embed_model_data=embed_model_data, + winograd_conv=winograd_conv, + model_pb_checksum=mode_pb_checksum, + build_time=build_time) with open(output, "wb") as f: f.write(source) diff --git a/mace/tools/validation/mace_run.cc b/mace/tools/validation/mace_run.cc index c0d984897938225eb307044f6ea729a58d761861..2a709ededfb34fe95123870d3c28911c8a08591e 100644 --- a/mace/tools/validation/mace_run.cc +++ b/mace/tools/validation/mace_run.cc @@ -52,7 +52,10 @@ extern void UnloadModelData(const unsigned char *model_data); extern NetDef CreateNet(const unsigned char *model_data); +extern const std::string ModelName(); extern const std::string ModelChecksum(); +extern const std::string ModelBuildTime(); +extern const std::string ModelBuildOptions(); } // namespace MACE_MODEL_TAG } // namespace mace @@ -355,7 +358,10 @@ int Main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); LOG(INFO) << "mace version: " << MaceVersion(); + LOG(INFO) << "model name: " << mace::MACE_MODEL_TAG::ModelName(); LOG(INFO) << "model checksum: " << mace::MACE_MODEL_TAG::ModelChecksum(); + LOG(INFO) << "build time: " << mace::MACE_MODEL_TAG::ModelBuildTime(); + LOG(INFO) << "build options: " << mace::MACE_MODEL_TAG::ModelBuildOptions(); LOG(INFO) << "input node: " << FLAGS_input_node; LOG(INFO) << "input shape: " << FLAGS_input_shape; LOG(INFO) << "output node: " << FLAGS_output_node;