Python torch.utils.cpp_extension.CppExtension() Examples

The following are 1 code examples of torch.utils.cpp_extension.CppExtension(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module torch.utils.cpp_extension , or try the search function .
Example #1
Source File: setup.py    From L3C-PyTorch with GNU General Public License v3.0 6 votes vote down vote up
def get_extension(cuda_support):
    # dir of this file
    setup_dir = os.path.dirname(os.path.realpath(__file__))
    # Where the cpp and cu files are
    prefix = os.path.join(setup_dir, MODULE_BASE_NAME)
    if not os.path.isdir(prefix):
        raise ValueError('Did not find backend foler: {}'.format(prefix))
    if cuda_support:
        nvcc_avaible, nvcc_version = supported_nvcc_available()
        if not nvcc_avaible:
            print(_bold_warn_str('***WARN') + ': Found untested nvcc {}'.format(nvcc_version))

        return CUDAExtension(
                MODULE_BASE_NAME + '_gpu',
                prefixed(prefix, ['torchac.cpp', 'torchac_kernel.cu']),
                define_macros=[('COMPILE_CUDA', '1')])
    else:
        return CppExtension(
                MODULE_BASE_NAME + '_cpu',
                prefixed(prefix, ['torchac.cpp']))


# TODO:
# Add further supported version as specified in readme