pytorch

Форк
0
/
BUCK.bzl 
308 строк · 8.1 Кб
1
# @lint-ignore-every FBCODEBZLADDLOADS
2
load("//tools/build_defs:glob_defs.bzl", "subdir_glob")
3

4
# shared by internal and OSS BUCK
5
def define_tools_targets(
6
        python_binary,
7
        python_library,
8
        python_test,
9
        third_party,
10
        torchgen_deps,
11
        contacts = []):
12
    python_library(
13
        name = "substitutelib",
14
        srcs = ["substitute.py"],
15
        base_module = "",
16
    )
17

18
    python_binary(
19
        name = "substitute",
20
        main_module = "substitute",
21
        visibility = ["PUBLIC"],
22
        deps = [
23
            ":substitutelib",
24
        ],
25
    )
26

27
    python_library(
28
        name = "jit",
29
        # @lint-ignore BUCKRESTRICTEDSYNTAX
30
        srcs = glob([
31
            "jit/*.py",
32
            "jit/templates/*",
33
        ]),
34
        base_module = "tools",
35
        visibility = ["PUBLIC"],
36
        deps = [
37
            torchgen_deps,
38
        ],
39
    )
40

41
    python_binary(
42
        name = "gen_unboxing_bin",
43
        main_module = "tools.jit.gen_unboxing",
44
        visibility = [
45
            "PUBLIC",
46
        ],
47
        deps = [
48
            ":jit",
49
        ],
50
    )
51

52
    python_library(
53
        name = "gen_selected_mobile_ops_header",
54
        srcs = ["lite_interpreter/gen_selected_mobile_ops_header.py"],
55
        base_module = "tools",
56
        visibility = ["PUBLIC"],
57
    )
58

59
    python_library(
60
        name = "gen_oplist_lib",
61
        srcs = subdir_glob([
62
            ("code_analyzer", "gen_oplist.py"),
63
            ("code_analyzer", "gen_op_registration_allowlist.py"),
64
        ]),
65
        base_module = "tools.code_analyzer",
66
        tests = [
67
            ":gen_oplist_test",
68
        ],
69
        visibility = ["PUBLIC"],
70
        deps = [
71
            ":gen_selected_mobile_ops_header",
72
            torchgen_deps,
73
            third_party("pyyaml"),
74
        ],
75
    )
76

77
    python_binary(
78
        name = "gen_oplist",
79
        main_module = "tools.code_analyzer.gen_oplist",
80
        visibility = ["PUBLIC"],
81
        deps = [
82
            ":gen_oplist_lib",
83
        ],
84
    )
85

86
    python_library(
87
        name = "gen_operators_yaml_lib",
88
        srcs = subdir_glob([
89
            ("code_analyzer", "gen_operators_yaml.py"),
90
            ("code_analyzer", "gen_op_registration_allowlist.py"),
91
        ]),
92
        base_module = "",
93
        tests = [
94
            ":gen_operators_yaml_test",
95
        ],
96
        deps = [
97
            third_party("pyyaml"),
98
            torchgen_deps,
99
        ],
100
    )
101

102
    python_binary(
103
        name = "gen_operators_yaml",
104
        main_module = "gen_operators_yaml",
105
        visibility = ["PUBLIC"],
106
        deps = [
107
            ":gen_operators_yaml_lib",
108
        ],
109
    )
110

111
    python_library(
112
        name = "autograd",
113
        # @lint-ignore BUCKRESTRICTEDSYNTAX
114
        srcs = glob(
115
            ["autograd/*.py"],
116
        ),
117
        base_module = "tools",
118
        resources = [
119
            "autograd/deprecated.yaml",
120
            "autograd/derivatives.yaml",
121
            "autograd/templates/ADInplaceOrViewType.cpp",
122
            "autograd/templates/Functions.cpp",
123
            "autograd/templates/Functions.h",
124
            "autograd/templates/TraceType.cpp",
125
            "autograd/templates/VariableType.cpp",
126
            "autograd/templates/VariableType.h",
127
            "autograd/templates/ViewFuncs.cpp",
128
            "autograd/templates/ViewFuncs.h",
129
            "autograd/templates/annotated_fn_args.py.in",
130
            "autograd/templates/python_enum_tag.cpp",
131
            "autograd/templates/python_fft_functions.cpp",
132
            "autograd/templates/python_functions.cpp",
133
            "autograd/templates/python_functions.h",
134
            "autograd/templates/python_linalg_functions.cpp",
135
            "autograd/templates/python_nested_functions.cpp",
136
            "autograd/templates/python_nn_functions.cpp",
137
            "autograd/templates/python_return_types.h",
138
            "autograd/templates/python_return_types.cpp",
139
            "autograd/templates/python_sparse_functions.cpp",
140
            "autograd/templates/python_special_functions.cpp",
141
            "autograd/templates/python_torch_functions.cpp",
142
            "autograd/templates/python_variable_methods.cpp",
143
            "autograd/templates/variable_factories.h",
144
        ],
145
        visibility = ["PUBLIC"],
146
        deps = [
147
            third_party("pyyaml"),
148
            torchgen_deps,
149
        ],
150
    )
