diff --git a/mace/python/tools/converter_tool/tensorflow_converter.py b/mace/python/tools/converter_tool/tensorflow_converter.py index 0f5f3e21fb4b20cb6230f96b22695136bcd6415e..e7ff180c5fc17f046bfdf95b18d8fcb15ed2f7da 100644 --- a/mace/python/tools/converter_tool/tensorflow_converter.py +++ b/mace/python/tools/converter_tool/tensorflow_converter.py @@ -318,7 +318,16 @@ class TensorflowConverter(base_converter.ConverterInterface): else: mace_check(False, "data type %s not supported" % dtype) except ValueError: - data_type_arg.i = self._option.data_type + try: + dtype = tf_op.get_attr('SrcT') + if dtype == tf.int32 or dtype == tf.bool: + data_type_arg.i = mace_pb2.DT_INT32 + elif dtype == tf.float32: + data_type_arg.i = self._option.data_type + else: + mace_check(False, "data type %s not supported" % dtype) + except ValueError: + data_type_arg.i = self._option.data_type ConverterUtil.add_data_format_arg(op, DataFormat.NHWC) diff --git a/tools/sh_commands.py b/tools/sh_commands.py index 92752c5790612791c17595b0fdb83a9fa486aee0..97d66ca4a5fdde77a28a79e12613f1461bd28ebc 100644 --- a/tools/sh_commands.py +++ b/tools/sh_commands.py @@ -773,10 +773,13 @@ def tuning_run(abi, (phone_data_dir, os.path.basename(opencl_binary_file)), ]) adb_cmd = ' '.join(adb_cmd) - adb_cmd_file = "%s/%s" % (phone_data_dir, 'cmd_file') - with open('/tmp/mace_cmd_file', 'w') as cmd_file: + cmd_file_name = "%s-%s-%s" % ('cmd_file', model_tag, str(time.time())) + adb_cmd_file = "%s/%s" % (phone_data_dir, cmd_file_name) + tmp_cmd_file = "%s/%s" % ('/tmp', cmd_file_name) + with open(tmp_cmd_file, 'w') as cmd_file: cmd_file.write(adb_cmd) - adb_push('/tmp/mace_cmd_file', adb_cmd_file, serialno) + adb_push(tmp_cmd_file, adb_cmd_file, serialno) + os.remove(tmp_cmd_file) sh.adb( "-s", @@ -790,7 +793,17 @@ def tuning_run(abi, stdout = "".join(stdout_buff) if not stdout_success(stdout): common.MaceLogger.error("Mace Run", "Mace run failed.") + + sh.adb( + "-s", + serialno, + "shell", + "rm", + adb_cmd_file, + _fg=True) + print("Running finished!\n") + return stdout @@ -1190,10 +1203,13 @@ def benchmark_model(abi, (phone_data_dir, os.path.basename(opencl_binary_file)), ] adb_cmd = ' '.join(adb_cmd) - adb_cmd_file = "%s/%s" % (phone_data_dir, 'cmd_file') - with open('/tmp/mace_cmd_file', 'w') as cmd_file: + cmd_file_name = "%s-%s-%s" % ('cmd_file', model_tag, str(time.time())) + adb_cmd_file = "%s/%s" % (phone_data_dir, cmd_file_name) + tmp_cmd_file = "%s/%s" % ('/tmp', cmd_file_name) + with open(tmp_cmd_file, 'w') as cmd_file: cmd_file.write(adb_cmd) - adb_push('/tmp/mace_cmd_file', adb_cmd_file, serialno) + adb_push(tmp_cmd_file, adb_cmd_file, serialno) + os.remove(tmp_cmd_file) sh.adb( "-s", @@ -1203,6 +1219,14 @@ def benchmark_model(abi, adb_cmd_file, _fg=True) + sh.adb( + "-s", + serialno, + "shell", + "rm", + adb_cmd_file, + _fg=True) + print("Benchmark done!\n")