chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DeepSpeed Team
|
||||
|
||||
import os
|
||||
from .builder import CUDAOpBuilder, installed_cuda_version
|
||||
|
||||
|
||||
class SpatialInferenceBuilder(CUDAOpBuilder):
|
||||
BUILD_VAR = "DS_BUILD_SPATIAL_INFERENCE"
|
||||
NAME = "spatial_inference"
|
||||
|
||||
def __init__(self, name=None):
|
||||
name = self.NAME if name is None else name
|
||||
super().__init__(name=name)
|
||||
|
||||
def absolute_name(self):
|
||||
return f'deepspeed.ops.spatial.{self.NAME}_op'
|
||||
|
||||
def is_compatible(self, verbose=False):
|
||||
try:
|
||||
import torch
|
||||
except ImportError:
|
||||
if verbose:
|
||||
self.warning("Please install torch if trying to pre-compile inference kernels")
|
||||
return False
|
||||
|
||||
cuda_okay = True
|
||||
if not os.environ.get("DS_IGNORE_CUDA_DETECTION"):
|
||||
if not self.is_rocm_pytorch() and torch.cuda.is_available():
|
||||
sys_cuda_major, _ = installed_cuda_version()
|
||||
torch_cuda_major = int(torch.version.cuda.split('.')[0])
|
||||
cuda_capability = self.cuda_capability_major()
|
||||
if cuda_capability is not None and cuda_capability >= 8:
|
||||
if torch_cuda_major < 11 or sys_cuda_major < 11:
|
||||
if verbose:
|
||||
self.warning("On Ampere and higher architectures please use CUDA 11+")
|
||||
cuda_okay = False
|
||||
return super().is_compatible(verbose) and cuda_okay
|
||||
|
||||
def sources(self):
|
||||
return [
|
||||
'csrc/spatial/csrc/opt_bias_add.cu',
|
||||
'csrc/spatial/csrc/pt_binding.cpp',
|
||||
]
|
||||
|
||||
def include_paths(self):
|
||||
return ['csrc/spatial/includes', 'csrc/includes']
|
||||
Reference in New Issue
Block a user