How Do I Convert the Format of a Dump File?
Converting the Format of a Dump File
In the current version, dump files generated by running on the Ascend AI Processor can be converted into NumPy format.
To perform the conversion, execute the msaccucmp.pyc script stored in the /home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/tools/operator_cmp/compare path. The command syntax is as follows:
python3.7.5 msaccucmp.pyc convert -d dump_file [-out output] [-f format -s shape] [-o output_tensor] [-i input_tensor] [-c custom_script_path]
Table 5-6 describes the command-line options.
Option |
Description |
---|---|
-d --dump_file |
(Required) Dump file (including the path) of a model running on the Ascend AI Processor |
-out --output |
(Optional) Directory of the converted data. Defaults to the current path. |
-f --format |
(Optional)
|
-s --shape |
(Optional) Shape to be set for FRACTAL_NZ conversion. The shape format is ([0-9]+,)+[0-9]+, where each number must be greater than 0. Valid only when -f is configured. |
-o --output_tensor |
(Optional) Index of the output to convert. Mutually exclusive with -i. Valid only when -f is configured. If neither -o nor -i is configured, the output indexed 0 is converted. |
-i --input_tensor |
(Optional) Index of the input to convert. Mutually exclusive with -o. Valid only when -f is configured. |
-c --custom_script_path |
(Optional) Customized path to store the .py file for format conversion, which should be the upper-level directory of the format_convert directory. For details about the .py file requirements, see Preparing a Customized .py File for Format Conversion. Valid only when -f is configured. |
The result is saved in the format of original_file_name.output.{index}.{shape}.npy or original_file_name.input.{index}.{shape}.npy, where shape is formatted as 1x3x224x224.
Currently, the following built-in format conversion types are supported:
- FRACTAL_NZ to NCHW
- FRACTAL_NZ to NHWC
- FRACTAL_NZ to ND
- HWCN to FRACTAL_Z
- HWCN to NCHW
- HWCN to NHWC
- NC1HWC0 to HWCN
- NC1HWC0 to NCHW
- NC1HWC0 to NHWC
- NCHW to FRACTAL_Z
- NCHW to NHWC
- NHWC to FRACTAL_Z
- NHWC to HWCN
- NHWC to NCHW
Preparing a Customized .py File for Format Conversion
Prepare the file as follows:
- The name of the .py file is in convert_{format_from}_to_{format_to}.py format. The supported formats for format _from and format _to are as follows:
- NCHW
- NHWC
- ND
- NC1HWC0
- FRACTAL_Z
- NC1C0HWPAD
- NHWC1C0
- FSR_NCHW
- FRACTAL_DECONV
- C1HWNC0
- FRACTAL_DECONV_TRANSPOSE
- FRACTAL_DECONV_SP_STRIDE_TRANS
- NC1HWC0_C04
- FRACTAL_Z_C04
- CHWN
- DECONV_SP_STRIDE8_TRANS
- NC1KHKWHWC0
- BN_WEIGHT
- FILTER_HWCK
- HWCN
- LOOKUP_LOOKUPS
- LOOKUP_KEYS
- LOOKUP_VALUE
- LOOKUP_OUTPUT
- LOOKUP_HITS
- MD
- NDHWC
- C1HWNCoC0
- FRACTAL_NZ
- The content of the .py file is as follows:
def convert(shape_from, shape_to, array): return numpy_array
The parameters are described as follows:
shape_from: shape of the one-dimensional array before conversion
shape_to: (optional) shape of the one-dimensional array after conversion
array: one-dimensional source data
return: NumPy array after conversion
- The directory of the .py file must meet the following requirement:
The .py file must be stored in the format_convert directory. If the directory does not exist, create one.