Python torch.utils.cpp_extension.load() Examples
The following are 24
code examples of torch.utils.cpp_extension.load().
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: _utils.py From EmbedMask with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #2
Source File: _utils.py From TinyBenchmark with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #3
Source File: _utils.py From maskscoring_rcnn with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #4
Source File: sru_functional.py From sru with MIT License | 6 votes |
def _lazy_load_cpu_kernel(): global SRU_CPU_kernel if SRU_CPU_kernel is not None: return SRU_CPU_kernel try: from torch.utils.cpp_extension import load cpu_source = os.path.join(os.path.dirname(__file__), "sru_cpu_impl.cpp") SRU_CPU_kernel = load( name="sru_cpu_impl", sources=[cpu_source], extra_cflags=['-O3'], verbose=False ) except: # use Python version instead SRU_CPU_kernel = False return SRU_CPU_kernel # load C++ implementation for GPU computation
Example #5
Source File: deformable.py From neurvps with MIT License | 6 votes |
def load_cpp_ext(ext_name): root_dir = os.path.join(os.path.split(__file__)[0]) src_dir = os.path.join(root_dir, "cpp") tar_dir = os.path.join(src_dir, "build", ext_name) os.makedirs(tar_dir, exist_ok=True) srcs = glob(f"{src_dir}/*.cu") + glob(f"{src_dir}/*.cpp") with warnings.catch_warnings(): warnings.simplefilter("ignore") from torch.utils.cpp_extension import load ext = load( name=ext_name, sources=srcs, extra_cflags=["-O3"], extra_cuda_cflags=[], build_directory=tar_dir, ) return ext # defer calling load_cpp_ext to make CUDA_VISIBLE_DEVICES happy
Example #6
Source File: _utils.py From DF-Traffic-Sign-Identification with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #7
Source File: _utils.py From RRPN_pytorch with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #8
Source File: _utils.py From training with Apache License 2.0 | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #9
Source File: _utils.py From retinamask with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #10
Source File: _utils.py From DSGN with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #11
Source File: _utils.py From FreeAnchor with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #12
Source File: _utils.py From Res2Net-maskrcnn with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #13
Source File: _utils.py From maskrcnn-benchmark with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #14
Source File: _utils.py From HRNet-MaskRCNN-Benchmark with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #15
Source File: _utils.py From sampling-free with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #16
Source File: shape_layer.py From shapenet with GNU Affero General Public License v3.0 | 6 votes |
def __init__(self, shapes, verbose=True): """ Parameters ---------- shapes : np.ndarray eigen shapes (obtained by PCA) """ super().__init__() self.register_buffer("_shape_mean", torch.from_numpy(shapes[0]).float().unsqueeze(0)) components = [] for i, _shape in enumerate(shapes[1:]): components.append(torch.from_numpy(_shape).float().unsqueeze(0)) component_tensor = torch.cat(components).unsqueeze(0) self.register_buffer("_shape_components", component_tensor) self._func = load_cpp("shape_function", sources=[os.path.join(os.path.split(__file__)[0], "shape_layer.cpp")], verbose=verbose)
Example #17
Source File: _utils.py From training_results_v0.5 with Apache License 2.0 | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #18
Source File: _utils.py From remote_sensing_object_detection_2019 with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #19
Source File: _utils.py From DetNAS with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #20
Source File: _csrc.py From pytorch-syncbn with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) sources_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) sources_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) sources = main_file + sources_cpu extra_cflags = [] extra_cuda_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: sources.extend(sources_cuda) extra_cflags = ["-O3", "-DWITH_CUDA"] extra_cuda_cflags = ["--expt-extended-lambda"] sources = [os.path.join(this_dir, s) for s in sources] extra_include_paths = [this_dir] return load( name="ext_lib", sources=sources, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, extra_cuda_cflags=extra_cuda_cflags, )
Example #21
Source File: _utils.py From Clothing-Detection with GNU General Public License v3.0 | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #22
Source File: _utils.py From R2CNN.pytorch with MIT License | 6 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, )
Example #23
Source File: homogeneous_transform_layer.py From shapenet with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, n_dims, verbose=True): """ Parameters ---------- n_dims : int number of dimensions verbose : float if True: verbosity during C++ loading """ super().__init__() homogen_trafo = torch.zeros(1, n_dims + 1, n_dims + 1) homogen_trafo[:, -1, :-1] = 0. homogen_trafo[:, -1, -1] = 1. self.register_buffer("_trafo_matrix", homogen_trafo) self._n_dims = n_dims self._func = load_cpp("homogeneous_transform_function", sources=[ os.path.join( os.path.split(__file__)[0], "homogeneous_transform_layer.cpp")], verbose=verbose)
Example #24
Source File: _utils.py From NAS-FCOS with BSD 2-Clause "Simplified" License | 5 votes |
def _load_C_extensions(): this_dir = os.path.dirname(os.path.abspath(__file__)) this_dir = os.path.dirname(this_dir) this_dir = os.path.join(this_dir, "csrc") main_file = glob.glob(os.path.join(this_dir, "*.cpp")) source_cpu = glob.glob(os.path.join(this_dir, "cpu", "*.cpp")) source_cuda = glob.glob(os.path.join(this_dir, "cuda", "*.cu")) source = main_file + source_cpu extra_cflags = [] if torch.cuda.is_available() and CUDA_HOME is not None: source.extend(source_cuda) extra_cflags = ["-DWITH_CUDA"] source = [os.path.join(this_dir, s) for s in source] extra_include_paths = [this_dir] build_dir = os.path.dirname(os.path.abspath(__file__)) build_dir = os.path.dirname(build_dir) build_dir = os.path.dirname(build_dir) build_dir = os.path.join(build_dir, 'jit', 'torchvision') if not os.path.exists(build_dir): os.makedirs(build_dir) return load_ext( "torchvision", source, extra_cflags=extra_cflags, extra_include_paths=extra_include_paths, build_directory=build_dir, verbose=True, )