提交 32ffb40f 编写于 作者: L Liangliang He

Add introspective build info

上级 d3ccb99b
......@@ -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;
......
......@@ -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())
......
......@@ -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
......@@ -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
......
......@@ -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)
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册