151

152
    python_library(
153
        name = "generate_code",
154
        srcs = [
155
            "setup_helpers/generate_code.py",
156
        ],
157
        base_module = "tools",
158
        deps = [
159
            ":autograd",
160
            ":jit",
161
            torchgen_deps,
162
        ],
163
    )
164

165
    python_binary(
166
        name = "generate_code_bin",
167
        main_module = "tools.setup_helpers.generate_code",
168
        # Windows does not support inplace:
169
        # https://github.com/facebook/buck/issues/2161.
170
        #
171
        # Note that //arvr/mode/embedded/win/clang-aarch64-release sets
172
        # its target platform to
173
        # ovr_config//platform/embedded:clang-aarch64-linux-release, hence
174
        # that is why we are selecting that OS to trigger this behavior.
175
        package_style = select({
176
            "DEFAULT": "inplace",
177
            "ovr_config//os:linux-arm64": "standalone",
178
        }),
179
        visibility = ["PUBLIC"],
180
        # Because Windows does not support inplace packaging, we need to
181
        # ensure it is unzipped before executing it, otherwise it will not
182
        # be able to find any resources using path manipulation.
183
        #
184
        # See note above about why the OS is Linux here and not Windows.
185
        zip_safe = select({
186
            "DEFAULT": True,
187
            "ovr_config//os:linux-arm64": False,
188
        }),
189
        deps = [
190
            ":generate_code",
191
        ],
192
    )
193

194
    python_library(
195
        name = "gen-version-header-lib",
196
        srcs = [
197
            "setup_helpers/gen_version_header.py",
198
        ],
199
        base_module = "",
200
        deps = [],
201
    )
202

203
    python_binary(
204
        name = "gen-version-header",
205
        main_module = "setup_helpers.gen_version_header",
206
        visibility = ["PUBLIC"],
207
        deps = [
208
            ":gen-version-header-lib",
209
        ],
210
    )
211

212
    python_library(
213
        name = "gen_aten_vulkan_spv_lib",
214
        srcs = [
215
            "gen_vulkan_spv.py",
216
        ],
217
        base_module = "tools",
218
        deps = [
219
            torchgen_deps,
220
        ],
221
    )
222

223
    python_binary(
224
        name = "gen_aten_vulkan_spv_bin",
225
        main_module = "tools.gen_vulkan_spv",
226
        visibility = [
227
            "PUBLIC",
228
        ],
229
        deps = [
230
            ":gen_aten_vulkan_spv_lib",
231
        ],
232
    )
233

234
    python_test(
235
        name = "vulkan_codegen_test",
236
        srcs = [
237
            "test/test_vulkan_codegen.py",
238
        ],
239
        contacts = contacts,
240
        visibility = ["PUBLIC"],
241
        deps = [
242
            ":gen_aten_vulkan_spv_lib",
243
        ],
244
    )
245

246
    python_test(
247
        name = "selective_build_test",
248
        srcs = [
249
            "test/test_selective_build.py",
250
        ],
251
        contacts = contacts,
252
        visibility = ["PUBLIC"],
253
        deps = [
254
            torchgen_deps,
255
        ],
256
    )
257

258
    python_test(
259
        name = "gen_oplist_test",
260
        srcs = [
261
            "test/gen_oplist_test.py",
262
        ],
263
        contacts = contacts,
264
        visibility = ["PUBLIC"],
265
        deps = [
266
            ":gen_oplist_lib",
267
        ],
268
    )
269

270
    python_test(
271
        name = "gen_operators_yaml_test",
272
        srcs = [
273
            "test/gen_operators_yaml_test.py",
274
        ],
275
        visibility = ["PUBLIC"],
276
        contacts = contacts,
277
        deps = [
278
            ":gen_operators_yaml_lib",
279
        ],
280
    )
281

282
    python_test(
283
        name = "test_codegen",
284
        srcs = [
285
            "test/test_codegen.py",
286
        ],
287
        contacts = contacts,
288
        visibility = ["PUBLIC"],
289
        deps = [
290
            torchgen_deps,
291
            ":autograd",
292
        ],
293
    )
294

295
    python_test(
296
        name = "test_torchgen_executorch",
297
        srcs = [
298
            "test/test_executorch_gen.py",
299
            "test/test_executorch_signatures.py",
300
            "test/test_executorch_types.py",
301
            "test/test_executorch_unboxing.py",
302
        ],
303
        contacts = contacts,
304
        visibility = ["PUBLIC"],
305
        deps = [
306
            torchgen_deps,
307
        ],
308
    )
309

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.