Browse Source

!1319 fix the ci warning

From: @yelihua
Reviewed-by: @ouwenchang,@liuchongming74
Signed-off-by: @liuchongming74
pull/1319/MERGE
mindspore-ci-bot Gitee 4 years ago
parent
commit
6bcf6dcad5
1 changed files with 13 additions and 9 deletions
  1. +13
    -9
      mindinsight/debugger/dump/convert.py

+ 13
- 9
mindinsight/debugger/dump/convert.py View File

@@ -178,10 +178,10 @@ class DirConvert:


def rename_generated_npy_file(self): def rename_generated_npy_file(self):
"""Rename the npy file generated by HISI tool to MS file name format.""" """Rename the npy file generated by HISI tool to MS file name format."""
# before change, the file name is format like:
# {op_type}.{op_name_with_scope}.{task_id}(.stream_id).{timestamp}.{tensor_type}.{slot}.{shape}.npy
# after change, the file name is format like:
# {op_type}.{op_name}.{task_id}(.stream_id).{timestamp}.{tensor_type}.{slot}.{format}.npy
# before change
# file name: {op_type}.{op_name_with_scope}.{task_id}(.stream_id).{timestamp}.{tensor_type}.{slot}.{shape}.npy
# after change
# file name: {op_type}.{op_name}.{task_id}(.stream_id).{timestamp}.{tensor_type}.{slot}.{format}.npy
if not self._is_npy_target(): if not self._is_npy_target():
return return
self.hisi_utils.print_info_log( self.hisi_utils.print_info_log(
@@ -193,6 +193,7 @@ class DirConvert:
name_splits[1] = name_splits[1].split('_')[-1] name_splits[1] = name_splits[1].split('_')[-1]
name_splits[-2] = target_format name_splits[-2] = target_format
new_file_name = '.'.join(name_splits) new_file_name = '.'.join(name_splits)
file.chmod(stat.S_IRUSR)
file.rename(file.with_name(new_file_name)) file.rename(file.with_name(new_file_name))


def convert_failed_tensors(self): def convert_failed_tensors(self):
@@ -200,6 +201,7 @@ class DirConvert:
failed_lines = [] failed_lines = []
if not self.failed_file_path.is_file(): if not self.failed_file_path.is_file():
return failed_lines return failed_lines
os.chmod(self.failed_file_path, stat.S_IRUSR)
with self.failed_file_path.open() as handler: with self.failed_file_path.open() as handler:
failed_line = handler.readline().strip('\n') failed_line = handler.readline().strip('\n')
while failed_line: while failed_line:
@@ -224,7 +226,7 @@ class DirConvert:
for missing_tensor in missing_tensors: for missing_tensor in missing_tensors:
tensor_type, idx = missing_tensor.split(':') tensor_type, idx = missing_tensor.split(':')
idx = int(idx) idx = int(idx)
tensor = op_data.input[idx] if tensor_type == 'input' else op_data.output[idx]
tensor = getattr(op_data, tensor_type)[idx]
dump_data_array = self.get_tensor_numpy_value(tensor) dump_data_array = self.get_tensor_numpy_value(tensor)
self.save_tensor_file(op_file, tensor_type, idx, tensor, dump_data_array) self.save_tensor_file(op_file, tensor_type, idx, tensor, dump_data_array)


@@ -280,6 +282,7 @@ class DirConvert:
) )
out_path = os.path.join(self.args_parser.output_path, out_file_name) out_path = os.path.join(self.args_parser.output_path, out_file_name)
np.save(out_path, dump_data_array) np.save(out_path, dump_data_array)
os.chmod(out_path, stat.S_IRUSR)


def _save_tensor_in_bin(self, op_name, tensor_type, idx, tensor, dump_data_array): def _save_tensor_in_bin(self, op_name, tensor_type, idx, tensor, dump_data_array):
""" """
@@ -304,6 +307,7 @@ class DirConvert:
) )
out_path = os.path.join(self.args_parser.output_path, out_file_name) out_path = os.path.join(self.args_parser.output_path, out_file_name)
dump_data_array.tofile(out_path) dump_data_array.tofile(out_path)
os.chmod(out_path, stat.S_IRUSR)




class FileMapping: class FileMapping:
@@ -474,14 +478,14 @@ class OpPath:
return [str(path) for path in path_gen] return [str(path) for path in path_gen]


@property @property
def input(self):
def inputs(self):
"""The list of input tensor files.""" """The list of input tensor files."""
if self._input_files is None: if self._input_files is None:
self._input_files = self._convert_path_gen_to_list(self._input_gen) self._input_files = self._convert_path_gen_to_list(self._input_gen)
return self._input_files return self._input_files


@property @property
def output(self):
def outputs(self):
"""The list of output tensor file paths.""" """The list of output tensor file paths."""
if self._output_files is None: if self._output_files is None:
self._output_files = self._convert_path_gen_to_list(self._output_gen) self._output_files = self._convert_path_gen_to_list(self._output_gen)
@@ -495,7 +499,7 @@ class OpPath:
def to_dict(self): def to_dict(self):
"""Get operator files of one iteration in dict format.""" """Get operator files of one iteration in dict format."""
res = { res = {
'input': self.input,
'output': self.output
'input': self.inputs,
'output': self.outputs
} }
return res return res

Loading…
Cancel
Save