tools/amd_build/pyHIPIFY/hipify-python.py
def preprocessor(filepath, stats, hipify_caffe2):
    """ Executes the CUDA -> HIP conversion on the specified file. """
    fin_path = filepath
    with open(fin_path, 'r') as fin:
        output_source = fin.read()

    fout_path = get_hip_file_path(filepath, hipify_caffe2)
    if not os.path.exists(os.path.dirname(fout_path)):
        os.makedirs(os.path.dirname(fout_path))

    with open(fout_path, 'w') as fout:
        # Perform type, method, constant replacements
        for mapping in CUDA_TO_HIP_MAPPINGS:
            for cuda_type, value in mapping.items():
                # Extract relevant information
                hip_type = value[0]
                meta_data = value[1:]

                if constants.API_CAFFE2 in meta_data and not hipify_caffe2:
                    continue
                if constants.API_RAND in meta_data and hipify_caffe2:
                    continue

                if output_source.find(cuda_type) > -1:
                    # Check if supported
                    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))
                    output_source = re.sub(pattern, hip_type, output_source)

        # Perform Kernel Launch Replacements
        output_source = processKernelLaunches(output_source, stats)

        # Disable asserts
        if not filepath.endswith("THCGeneral.h.in"):
            output_source = disable_asserts(output_source)

        # Replace std:: with non-std:: versions
        output_source = replace_math_functions(output_source)

        # Replace __forceinline__ with inline
        output_source = replace_forceinline(output_source)

        # Replace the extern __shared__
        output_source = replace_extern_shared(output_source)

        fout.write(output_source)
 Executes the CUDA -> HIP conversion on the specified file. 
Executes the CUDA -> HIP conversion on the specified file.
Executes the CUDA - > HIP conversion on the specified file .
def preprocessor(filepath, stats, hipify_caffe2):
    fin_path = filepath
    with open(fin_path, 'r') as fin:
        output_source = fin.read()
    fout_path = get_hip_file_path(filepath, hipify_caffe2)
    if not os.path.exists(os.path.dirname(fout_path)):
        os.makedirs(os.path.dirname(fout_path))
    with open(fout_path, 'w') as fout:
        for mapping in CUDA_TO_HIP_MAPPINGS:
            for cuda_type, value in mapping.items():
                hip_type = value[0]
                meta_data = value[1:]
                if constants.API_CAFFE2 in meta_data and not hipify_caffe2:
                    continue
                if constants.API_RAND in meta_data and hipify_caffe2:
                    continue
                if output_source.find(cuda_type) > -1:
                    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))
                    output_source = re.sub(pattern, hip_type, output_source)
        output_source = processKernelLaunches(output_source, stats)
        if not filepath.endswith("THCGeneral.h.in"):
            output_source = disable_asserts(output_source)
        output_source = replace_math_functions(output_source)
        output_source = replace_forceinline(output_source)
        output_source = replace_extern_shared(output_source)
        fout.write(output_source)
def preprocessor ( filepath , stats , hipify_caffe2 ) : fin_path = filepath with open ( fin_path , 'r' ) as fin : output_source = fin . read ( ) fout_path = get_hip_file_path ( filepath , hipify_caffe2 ) if not os . path . exists ( os . path . dirname ( fout_path ) ) : os . makedirs ( os . path . dirname ( fout_path ) ) with open ( fout_path , 'w' ) as fout : for mapping in CUDA_TO_HIP_MAPPINGS : for cuda_type , value in mapping . items ( ) : hip_type = value [ 0 ] meta_data = value [ 1 : ] if constants . API_CAFFE2 in meta_data and not hipify_caffe2 : continue if constants . API_RAND in meta_data and hipify_caffe2 : continue if output_source . find ( cuda_type ) > - 1 : 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 ) ) output_source = re . sub ( pattern , hip_type , output_source ) output_source = processKernelLaunches ( output_source , stats ) if not filepath . endswith ( "THCGeneral.h.in" ) : output_source = disable_asserts ( output_source ) output_source = replace_math_functions ( output_source ) output_source = replace_forceinline ( output_source ) output_source = replace_extern_shared ( output_source ) fout . write ( output_source )
Executes the CUDA -> HIP conversion on the specified file.
Executes the CUDA - > HIP conversion on the specified file .
""" Executes the CUDA -> HIP conversion on the specified file. """ # Perform type, method, constant replacements # Extract relevant information # Check if supported # Perform Kernel Launch Replacements # Disable asserts # Replace std:: with non-std:: versions # Replace __forceinline__ with inline # Replace the extern __shared__
filepath
stats
hipify_caffe2