How Do I Convert an .npy File into a Dump File?

This function will be brought offline in later versions. You are advised to use the function of Converting Dump File Formats in the current version.

Converting the Caffe .npy File into a Dump File

After obtaining the Caffe .npy file, execute the dump_data_conversion.py script to convert it into a dump file in binary format. The command syntax is as follows:

python3 dump_data_conversion.py -type type -target target -i input_path -o output_path
  • -type: (required) data type, selected from:
    • quant: quantized Caffe model data
    • tf: non-quantized TensorFlow model data
    • caffe: non-quantized Caffe model data
    • offline: offline model data
  • -target: (required) target format, either numpy or dump
    • numpy: converts a dump file into a NumPy file.
    • dump: converts a NumPy file into a dump file.
  • -i: (required) data folder/file path
    • Converting NumPy files into dump files:

      To pass a folder path to i, ensure that names of the files in the folder are in {op_name}.{output_index}.{timestamp}.npy format.

      If the i parameter is set to a file name, the file name must be in the {op_name}.{output_index}.{timestamp}.npy format. Only one file can be set at a time.

      op_name must comply with the A-Za-z0-9_- regular expression rule, timestamp is of 16 bits, and output_index is a digit in the range 0–9.

    • Converting dump files into NumPy files:

      The format of the folder or file name specified by the i parameter must comply with the naming conventions described in Dump File Naming Conventions.

  • -o: (required) output path

    You are not advised to configure directories that are different from those of the current user to avoid privilege escalation risks.

The following is a command example for converting the .npy file into a dump file:

python3 dump_data_conversion.py -type caffe -target dump -i $HOME/caffenpyfile -o $HOME/caffedump

  • The dump_data_conversion.py script is stored in ${INSTALL_DIR}/tools/operator_cmp/compare.Replace ${INSTALL_DIR} with the actual CANN component directory. If the Ascend-CANN-Toolkit package is installed as the root user, the CANN component directory is /usr/local/Ascend/ascend-toolkit/latest..
  • To use this script for conversion, ensure that the host has at least 15 GB disk space. If the size of a single dump file to be converted exceeds 441 MB, you are advised to use a host with larger disk space.

Converting the TensorFlow .npy File into a Dump File

After obtaining the TensorFlow .npy file, execute the dump_data_conversion.py script to convert it into a dump file in binary format. The command syntax is as follows:

python3 dump_data_conversion.py -type type -target target -i input_path -o output_path

The following is a command example for converting the .npy file into a dump file:

  • -type: (required) data type, selected from:
    • quant: quantized Caffe model data
    • tf: non-quantized TensorFlow model data
    • caffe: non-quantized Caffe model data
    • offline: offline model data
  • -target: (required) target format, either numpy or dump
    • numpy: converts a dump file into a NumPy file.
    • dump: converts a NumPy file into a dump file.
  • -i: (required) data folder/file path
    • Converting NumPy files into dump files:

      To pass a folder path to i, ensure that names of the files in the folder are in {op_name}.{output_index}.{timestamp}.npy format.

      If the i parameter is set to a file name, the file name must be in the {op_name}.{output_index}.{timestamp}.npy format. Only one file can be set at a time.

      op_name must comply with the A-Za-z0-9_- regular expression rule, timestamp is of 16 bits, and output_index is a digit in the range 0–9.

    • Converting dump files into NumPy files:

      The format of the folder or file name specified by the i parameter must comply with the naming conventions described in Dump File Naming Conventions.

  • -o: (required) output path

    You are not advised to configure directories that are different from those of the current user to avoid privilege escalation risks.

The following is a command example for converting the .npy file into a dump file:

python3 dump_data_conversion.py -type tf -target dump -i $HOME/tfnpyfile -o $HOME/tfdump

  • The dump_data_conversion.py script is stored in $HOME/Ascend/ascend-toolkit/latest/tools/operator_cmp/compare.
  • To use this script for conversion, ensure that the host has at least 15 GB disk space. If the size of a single dump file to be converted exceeds 441 MB, you are advised to use a host with larger disk space.