-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathrandom_ltd.py
40 lines (33 loc) · 1.08 KB
/
random_ltd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Copyright 2022 The Microsoft DeepSpeed Team
"""
from .builder import CUDAOpBuilder
class RandomLTDBuilder(CUDAOpBuilder):
BUILD_VAR = "DS_BUILD_RANDOM_LTD"
NAME = "random_ltd"
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.{self.NAME}_op'
def extra_ldflags(self):
if not self.is_rocm_pytorch():
return ['-lcurand']
else:
return []
def sources(self):
return [
'csrc/random_ltd/pt_binding.cpp',
'csrc/random_ltd/gather_scatter.cu',
'csrc/random_ltd/slice_attn_masks.cu',
'csrc/random_ltd/token_sort.cu'
]
def include_paths(self):
includes = ['csrc/includes']
if self.is_rocm_pytorch():
from torch.utils.cpp_extension import ROCM_HOME
includes += [
'{}/hiprand/include'.format(ROCM_HOME),
'{}/rocrand/include'.format(ROCM_HOME)
]
return includes