forked from ROCm/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defs_hip.bzl
126 lines (102 loc) · 3.63 KB
/
defs_hip.bzl
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
load("@bazel_skylib//lib:paths.bzl", "paths")
load("//caffe2:defs_hip.bzl", "get_hip_file_path")
gpu_file_extensions = [".cu", ".c", ".cc", ".cpp"]
gpu_header_extensions = [".cuh", ".h", ".hpp"]
def is_test_files(filepath):
if filepath.startswith("test"):
return True
else:
return False
def get_c10_hip_srcs():
gpu_file_pattern = [
base + suffix
for base in c10_includes
for suffix in gpu_file_extensions
]
native_gpu_files = native.glob(gpu_file_pattern)
gpu_files = []
hip_files = []
for name in native_gpu_files:
# exclude the test folder
if is_test_files(name):
continue
gpu_files.append(name)
hip_file_name = get_hip_file_path(paths.join("cuda/", name))
hip_files.append(hip_file_name)
# there will be some native hip files that needs suffix changed
native_hip_pattern = [
"hip/**/*.hip",
]
native_hip_files = native.glob(native_hip_pattern)
gpu_files += native_hip_files
hip_files += native_hip_files
# we run hipify script under the caffe2 folder; therefore we need to
# prepend c10 to the path so that buck can find the hipified file
real_hip_files = []
for filename in hip_files:
real_hip_files.append(paths.join("c10", filename))
# return the src and output_gen files
return gpu_files, real_hip_files
def get_c10_hip_headers():
gpu_file_pattern = [
base + suffix
for base in c10_includes
for suffix in gpu_header_extensions
]
native_gpu_files = native.glob(gpu_file_pattern)
# store the original
gpu_files = []
hip_files = []
for name in native_gpu_files:
if is_test_files(name):
continue
gpu_files.append(name)
hip_file_name = get_hip_file_path(paths.join("cuda/", name))
hip_files.append(hip_file_name)
# there will be some native hip files that needs suffix changed
native_hip_pattern = [
"hip/**/*" + suffix
for suffix in gpu_header_extensions
]
native_hip_files = native.glob(native_hip_pattern)
gpu_files += native_hip_files
hip_files += native_hip_files
# we run hipify script under the caffe2 folder; therefore we need to
# prepend c10 to the path so that buck can find the hipified file
real_hip_files = []
for filename in hip_files:
real_hip_files.append(paths.join("c10", filename))
# return the src and output_gen files
return gpu_files, real_hip_files
def get_c10_hip_test_files():
gpu_file_pattern = [
base + suffix
for base in c10_includes
for suffix in gpu_file_extensions
]
native_gpu_files = native.glob(gpu_file_pattern)
# store the original
gpu_files = []
hip_files = []
for name in native_gpu_files:
if not is_test_files(name):
continue
gpu_files.append(name)
hip_file_name = get_hip_file_path(paths.join("cuda/", name))
hip_files.append(hip_file_name)
# there will be some native hip files that needs suffix changed
native_hip_pattern = [
"hip/test/**/*" + suffix
for suffix in gpu_header_extensions
]
native_hip_files = native.glob(native_hip_pattern)
gpu_files += native_hip_files
hip_files += native_hip_files
# we run hipify script under the caffe2 folder; therefore we need to
# prepend c10 to the path so that buck can find the hipified file
real_hip_files = []
for filename in hip_files:
real_hip_files.append(paths.join("c10", filename))
# return the src and output_gen files
return gpu_files, real_hip_files
c10_includes = ["**/*"]