mirror of
https://github.com/pytorch/pytorch.git
synced 2025-11-02 06:24:59 +08:00
Summary: - Speed up hipify_python.py by blacklisting useless (and quite large) directory trees that it would otherwise recurse into - Pass around relative paths instead of absolute paths. This makes it easier to do filename matches based on the root of the tree. - Redo the streaming output to contain more useful information - Make it handle c10/cuda correctly, rewrite c10::cuda to c10::hip, and the header name from CUDAMathCompat.h to CUDAHIPCompat.h Signed-off-by: Edward Z. Yang <ezyang@fb.com> Pull Request resolved: https://github.com/pytorch/pytorch/pull/13973 Differential Revision: D13062374 Pulled By: ezyang fbshipit-source-id: f0858dd18c94d449ff5dbadc22534c695dc0f8fb
59 lines
1.3 KiB
Python
Executable File
59 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
import argparse
|
|
import os
|
|
import sys
|
|
|
|
from pyHIPIFY import hipify_python
|
|
|
|
amd_build_dir = os.path.dirname(os.path.realpath(__file__))
|
|
proj_dir = os.path.join(os.path.dirname(os.path.dirname(amd_build_dir)))
|
|
|
|
includes = [
|
|
"caffe2/operators/*",
|
|
"caffe2/sgd/*",
|
|
"caffe2/image/*",
|
|
"caffe2/transforms/*",
|
|
"caffe2/video/*",
|
|
"caffe2/distributed/*",
|
|
"caffe2/queue/*",
|
|
"binaries/*",
|
|
"caffe2/**/*_test*",
|
|
"caffe2/core/*",
|
|
"caffe2/db/*",
|
|
"caffe2/utils/*",
|
|
"c10/cuda/*",
|
|
]
|
|
|
|
ignores = [
|
|
"caffe2/operators/depthwise_3x3_conv_op.cu",
|
|
"caffe2/operators/depthwise_3x3_conv_op_cudnn.cu",
|
|
"caffe2/operators/pool_op_cudnn.cu",
|
|
'**/hip/**',
|
|
]
|
|
|
|
file_extensions = ['.cc', '.cu', '.h', '.cuh']
|
|
|
|
parser = argparse.ArgumentParser(
|
|
description="The Script to Hipify Caffe2")
|
|
|
|
parser.add_argument(
|
|
'--hip-suffix',
|
|
type=str,
|
|
default='cc',
|
|
help="The suffix for the hipified files",
|
|
required=False)
|
|
|
|
args = parser.parse_args()
|
|
|
|
hipify_python.hipify(
|
|
project_directory=proj_dir,
|
|
output_directory=proj_dir,
|
|
includes=includes,
|
|
extensions=file_extensions,
|
|
ignores=ignores,
|
|
hipify_caffe2=True,
|
|
add_static_casts_option=True,
|
|
hip_suffix=args.hip_suffix)
|