[INFO] Initializing environment for https://gitcode.com/pre-commit/pre-commit-hooks. [WARNING] repo `https://gitcode.com/pre-commit/pre-commit-hooks` uses deprecated stage names (commit, push) which will be removed in a future version. Hint: often `pre-commit autoupdate --repo https://gitcode.com/pre-commit/pre-commit-hooks` will fix this. if it does not -- consider reporting an issue to that repo. [INFO] Initializing environment for https://gitcode.com/pre-commit-clang/mirrors-clang-format. [INFO] Initializing environment for https://gitcode.com/gh_mirrors/ru/ruff-pre-commit. [INFO] Initializing environment for https://gitcode.com/gh_mirrors/co/codespell. [INFO] Installing environment for https://gitcode.com/pre-commit/pre-commit-hooks. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://gitcode.com/pre-commit-clang/mirrors-clang-format. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://gitcode.com/gh_mirrors/ru/ruff-pre-commit. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://gitcode.com/gh_mirrors/co/codespell. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... trim trailing whitespace.................................................Passed fix end of files.........................................................Passed check yaml...........................................(no files to check)Skipped check for added large files..............................................Passed check for merge conflicts................................................Passed detect private key.......................................................Passed check json...........................................(no files to check)Skipped clang-format.........................................(no files to check)Skipped ruff check...............................................................Passed ruff format..............................................................Failed - hook id: ruff-format - files were modified by this hook 1 file reformatted codespell................................................................Passed All changes made by hooks: diff --git a/scripts/util/modify_gen_aclnn_static.py b/scripts/util/modify_gen_aclnn_static.py index a25afd1..4485162 100644 --- a/scripts/util/modify_gen_aclnn_static.py +++ b/scripts/util/modify_gen_aclnn_static.py @@ -28,11 +28,15 @@ def shell_exec(cmd, shell=False): def search_file(aclnn_cpp): op_type = None index = 0 - with open(aclnn_cpp, 'r') as f: + with open(aclnn_cpp, "r") as f: for line in f.readlines(): index = index + 1 if "_op_resource.h" in line: - op_type = line.replace("_op_resource.h\"", "").replace("#include \"", "").strip() + op_type = ( + line.replace('_op_resource.h"', "") + .replace('#include "', "") + .strip() + ) if "EXTERN_OP_RESOURCE" in line or "namespace op {" in line: break return (op_type, index) @@ -43,13 +47,32 @@ def modify_gen_aclnn(build_path): for aclnn_cpp in auto_gen_cpps: (op_type, index) = search_file(aclnn_cpp) if op_type: - shell_exec(["bash", "-c", f"""sed -i 's/{op_type}_op_resource.h/op_resource_ras.h/g' {aclnn_cpp}"""], - shell=False) shell_exec( - ["bash", "-c", f"""sed -i 's/{op_type}_RESOURCES/AUTO_GEN_OP_RESOURCE({op_type})/g' {aclnn_cpp}"""], - shell=False) - shell_exec(["bash", "-c", f"sed -i '{index}i\\EXTERN_OP_RESOURCE({op_type})' {aclnn_cpp}"], shell=False) + [ + "bash", + "-c", + f"""sed -i 's/{op_type}_op_resource.h/op_resource_ras.h/g' {aclnn_cpp}""", + ], + shell=False, + ) + shell_exec( + [ + "bash", + "-c", + f"""sed -i 's/{op_type}_RESOURCES/AUTO_GEN_OP_RESOURCE({op_type})/g' {aclnn_cpp}""", + ], + shell=False, + ) + shell_exec( + [ + "bash", + "-c", + f"sed -i '{index}i\\EXTERN_OP_RESOURCE({op_type})' {aclnn_cpp}", + ], + shell=False, + ) return -if __name__ == '__main__': + +if __name__ == "__main__": modify_gen_aclnn(sys.argv[1])