From dabe486e6654cdd874b6ec192236ab174b3b5606 Mon Sep 17 00:00:00 2001 From: Liangliang He Date: Mon, 5 Mar 2018 15:20:41 +0800 Subject: [PATCH] Add model checksum and change build path format --- generate_model_code.sh | 1 + mace_tools.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/generate_model_code.sh b/generate_model_code.sh index 6247cdc4..d7721416 100644 --- a/generate_model_code.sh +++ b/generate_model_code.sh @@ -16,6 +16,7 @@ if [ "${BENCHMARK_FLAG}" = "1" ]; then fi bazel-bin/lib/python/tools/tf_converter --input=${MODEL_FILE_PATH} \ + --model_checksum=${MODEL_SHA256_CHECKSUM} \ --output=${MODEL_CODEGEN_DIR}/model.cc \ --input_node=${INPUT_NODE} \ --output_node=${OUTPUT_NODE} \ diff --git a/mace_tools.py b/mace_tools.py index 0b6d138a..8ae47d0f 100644 --- a/mace_tools.py +++ b/mace_tools.py @@ -7,7 +7,7 @@ # --mode=all import argparse -import base64 +import hashlib import os import shutil import subprocess @@ -165,7 +165,7 @@ def parse_args(): default="./tool/config", help="The global config file of models.") parser.add_argument( - "--output_dir", type=str, default="./build/", help="The output dir.") + "--output_dir", type=str, default="build", help="The output dir.") parser.add_argument( "--round", type=int, default=1, help="The model running round.") parser.add_argument( @@ -208,8 +208,10 @@ def main(unused_args): for key in model_config: os.environ[key.upper()] = str(model_config[key]) - model_output_dir = FLAGS.output_dir + "/" + target_abi + "/" + model_name + "/" + base64.b16encode( - model_config["model_file_path"]) + md5 = hashlib.md5() + md5.update(model_config["model_file_path"]) + model_path_digest = md5.hexdigest() + model_output_dir = "%s/%s/%s/%s" % (FLAGS.output_dir, model_name, model_path_digest, target_abi) model_output_dirs.append(model_output_dir) if FLAGS.mode == "build" or FLAGS.mode == "all": -- GitLab