Skip to content

Correctly handle include replacements. #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions tools/amd_build/pyHIPIFY/hipify-python.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,16 @@ def preprocessor(filepath, stats, hipify_caffe2):
if constants.HIP_UNSUPPORTED in meta_data:
stats["unsupported_calls"].append((cuda_type, filepath))

if cuda_type in output_source:
if hipify_caffe2:
pattern = r'({0})'.format(re.escape(cuda_type))
else:
pattern = r'(\b{0}\b)'.format(re.escape(cuda_type))
# Correctly include replacements in a special way.
if constants.CONV_INCLUDE in meta_data or constants.CONV_INCLUDE_CUDA_MAIN_H in meta_data:
pattern1 = r'("{0}")'.format(re.escape(cuda_type))
pattern2 = r'(<{0}>)'.format(re.escape(cuda_type))
output_source = re.sub(pattern1, '"{0}"'.format(hip_type), output_source)
output_source = re.sub(pattern2, '<{0}>'.format(hip_type), output_source)

# Handle all other replacements as regularly
elif cuda_type in output_source:
pattern = r'({0})'.format(re.escape(cuda_type))
output_source = re.sub(pattern, hip_type, output_source)

# Perform Kernel Launch Replacements
Expand Down