Repository Merging

Overview

You can merge custom repositories in different directories by using AOE, which saves the tiling policies that outperform those in the built-in repositories in the specified output directory.

  • Only custom OPAT repositories of the same Ascend AI Processor model can be merged.
  • .json files whose names contain runtime_kb cannot be merged.

Procedure

  1. Copy the repositories to be merged generated in different environments to different directories in the target environment, for example, ${src_dir1} and ${src_dir2}.

    When copying a repository, you need to copy the entire custom repository path (TUNE_BANK_PATH) and the content in it. For example, if the path of a custom repository is /home/aoe/data and ${src_dir1} is /home/HwHiAiUser/data, run the following command to copy the repository:

    cp -r /home/aoe/data /home/HwHiAiUser

  2. Merge the repositories.
    1. Set the environment variables.

      The CANN portfolio provides a process-level environment variable setting script to automatically set environment variables. The following commands are used as examples, in which the default installation paths are under the root or non-root user. Replace them with actual installation paths.

      # Install Toolkit as the root user.
      . /usr/local/Ascend/ascend-toolkit/set_env.sh 
      # Install Toolkit as a non-root user.
      . ${HOME}/Ascend/ascend-toolkit/set_env.sh 
    2. Merge the repositories.

      python3 $HOME/Ascend/ascend-toolkit/latest/python/site-packages/schedule_search/msoptune.py --merge ${src_dir1}:${src_dir2} ${dst_dir}

      • ${src_dirx}: Separate multiple src_dir directories by colons (:). src_dir is the ${src_dir} specified in 1 for storing the repository to be merged.
      • ${dst_dir}: output directory of the merged custom repository. It can be an absolute path or a relative path. The path must exist and the msoptune.py script must have the read, write, and execute permissions on the path.

      If you want to use the merged repository during model compilation, specify its path by using the TUNE_BANK_PATH environment variable. For details about the environment variables, see Environment Variable Configuration.

      The msoptune.py --merge script provides the following functions:

      • Merge the custom repositories in the ${src_dirx} directory.
      • Compare the merged custom repository with the built-in repository, and place the tiling policies that do not exist in the built-in repository or are better than the built-in repository into ${dst_dir}.

        The merged custom repositories are stored in the ${soc_version} directories under ${dst_dir}. The ${soc_version} directories are automatically created with the script execution.