pytorch
/
build_variables.bzl
1514 строк · 69.3 Кб
1# WARNING: the contents of this file must BOTH be valid Starlark (for Buck and
2
3# Bazel) as well as valid Python (for our cmake build). This means that
4# load() directives are not allowed (as they are not recognized by Python).
5# If you want to fix this, figure out how run this file from cmake with a proper
6# Starlark interpreter as part of the default OSS build process. If you need
7# some nontrivial Starlark features, make a separate bzl file (remember that
8
9# bzl files are not exported via ShipIt by default, so you may also need to
10# update PyTorch's ShipIt config)
11
12# This is duplicated in caffe2/CMakeLists.txt for now and not yet used in buck
13GENERATED_LAZY_TS_CPP = [
14"lazy/generated/LazyNativeFunctions.cpp",
15"lazy/generated/RegisterAutogradLazy.cpp",
16"lazy/generated/RegisterLazy.cpp",
17]
18
19def libtorch_generated_sources(gencode_pattern):
20return [gencode_pattern.format(name) for name in [
21"torch/csrc/autograd/generated/Functions.cpp",
22"torch/csrc/autograd/generated/VariableType_0.cpp",
23"torch/csrc/autograd/generated/VariableType_1.cpp",
24"torch/csrc/autograd/generated/VariableType_2.cpp",
25"torch/csrc/autograd/generated/VariableType_3.cpp",
26"torch/csrc/autograd/generated/VariableType_4.cpp",
27"torch/csrc/autograd/generated/ViewFuncs.cpp",
28"torch/csrc/autograd/generated/TraceType_0.cpp",
29"torch/csrc/autograd/generated/TraceType_1.cpp",
30"torch/csrc/autograd/generated/TraceType_2.cpp",
31"torch/csrc/autograd/generated/TraceType_3.cpp",
32"torch/csrc/autograd/generated/TraceType_4.cpp",
33"torch/csrc/autograd/generated/ADInplaceOrViewType_0.cpp",
34"torch/csrc/autograd/generated/ADInplaceOrViewType_1.cpp",
35]]
36
37# copied from https://github.com/pytorch/pytorch/blob/f99a693cd9ff7a9b5fdc71357dac66b8192786d3/aten/src/ATen/core/CMakeLists.txt
38jit_core_headers = [
39"torch/csrc/Export.h",
40"torch/csrc/jit/frontend/source_range.h",
41"torch/csrc/jit/serialization/callstack_debug_info_serialization.h",
42"torch/csrc/jit/serialization/source_range_serialization.h",
43"torch/csrc/jit/frontend/lexer.h",
44"torch/csrc/jit/frontend/strtod.h",
45"torch/csrc/jit/frontend/parser_constants.h",
46"torch/csrc/jit/frontend/function_schema_parser.h",
47"torch/csrc/jit/frontend/parse_string_literal.h",
48"torch/csrc/jit/frontend/schema_type_parser.h",
49"torch/csrc/jit/frontend/error_report.h",
50"torch/csrc/jit/frontend/tree.h",
51"torch/custom_class.h",
52"torch/custom_class_detail.h",
53"torch/library.h",
54]
55
56jit_core_sources = [
57"torch/csrc/jit/frontend/error_report.cpp",
58"torch/csrc/jit/frontend/function_schema_parser.cpp",
59"torch/csrc/jit/frontend/lexer.cpp",
60"torch/csrc/jit/frontend/schema_type_parser.cpp",
61"torch/csrc/jit/frontend/strtod.cpp",
62"torch/csrc/jit/frontend/source_range.cpp",
63]
64
65# copied from https://github.com/pytorch/pytorch/blob/0bde610c14b92d351b968a0228df29e92442b1cc/torch/CMakeLists.txt
66# There are some common files used in both internal lite-interpreter and full-jit. Making a separate
67# list for the shared files.
68
69core_sources_common = [
70"torch/csrc/autograd/autograd_meta.cpp",
71"torch/csrc/autograd/forward_grad.cpp",
72"torch/csrc/jit/frontend/edit_distance.cpp",
73"torch/csrc/jit/mobile/compatibility/runtime_compatibility.cpp",
74"torch/csrc/jit/mobile/type_parser.cpp",
75"torch/csrc/jit/operator_upgraders/version_map.cpp",
76"torch/csrc/jit/runtime/instruction.cpp",
77"torch/csrc/jit/runtime/jit_exception.cpp",
78"torch/csrc/jit/runtime/operator.cpp",
79"torch/csrc/jit/mobile/register_ops_common_utils.cpp",
80"torch/csrc/jit/runtime/print_handler.cpp",
81"torch/csrc/jit/runtime/slice_indices_adjust.cpp",
82"torch/csrc/jit/runtime/register_ops_utils.cpp",
83"torch/csrc/jit/runtime/vararg_functions.cpp",
84"torch/csrc/jit/mobile/promoted_prim_ops.cpp",
85"torch/csrc/jit/mobile/prim_ops_registery.cpp",
86"torch/csrc/profiler/util.cpp",
87]
88
89torch_unpickler_common = [
90"torch/csrc/jit/serialization/import_read.cpp",
91"torch/csrc/jit/serialization/unpickler.cpp",
92]
93
94libtorch_sources_common = sorted(core_sources_common + torch_unpickler_common)
95
96# The profilers are not needed in the lite interpreter build.
97libtorch_profiler_sources = [
98"torch/csrc/autograd/profiler_legacy.cpp",
99"torch/csrc/autograd/profiler_kineto.cpp",
100"torch/csrc/profiler/collection.cpp",
101"torch/csrc/profiler/data_flow.cpp",
102"torch/csrc/profiler/kineto_shim.cpp",
103"torch/csrc/profiler/kineto_client_interface.cpp",
104"torch/csrc/profiler/orchestration/observer.cpp",
105"torch/csrc/profiler/orchestration/python_tracer.cpp",
106"torch/csrc/profiler/standalone/execution_trace_observer.cpp",
107"torch/csrc/profiler/standalone/itt_observer.cpp",
108"torch/csrc/profiler/standalone/nvtx_observer.cpp",
109"torch/csrc/profiler/standalone/privateuse1_observer.cpp",
110"torch/csrc/profiler/stubs/base.cpp",
111"torch/csrc/profiler/orchestration/vulkan.cpp",
112"torch/csrc/profiler/perf.cpp",
113"torch/csrc/monitor/counters.cpp",
114"torch/csrc/monitor/events.cpp",
115]
116
117libtorch_edge_profiler_sources = libtorch_profiler_sources + [
118"torch/csrc/jit/mobile/profiler_edge.cpp",
119]
120
121core_trainer_sources = [
122"torch/csrc/autograd/anomaly_mode.cpp",
123"torch/csrc/autograd/autograd.cpp",
124"torch/csrc/autograd/autograd_not_implemented_fallback.cpp",
125"torch/csrc/autograd/cpp_hook.cpp",
126"torch/csrc/autograd/custom_function.cpp",
127"torch/csrc/autograd/variable_info.cpp",
128"torch/csrc/autograd/engine.cpp",
129"torch/csrc/autograd/function.cpp",
130"torch/csrc/autograd/input_metadata.cpp",
131"torch/csrc/autograd/functions/accumulate_grad.cpp",
132"torch/csrc/autograd/functions/basic_ops.cpp",
133"torch/csrc/autograd/functions/tensor.cpp",
134"torch/csrc/autograd/functions/utils.cpp",
135"torch/csrc/autograd/input_buffer.cpp",
136"torch/csrc/autograd/record_function_ops.cpp",
137"torch/csrc/autograd/saved_variable.cpp",
138"torch/csrc/autograd/variable.cpp",
139"torch/csrc/autograd/utils/warnings.cpp",
140"torch/csrc/autograd/jit_decomp_interface.cpp",
141"torch/csrc/jit/frontend/name_mangler.cpp",
142"torch/csrc/jit/ir/type_hashing.cpp",
143"torch/csrc/jit/serialization/pickler.cpp",
144"torch/csrc/jit/serialization/type_name_uniquer.cpp",
145]
146
147torch_mobile_core = [
148# backend_debug_info.cpp provides
149# __torch__.torch.classes.backend.BackendDebugInfo class
150# This should not be needed eventually.
151# TODO: Remove this dependency
152"torch/csrc/jit/backends/backend_debug_info.cpp",
153"torch/csrc/jit/mobile/compatibility/model_compatibility.cpp",
154"torch/csrc/jit/mobile/function.cpp",
155"torch/csrc/jit/mobile/import.cpp",
156"torch/csrc/jit/mobile/flatbuffer_loader.cpp",
157"torch/csrc/jit/mobile/interpreter.cpp",
158"torch/csrc/jit/mobile/module.cpp",
159"torch/csrc/jit/mobile/observer.cpp",
160"torch/csrc/jit/mobile/parse_bytecode.cpp",
161"torch/csrc/jit/mobile/parse_operators.cpp",
162"torch/csrc/jit/mobile/quantization.cpp",
163"torch/csrc/jit/mobile/upgrader_mobile.cpp",
164"torch/csrc/jit/runtime/register_prim_ops.cpp",
165"torch/csrc/jit/runtime/register_special_ops.cpp",
166]
167
168core_sources_full_mobile_no_backend_interface_xplat = [
169"torch/csrc/jit/api/function_impl.cpp",
170"torch/csrc/jit/api/module.cpp",
171"torch/csrc/jit/api/object.cpp",
172"torch/csrc/jit/backends/backend_debug_handler.cpp",
173"torch/csrc/jit/backends/backend_detail.cpp",
174"torch/csrc/jit/backends/backend_resolver.cpp",
175"torch/csrc/jit/codegen/fuser/codegen.cpp",
176"torch/csrc/jit/codegen/fuser/compiler.cpp",
177"torch/csrc/jit/codegen/fuser/executor.cpp",
178"torch/csrc/jit/codegen/fuser/fallback.cpp",
179"torch/csrc/jit/codegen/fuser/interface.cpp",
180"torch/csrc/jit/codegen/fuser/kernel_cache.cpp",
181"torch/csrc/jit/frontend/builtin_functions.cpp",
182"torch/csrc/jit/frontend/versioned_symbols.cpp",
183"torch/csrc/jit/frontend/canonicalize_modified_loop.cpp",
184"torch/csrc/jit/frontend/convert_to_ssa.cpp",
185"torch/csrc/jit/frontend/exit_transforms.cpp",
186"torch/csrc/jit/frontend/inline_loop_condition.cpp",
187"torch/csrc/jit/frontend/ir_emitter.cpp",
188"torch/csrc/jit/frontend/parser.cpp",
189"torch/csrc/jit/frontend/schema_matching.cpp",
190"torch/csrc/jit/frontend/script_type_parser.cpp",
191"torch/csrc/jit/frontend/sugared_value.cpp",
192"torch/csrc/jit/frontend/tracer.cpp",
193"torch/csrc/jit/ir/alias_analysis.cpp",
194"torch/csrc/jit/ir/attributes.cpp",
195"torch/csrc/jit/ir/constants.cpp",
196"torch/csrc/jit/ir/ir.cpp",
197"torch/csrc/jit/ir/irparser.cpp",
198"torch/csrc/jit/ir/node_hashing.cpp",
199"torch/csrc/jit/ir/scope.cpp",
200"torch/csrc/jit/ir/subgraph_matcher.cpp",
201"torch/csrc/jit/ir/graph_utils.cpp",
202"torch/csrc/jit/jit_log.cpp",
203"torch/csrc/jit/jit_opt_limit.cpp",
204"torch/csrc/jit/mobile/nnc/aot_compiler.cpp",
205"torch/csrc/jit/mobile/nnc/backend.cpp",
206"torch/csrc/jit/mobile/nnc/context.cpp",
207"torch/csrc/jit/mobile/nnc/registry.cpp",
208"torch/csrc/jit/operator_upgraders/utils.cpp",
209"torch/csrc/jit/operator_upgraders/upgraders.cpp",
210"torch/csrc/jit/operator_upgraders/upgraders_entry.cpp",
211"torch/csrc/jit/passes/add_if_then_else.cpp",
212"torch/csrc/jit/passes/annotate_warns.cpp",
213"torch/csrc/jit/passes/bailout_graph.cpp",
214"torch/csrc/jit/passes/check_strict_fusion.cpp",
215"torch/csrc/jit/passes/batch_mm.cpp",
216"torch/csrc/jit/passes/canonicalize.cpp",
217"torch/csrc/jit/passes/canonicalize_graph_fuser_ops.cpp",
218"torch/csrc/jit/passes/clear_profiling.cpp",
219"torch/csrc/jit/passes/clear_undefinedness.cpp",
220"torch/csrc/jit/passes/common_subexpression_elimination.cpp",
221"torch/csrc/jit/passes/concat_opt.cpp",
222"torch/csrc/jit/passes/constant_pooling.cpp",
223"torch/csrc/jit/passes/constant_propagation.cpp",
224"torch/csrc/jit/passes/restore_mutation.cpp",
225"torch/csrc/jit/passes/create_autodiff_subgraphs.cpp",
226"torch/csrc/jit/passes/dead_code_elimination.cpp",
227"torch/csrc/jit/passes/eliminate_no_ops.cpp",
228"torch/csrc/jit/passes/remove_redundant_profiles.cpp",
229"torch/csrc/jit/passes/remove_exceptions.cpp",
230"torch/csrc/jit/passes/decompose_ops.cpp",
231"torch/csrc/jit/passes/dtype_analysis.cpp",
232"torch/csrc/jit/passes/device_type_analysis.cpp",
233"torch/csrc/jit/passes/erase_number_types.cpp",
234"torch/csrc/jit/passes/fixup_trace_scope_blocks.cpp",
235"torch/csrc/jit/passes/freeze_module.cpp",
236"torch/csrc/jit/passes/fuse_linear.cpp",
237"torch/csrc/jit/passes/fuse_relu.cpp",
238"torch/csrc/jit/passes/graph_fuser.cpp",
239"torch/csrc/jit/passes/graph_rewrite_helper.cpp",
240"torch/csrc/jit/passes/guard_elimination.cpp",
241"torch/csrc/jit/passes/hoist_conv_packed_params.cpp",
242"torch/csrc/jit/passes/inline_autodiff_subgraphs.cpp",
243"torch/csrc/jit/passes/inline_forked_closures.cpp",
244"torch/csrc/jit/passes/inline_fork_wait.cpp",
245"torch/csrc/jit/passes/inliner.cpp",
246"torch/csrc/jit/passes/inplace_check.cpp",
247"torch/csrc/jit/passes/insert_guards.cpp",
248"torch/csrc/jit/passes/lift_closures.cpp",
249"torch/csrc/jit/passes/liveness.cpp",
250"torch/csrc/jit/passes/loop_unrolling.cpp",
251"torch/csrc/jit/passes/lower_grad_of.cpp",
252"torch/csrc/jit/passes/lower_tuples.cpp",
253"torch/csrc/jit/passes/normalize_ops.cpp",
254"torch/csrc/jit/passes/peephole_dict_idioms.cpp",
255"torch/csrc/jit/passes/peephole_list_idioms.cpp",
256"torch/csrc/jit/passes/value_refinement_utils.cpp",
257"torch/csrc/jit/passes/peephole_alias_sensitive.cpp",
258"torch/csrc/jit/passes/pass_manager.cpp",
259"torch/csrc/jit/passes/peephole.cpp",
260"torch/csrc/jit/passes/peephole_non_tensor.cpp",
261"torch/csrc/jit/passes/create_functional_graphs.cpp",
262"torch/csrc/jit/passes/refine_tuple_types.cpp",
263"torch/csrc/jit/passes/remove_mutation.cpp",
264"torch/csrc/jit/passes/prepack_folding.cpp",
265"torch/csrc/jit/passes/fold_conv_bn.cpp",
266"torch/csrc/jit/passes/fold_linear_bn.cpp",
267"torch/csrc/jit/passes/dbr_quantization/remove_redundant_aliases.cpp",
268"torch/csrc/jit/passes/frozen_concat_linear.cpp",
269"torch/csrc/jit/passes/frozen_conv_add_relu_fusion.cpp",
270"torch/csrc/jit/passes/frozen_conv_folding.cpp",
271"torch/csrc/jit/passes/frozen_linear_folding.cpp",
272"torch/csrc/jit/passes/frozen_linear_transpose.cpp",
273"torch/csrc/jit/passes/frozen_ops_to_mkldnn.cpp",
274"torch/csrc/jit/passes/frozen_graph_optimizations.cpp",
275"torch/csrc/jit/passes/remove_expands.cpp",
276"torch/csrc/jit/passes/remove_dropout.cpp",
277"torch/csrc/jit/passes/requires_grad_analysis.cpp",
278"torch/csrc/jit/passes/shape_analysis.cpp",
279"torch/csrc/jit/passes/integer_value_refinement.cpp",
280"torch/csrc/jit/passes/replacement_of_old_operators.cpp",
281"torch/csrc/jit/passes/symbolic_shape_analysis.cpp",
282"torch/csrc/jit/passes/symbolic_shape_cache.cpp",
283"torch/csrc/jit/passes/symbolic_shape_runtime_fusion.cpp",
284"torch/csrc/jit/passes/specialize_autogradzero.cpp",
285"torch/csrc/jit/passes/update_differentiable_graph_requires_grad.cpp",
286"torch/csrc/jit/passes/variadic_ops.cpp",
287"torch/csrc/jit/passes/subgraph_rewrite.cpp",
288"torch/csrc/jit/passes/tensorexpr_fuser.cpp",
289"torch/csrc/jit/passes/utils/memory_dag.cpp",
290"torch/csrc/jit/passes/utils/subgraph_utils.cpp",
291"torch/csrc/jit/passes/utils/optimization_utils.cpp",
292"torch/csrc/jit/passes/utils/op_registry.cpp",
293"torch/csrc/jit/passes/mkldnn_rewrite.cpp",
294"torch/csrc/jit/passes/xnnpack_rewrite.cpp",
295"torch/csrc/jit/passes/vulkan_rewrite.cpp",
296"torch/csrc/jit/passes/metal_rewrite.cpp",
297"torch/csrc/jit/passes/quantization/helper.cpp",
298"torch/csrc/jit/passes/quantization/quantization_type.cpp",
299"torch/csrc/jit/passes/quantization/insert_observers.cpp",
300"torch/csrc/jit/passes/quantization/insert_quant_dequant.cpp",
301"torch/csrc/jit/passes/quantization/dedup_module_uses.cpp",
302"torch/csrc/jit/passes/quantization/finalize.cpp",
303"torch/csrc/jit/passes/quantization/fusion_passes.cpp",
304"torch/csrc/jit/passes/quantization/register_packed_params.cpp",
305"torch/csrc/jit/python/update_graph_executor_opt.cpp",
306"torch/csrc/jit/python/utf8_decoding_ignore.cpp",
307"torch/csrc/jit/runtime/argument_spec.cpp",
308"torch/csrc/jit/runtime/autodiff.cpp",
309"torch/csrc/jit/runtime/graph_executor.cpp",
310"torch/csrc/jit/runtime/interpreter/frame.cpp",
311"torch/csrc/jit/runtime/interpreter/preprocess_graph.cpp",
312"torch/csrc/jit/runtime/interpreter.cpp",
313"torch/csrc/jit/runtime/logging.cpp",
314"torch/csrc/jit/runtime/simple_graph_executor_impl.cpp",
315"torch/csrc/jit/runtime/profiling_graph_executor_impl.cpp",
316"torch/csrc/jit/runtime/profiling_record.cpp",
317"torch/csrc/jit/runtime/script_profile.cpp",
318"torch/csrc/jit/runtime/symbolic_script.cpp",
319"torch/csrc/jit/runtime/symbolic_shape_registry.cpp",
320"torch/csrc/jit/runtime/decomposition_registry.cpp",
321"torch/csrc/jit/runtime/decomposition_registry_util.cpp",
322"torch/csrc/jit/runtime/serialized_shape_function_registry.cpp",
323"torch/csrc/jit/runtime/symbolic_shape_registry_util.cpp",
324"torch/csrc/jit/runtime/jit_trace.cpp",
325"torch/csrc/jit/serialization/callstack_debug_info_serialization.cpp",
326"torch/csrc/jit/serialization/import.cpp",
327"torch/csrc/jit/serialization/import_export_helpers.cpp",
328"torch/csrc/jit/serialization/import_source.cpp",
329"torch/csrc/jit/serialization/pickle.cpp",
330"torch/csrc/jit/serialization/python_print.cpp",
331"torch/csrc/jit/serialization/source_range_serialization.cpp",
332"torch/csrc/jit/tensorexpr/block_codegen.cpp",
333"torch/csrc/jit/tensorexpr/bounds_inference.cpp",
334"torch/csrc/jit/tensorexpr/bounds_overlap.cpp",
335"torch/csrc/jit/tensorexpr/codegen.cpp",
336"torch/csrc/jit/tensorexpr/cpp_codegen.cpp",
337"torch/csrc/jit/tensorexpr/eval.cpp",
338"torch/csrc/jit/tensorexpr/expr.cpp",
339"torch/csrc/jit/tensorexpr/external_functions_core.cpp",
340"torch/csrc/jit/tensorexpr/external_functions_registry.cpp",
341"torch/csrc/jit/tensorexpr/graph_opt.cpp",
342"torch/csrc/jit/tensorexpr/hash_provider.cpp",
343"torch/csrc/jit/tensorexpr/intrinsic_symbols.cpp",
344"torch/csrc/jit/tensorexpr/ir.cpp",
345"torch/csrc/jit/tensorexpr/ir_cloner.cpp",
346"torch/csrc/jit/tensorexpr/ir_mutator.cpp",
347"torch/csrc/jit/tensorexpr/ir_printer.cpp",
348"torch/csrc/jit/tensorexpr/ir_simplifier.cpp",
349"torch/csrc/jit/tensorexpr/ir_verifier.cpp",
350"torch/csrc/jit/tensorexpr/ir_visitor.cpp",
351"torch/csrc/jit/tensorexpr/kernel.cpp",
352"torch/csrc/jit/tensorexpr/llvm_codegen.cpp",
353"torch/csrc/jit/tensorexpr/llvm_jit.cpp",
354"torch/csrc/jit/tensorexpr/loopnest.cpp",
355"torch/csrc/jit/tensorexpr/loopnest_randomization.cpp",
356"torch/csrc/jit/tensorexpr/lowerings.cpp",
357"torch/csrc/jit/tensorexpr/mem_dependency_checker.cpp",
358"torch/csrc/jit/tensorexpr/operators/conv2d.cpp",
359"torch/csrc/jit/tensorexpr/operators/matmul.cpp",
360"torch/csrc/jit/tensorexpr/operators/misc.cpp",
361"torch/csrc/jit/tensorexpr/operators/norm.cpp",
362"torch/csrc/jit/tensorexpr/operators/pointwise.cpp",
363"torch/csrc/jit/tensorexpr/operators/quantization.cpp",
364"torch/csrc/jit/tensorexpr/operators/reduction.cpp",
365"torch/csrc/jit/tensorexpr/operators/softmax.cpp",
366"torch/csrc/jit/tensorexpr/reduction.cpp",
367"torch/csrc/jit/tensorexpr/registerizer.cpp",
368"torch/csrc/jit/tensorexpr/tensor.cpp",
369"torch/csrc/jit/tensorexpr/types.cpp",
370"torch/csrc/jit/tensorexpr/unique_name_manager.cpp",
371"torch/csrc/jit/testing/file_check.cpp",
372"torch/csrc/profiler/unwind/unwind.cpp",
373"torch/csrc/profiler/unwind/unwind_fb.cpp",
374"torch/csrc/profiler/combined_traceback.cpp",
375"torch/csrc/jit/testing/hooks_for_testing.cpp",
376"torch/csrc/utils/cpp_stacktraces.cpp",
377"torch/csrc/utils/schema_info.cpp",
378"torch/csrc/utils/tensor_flatten.cpp",
379"torch/csrc/utils/variadic.cpp",
380]
381
382core_sources_full_mobile_no_backend_interface = core_sources_full_mobile_no_backend_interface_xplat + [
383# backend_debug_info.cpp provides
384# __torch__.torch.classes.backend.BackendDebugInfo class
385# This should not be needed eventually.
386# TODO: Remove this dependency
387"torch/csrc/jit/backends/backend_debug_info.cpp",
388"torch/csrc/jit/mobile/compatibility/model_compatibility.cpp",
389"torch/csrc/jit/mobile/function.cpp",
390"torch/csrc/jit/mobile/import.cpp",
391"torch/csrc/jit/mobile/flatbuffer_loader.cpp",
392"torch/csrc/jit/mobile/interpreter.cpp",
393"torch/csrc/jit/mobile/module.cpp",
394"torch/csrc/jit/mobile/observer.cpp",
395"torch/csrc/jit/mobile/parse_bytecode.cpp",
396"torch/csrc/jit/mobile/parse_operators.cpp",
397"torch/csrc/jit/mobile/quantization.cpp",
398"torch/csrc/jit/mobile/upgrader_mobile.cpp",
399]
400
401core_sources_full_mobile = core_sources_full_mobile_no_backend_interface + [
402"torch/csrc/jit/backends/backend_debug_info.cpp",
403"torch/csrc/jit/backends/backend_interface.cpp",
404]
405
406core_sources_full = core_sources_full_mobile + [
407"torch/csrc/jit/runtime/static/fusion.cpp",
408"torch/csrc/jit/runtime/static/generated_ops.cpp",
409"torch/csrc/jit/runtime/static/impl.cpp",
410"torch/csrc/jit/runtime/static/memory_planner.cpp",
411"torch/csrc/jit/runtime/static/native_ops.cpp",
412"torch/csrc/jit/runtime/static/ops.cpp",
413"torch/csrc/jit/runtime/static/passes.cpp",
414"torch/csrc/jit/runtime/static/te_wrapper.cpp",
415"torch/csrc/jit/tensorexpr/external_functions.cpp",
416"torch/csrc/jit/tensorexpr/external_functions_codegen.cpp",
417]
418
419lazy_tensor_core_sources = [
420"torch/csrc/lazy/backend/backend_device.cpp",
421"torch/csrc/lazy/backend/backend_interface.cpp",
422"torch/csrc/lazy/backend/lowering_context.cpp",
423"torch/csrc/lazy/core/config.cpp",
424"torch/csrc/lazy/core/debug_util.cpp",
425"torch/csrc/lazy/core/hash.cpp",
426"torch/csrc/lazy/core/helpers.cpp",
427"torch/csrc/lazy/core/ir.cpp",
428"torch/csrc/lazy/core/ir_dump_util.cpp",
429"torch/csrc/lazy/core/ir_metadata.cpp",
430"torch/csrc/lazy/core/ir_util.cpp",
431"torch/csrc/lazy/core/lazy_graph_executor.cpp",
432"torch/csrc/lazy/core/metrics.cpp",
433"torch/csrc/lazy/core/multi_wait.cpp",
434"torch/csrc/lazy/core/ops/arithmetic_ir_ops.cpp",
435"torch/csrc/lazy/core/ops/utils.cpp",
436"torch/csrc/lazy/core/permutation_util.cpp",
437"torch/csrc/lazy/core/shape.cpp",
438"torch/csrc/lazy/core/shape_inference.cpp",
439"torch/csrc/lazy/core/tensor.cpp",
440"torch/csrc/lazy/core/tensor_impl.cpp",
441"torch/csrc/lazy/core/tensor_util.cpp",
442"torch/csrc/lazy/core/thread_pool.cpp",
443"torch/csrc/lazy/core/trie.cpp",
444]
445
446# We can't build all of the ts backend under certain build configurations, e.g. mobile,
447# since it depends on things like autograd, meta functions, which may be disabled
448lazy_tensor_ts_sources = [
449"torch/csrc/lazy/ts_backend/dynamic_ir.cpp",
450"torch/csrc/lazy/ts_backend/config.cpp",
451"torch/csrc/lazy/ts_backend/ops/device_data.cpp",
452"torch/csrc/lazy/ts_backend/ops/generic.cpp",
453"torch/csrc/lazy/ts_backend/tensor_aten_ops.cpp",
454"torch/csrc/lazy/ts_backend/ts_autograd_functions.cpp",
455"torch/csrc/lazy/ts_backend/ts_backend_impl.cpp",
456"torch/csrc/lazy/ts_backend/ts_eager_fallback.cpp",
457"torch/csrc/lazy/ts_backend/ts_lowering_context.cpp",
458"torch/csrc/lazy/ts_backend/ts_native_functions.cpp",
459"torch/csrc/lazy/ts_backend/ts_node.cpp",
460"torch/csrc/lazy/ts_backend/ts_node_lowering.cpp",
461]
462
463lazy_tensor_core_python_sources = [
464"torch/csrc/lazy/python/init.cpp",
465"torch/csrc/lazy/python/python_util.cpp",
466]
467
468inductor_core_resources = [
469"torch/csrc/inductor/aoti_runner/model_container_runner.cpp",
470"torch/csrc/inductor/aoti_runner/model_container_runner_cpu.cpp",
471"torch/csrc/inductor/aoti_torch/shim_common.cpp",
472"torch/csrc/inductor/aoti_torch/tensor_converter.cpp",
473"torch/csrc/inductor/aoti_torch/mkldnn_tensor.cpp",
474"torch/csrc/inductor/aoti_torch/oss_proxy_executor.cpp",
475"torch/csrc/inductor/inductor_ops.cpp",
476"torch/csrc/jit/serialization/pickle.cpp",
477]
478
479libtorch_core_sources = sorted(
480core_sources_common +
481torch_unpickler_common +
482core_sources_full +
483core_trainer_sources +
484inductor_core_resources +
485libtorch_profiler_sources +
486lazy_tensor_core_sources,
487)
488
489# These files are the only ones that are supported on Windows.
490libtorch_distributed_base_sources = [
491"torch/csrc/distributed/c10d/Backend.cpp",
492"torch/csrc/distributed/c10d/Backoff.cpp",
493"torch/csrc/distributed/c10d/DMAConnectivity.cpp",
494"torch/csrc/distributed/c10d/control_collectives/StoreCollectives.cpp",
495"torch/csrc/distributed/c10d/FileStore.cpp",
496"torch/csrc/distributed/c10d/Functional.cpp",
497"torch/csrc/distributed/c10d/GlooDeviceFactory.cpp",
498"torch/csrc/distributed/c10d/GroupRegistry.cpp",
499"torch/csrc/distributed/c10d/LockGuard.cpp",
500"torch/csrc/distributed/c10d/Ops.cpp",
501"torch/csrc/distributed/c10d/ParamCommsUtils.cpp",
502"torch/csrc/distributed/c10d/PrefixStore.cpp",
503"torch/csrc/distributed/c10d/ProcessGroup.cpp",
504"torch/csrc/distributed/c10d/ProcessGroupGloo.cpp",
505"torch/csrc/distributed/c10d/ProcessGroupMPI.cpp",
506"torch/csrc/distributed/c10d/ProcessGroupWrapper.cpp",
507"torch/csrc/distributed/c10d/Store.cpp",
508"torch/csrc/distributed/c10d/SymmetricMemory.cpp",
509"torch/csrc/distributed/c10d/TCPStore.cpp",
510"torch/csrc/distributed/c10d/TCPStoreBackend.cpp",
511"torch/csrc/distributed/c10d/TCPStoreLibUvBackend.cpp",
512"torch/csrc/distributed/c10d/Utils.cpp",
513"torch/csrc/distributed/c10d/comm.cpp",
514"torch/csrc/distributed/c10d/debug.cpp",
515"torch/csrc/distributed/c10d/default_comm_hooks.cpp",
516"torch/csrc/distributed/c10d/logger.cpp",
517"torch/csrc/distributed/c10d/logging.cpp",
518"torch/csrc/distributed/c10d/quantization/quantization.cpp",
519"torch/csrc/distributed/c10d/reducer.cpp",
520"torch/csrc/distributed/c10d/sequence_num.cpp",
521"torch/csrc/distributed/c10d/socket.cpp",
522"torch/csrc/distributed/c10d/Work.cpp",
523"torch/csrc/distributed/c10d/control_plane/Handlers.cpp",
524"torch/csrc/distributed/c10d/control_plane/WorkerServer.cpp",
525]
526
527# These files are only supported on Linux (and others) but not on Windows.
528libtorch_distributed_extra_sources = [
529"torch/csrc/distributed/autograd/autograd.cpp",
530"torch/csrc/distributed/autograd/utils.cpp",
531"torch/csrc/distributed/autograd/context/container.cpp",
532"torch/csrc/distributed/autograd/context/context.cpp",
533"torch/csrc/distributed/autograd/engine/dist_engine.cpp",
534"torch/csrc/distributed/autograd/functions/recvrpc_backward.cpp",
535"torch/csrc/distributed/autograd/functions/sendrpc_backward.cpp",
536"torch/csrc/distributed/autograd/rpc_messages/autograd_metadata.cpp",
537"torch/csrc/distributed/autograd/rpc_messages/propagate_gradients_req.cpp",
538"torch/csrc/distributed/autograd/rpc_messages/propagate_gradients_resp.cpp",
539"torch/csrc/distributed/autograd/rpc_messages/cleanup_autograd_context_req.cpp",
540"torch/csrc/distributed/autograd/rpc_messages/cleanup_autograd_context_resp.cpp",
541"torch/csrc/distributed/autograd/rpc_messages/rpc_with_autograd.cpp",
542"torch/csrc/distributed/autograd/rpc_messages/rpc_with_profiling_req.cpp",
543"torch/csrc/distributed/autograd/rpc_messages/rpc_with_profiling_resp.cpp",
544"torch/csrc/distributed/autograd/rpc_messages/rref_backward_req.cpp",
545"torch/csrc/distributed/autograd/rpc_messages/rref_backward_resp.cpp",
546"torch/csrc/distributed/c10d/HashStore.cpp",
547"torch/csrc/distributed/rpc/agent_utils.cpp",
548"torch/csrc/distributed/rpc/message.cpp",
549"torch/csrc/distributed/rpc/profiler/remote_profiler_manager.cpp",
550"torch/csrc/distributed/rpc/profiler/server_process_global_profiler.cpp",
551"torch/csrc/distributed/rpc/python_call.cpp",
552"torch/csrc/distributed/rpc/python_remote_call.cpp",
553"torch/csrc/distributed/rpc/python_resp.cpp",
554"torch/csrc/distributed/rpc/request_callback.cpp",
555"torch/csrc/distributed/rpc/request_callback_no_python.cpp",
556"torch/csrc/distributed/rpc/rpc_agent.cpp",
557"torch/csrc/distributed/rpc/rref_context.cpp",
558"torch/csrc/distributed/rpc/rref_impl.cpp",
559"torch/csrc/distributed/rpc/rref_proto.cpp",
560"torch/csrc/distributed/rpc/script_call.cpp",
561"torch/csrc/distributed/rpc/script_remote_call.cpp",
562"torch/csrc/distributed/rpc/script_resp.cpp",
563"torch/csrc/distributed/rpc/tensorpipe_agent.cpp",
564"torch/csrc/distributed/rpc/tensorpipe_utils.cpp",
565"torch/csrc/distributed/rpc/testing/faulty_tensorpipe_agent.cpp",
566"torch/csrc/distributed/rpc/torchscript_functions.cpp",
567"torch/csrc/distributed/rpc/types.cpp",
568"torch/csrc/distributed/rpc/utils.cpp",
569]
570
571libtorch_distributed_sources = libtorch_distributed_base_sources + libtorch_distributed_extra_sources
572
573jit_sources_full = [
574"torch/csrc/jit/codegen/cuda/interface.cpp",
575"torch/csrc/jit/passes/lower_graph.cpp",
576"torch/csrc/jit/runtime/register_c10_ops.cpp",
577"torch/csrc/jit/runtime/register_prim_ops.cpp",
578"torch/csrc/jit/runtime/register_prim_ops_fulljit.cpp",
579"torch/csrc/jit/runtime/register_special_ops.cpp",
580"torch/csrc/jit/passes/remove_inplace_ops.cpp",
581"torch/csrc/jit/passes/utils/check_alias_annotation.cpp",
582"torch/csrc/jit/passes/autocast.cpp",
583]
584
585libtorch_core_jit_sources = sorted(jit_sources_full)
586
587torch_mobile_tracer_sources = [
588"torch/csrc/jit/mobile/model_tracer/tracer.cpp",
589"torch/csrc/jit/mobile/model_tracer/TensorUtils.cpp",
590"torch/csrc/jit/mobile/model_tracer/TracerRunner.cpp",
591"torch/csrc/jit/mobile/model_tracer/MobileModelRunner.cpp",
592"torch/csrc/jit/mobile/model_tracer/OperatorCallTracer.cpp",
593"torch/csrc/jit/mobile/model_tracer/KernelDTypeTracer.cpp",
594"torch/csrc/jit/mobile/model_tracer/CustomClassTracer.cpp",
595"torch/csrc/jit/mobile/model_tracer/BuildFeatureTracer.cpp",
596]
597
598libtorch_lite_eager_symbolication = [
599"torch/csrc/jit/frontend/source_range.cpp",
600"torch/csrc/jit/ir/scope.cpp",
601"torch/csrc/jit/mobile/debug_info.cpp",
602"torch/csrc/jit/serialization/callstack_debug_info_serialization.cpp",
603"torch/csrc/jit/serialization/source_range_serialization.cpp",
604# Later we can split serialization and deserialization logic
605# to have better separation within build and only build relevant parts.
606"torch/csrc/jit/serialization/pickle.cpp",
607"torch/csrc/jit/serialization/pickler.cpp",
608"torch/csrc/jit/serialization/unpickler.cpp",
609]
610
611# TODO: core_trainer_sources is not necessary for libtorch lite
612libtorch_lite_cmake_sources = sorted(
613core_trainer_sources +
614core_sources_common +
615torch_unpickler_common +
616torch_mobile_core,
617)
618
619libtorch_cmake_sources = libtorch_core_sources + libtorch_core_jit_sources
620
621libtorch_extra_sources = libtorch_core_jit_sources + [
622"torch/csrc/autograd/TraceTypeManual.cpp",
623"torch/csrc/autograd/VariableTypeManual.cpp",
624"torch/csrc/autograd/FunctionsManual.cpp",
625"torch/csrc/jit/api/module_save.cpp",
626"torch/csrc/jit/codegen/fuser/cpu/fused_kernel.cpp",
627"torch/csrc/jit/mobile/compatibility/backport.cpp",
628"torch/csrc/jit/mobile/compatibility/backport_manager.cpp",
629"torch/csrc/jit/mobile/compatibility/model_compatibility.cpp",
630# To be included for eager symbolication in lite interpreter
631# when it is built in libtorch
632"torch/csrc/jit/mobile/debug_info.cpp",
633"torch/csrc/jit/mobile/function.cpp",
634"torch/csrc/jit/mobile/flatbuffer_loader.cpp",
635"torch/csrc/jit/mobile/import.cpp",
636"torch/csrc/jit/mobile/import_data.cpp",
637"torch/csrc/jit/mobile/interpreter.cpp",
638"torch/csrc/jit/mobile/module.cpp",
639"torch/csrc/jit/mobile/observer.cpp",
640"torch/csrc/jit/mobile/parse_bytecode.cpp",
641"torch/csrc/jit/mobile/parse_operators.cpp",
642"torch/csrc/jit/mobile/quantization.cpp",
643"torch/csrc/jit/mobile/train/export_data.cpp",
644"torch/csrc/jit/mobile/train/optim/sgd.cpp",
645"torch/csrc/jit/mobile/train/random.cpp",
646"torch/csrc/jit/mobile/train/sequential.cpp",
647"torch/csrc/jit/mobile/upgrader_mobile.cpp",
648"torch/csrc/jit/serialization/onnx.cpp",
649"torch/csrc/jit/serialization/export.cpp",
650"torch/csrc/jit/serialization/export_bytecode.cpp",
651"torch/csrc/jit/serialization/export_module.cpp",
652"torch/csrc/jit/serialization/flatbuffer_serializer.cpp",
653"torch/csrc/utils/byte_order.cpp",
654"torch/csrc/utils/out_types.cpp",
655]
656
657def libtorch_sources(gencode_pattern = ":generate-code[{}]"):
658return (
659libtorch_generated_sources(gencode_pattern) + libtorch_core_sources + libtorch_distributed_sources + libtorch_extra_sources
660)
661
662libtorch_cuda_core_sources = [
663"torch/csrc/CudaIPCTypes.cpp",
664"torch/csrc/cuda/comm.cpp",
665"torch/csrc/cuda/memory_snapshot.cpp",
666"torch/csrc/cuda/CUDAPluggableAllocator.cpp",
667"torch/csrc/inductor/aoti_runner/model_container_runner_cuda.cpp",
668"torch/csrc/inductor/aoti_torch/shim_cuda.cpp",
669"torch/csrc/jit/codegen/fuser/cuda/fused_kernel.cpp",
670"torch/csrc/profiler/stubs/cuda.cpp",
671"torch/csrc/autograd/functions/comm.cpp",
672"torch/csrc/jit/passes/frozen_conv_add_relu_fusion_cuda.cpp",
673"torch/csrc/jit/tensorexpr/cuda_codegen.cpp",
674"torch/csrc/jit/runtime/register_cuda_ops.cpp",
675]
676
677# These files are the only ones that are supported on Windows.
678libtorch_cuda_distributed_base_sources = [
679"torch/csrc/distributed/c10d/reducer_cuda.cpp",
680]
681
682# These files are only supported on Linux (and others) but not on Windows.
683libtorch_cuda_distributed_extra_sources = [
684"torch/csrc/distributed/c10d/CudaDMAConnectivity.cpp",
685"torch/csrc/distributed/c10d/NCCLUtils.cpp",
686"torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp",
687"torch/csrc/distributed/c10d/ProcessGroupUCC.cpp",
688"torch/csrc/distributed/c10d/UCCTracing.cpp",
689"torch/csrc/distributed/c10d/UCCUtils.cpp",
690"torch/csrc/distributed/c10d/intra_node_comm.cpp",
691"torch/csrc/distributed/c10d/intra_node_comm.cu",
692"torch/csrc/distributed/c10d/CUDASymmetricMemory.cu",
693"torch/csrc/distributed/c10d/CUDASymmetricMemoryOps.cu",
694"torch/csrc/distributed/c10d/NanCheck.cu",
695"torch/csrc/distributed/rpc/tensorpipe_cuda.cpp",
696"torch/csrc/distributed/c10d/quantization/quantization_gpu.cu",
697]
698
699libtorch_cuda_distributed_sources = libtorch_cuda_distributed_base_sources + libtorch_cuda_distributed_extra_sources
700
701libtorch_cuda_sources = libtorch_cuda_core_sources + libtorch_cuda_distributed_sources + [
702"torch/csrc/cuda/nccl.cpp",
703]
704
705torch_cpp_srcs = [
706"torch/csrc/api/src/cuda.cpp", # this just forwards stuff, no real CUDA
707"torch/csrc/api/src/data/datasets/mnist.cpp",
708"torch/csrc/api/src/data/samplers/distributed.cpp",
709"torch/csrc/api/src/data/samplers/random.cpp",
710"torch/csrc/api/src/data/samplers/sequential.cpp",
711"torch/csrc/api/src/data/samplers/stream.cpp",
712"torch/csrc/api/src/enum.cpp",
713"torch/csrc/api/src/imethod.cpp",
714"torch/csrc/api/src/jit.cpp",
715"torch/csrc/api/src/mps.cpp",
716"torch/csrc/api/src/serialize.cpp",
717"torch/csrc/api/src/nn/init.cpp",
718"torch/csrc/api/src/nn/module.cpp",
719"torch/csrc/api/src/nn/modules/_functions.cpp",
720"torch/csrc/api/src/nn/modules/activation.cpp",
721"torch/csrc/api/src/nn/modules/adaptive.cpp",
722"torch/csrc/api/src/nn/modules/batchnorm.cpp",
723"torch/csrc/api/src/nn/modules/normalization.cpp",
724"torch/csrc/api/src/nn/modules/instancenorm.cpp",
725"torch/csrc/api/src/nn/modules/conv.cpp",
726"torch/csrc/api/src/nn/modules/dropout.cpp",
727"torch/csrc/api/src/nn/modules/distance.cpp",
728"torch/csrc/api/src/nn/modules/embedding.cpp",
729"torch/csrc/api/src/nn/modules/fold.cpp",
730"torch/csrc/api/src/nn/modules/linear.cpp",
731"torch/csrc/api/src/nn/modules/loss.cpp",
732"torch/csrc/api/src/nn/modules/padding.cpp",
733"torch/csrc/api/src/nn/modules/pixelshuffle.cpp",
734"torch/csrc/api/src/nn/modules/pooling.cpp",
735"torch/csrc/api/src/nn/modules/rnn.cpp",
736"torch/csrc/api/src/nn/modules/upsampling.cpp",
737"torch/csrc/api/src/nn/modules/transformer.cpp",
738"torch/csrc/api/src/nn/modules/container/functional.cpp",
739"torch/csrc/api/src/nn/options/activation.cpp",
740"torch/csrc/api/src/nn/options/adaptive.cpp",
741"torch/csrc/api/src/nn/options/batchnorm.cpp",
742"torch/csrc/api/src/nn/options/conv.cpp",
743"torch/csrc/api/src/nn/options/dropout.cpp",
744"torch/csrc/api/src/nn/options/instancenorm.cpp",
745"torch/csrc/api/src/nn/options/linear.cpp",
746"torch/csrc/api/src/nn/options/normalization.cpp",
747"torch/csrc/api/src/nn/options/embedding.cpp",
748"torch/csrc/api/src/nn/options/padding.cpp",
749"torch/csrc/api/src/nn/options/pooling.cpp",
750"torch/csrc/api/src/nn/options/rnn.cpp",
751"torch/csrc/api/src/nn/options/vision.cpp",
752"torch/csrc/api/src/nn/options/transformer.cpp",
753"torch/csrc/api/src/optim/adagrad.cpp",
754"torch/csrc/api/src/optim/adam.cpp",
755"torch/csrc/api/src/optim/adamw.cpp",
756"torch/csrc/api/src/optim/lbfgs.cpp",
757"torch/csrc/api/src/optim/optimizer.cpp",
758"torch/csrc/api/src/optim/rmsprop.cpp",
759"torch/csrc/api/src/optim/serialize.cpp",
760"torch/csrc/api/src/optim/sgd.cpp",
761"torch/csrc/api/src/optim/schedulers/lr_scheduler.cpp",
762"torch/csrc/api/src/optim/schedulers/reduce_on_plateau_scheduler.cpp",
763"torch/csrc/api/src/optim/schedulers/step_lr.cpp",
764"torch/csrc/api/src/serialize/input-archive.cpp",
765"torch/csrc/api/src/serialize/output-archive.cpp",
766"torch/csrc/api/src/xpu.cpp",
767]
768
769libtorch_python_cuda_core_sources = [
770"torch/csrc/cuda/Event.cpp",
771"torch/csrc/cuda/Module.cpp",
772"torch/csrc/cuda/python_comm.cpp",
773"torch/csrc/cuda/Stream.cpp",
774"torch/csrc/cuda/Graph.cpp",
775"torch/csrc/cuda/MemPool.cpp",
776"torch/csrc/cuda/shared/cudart.cpp",
777"torch/csrc/cuda/shared/nvtx.cpp",
778"torch/csrc/cuda/utils.cpp",
779"torch/csrc/cuda/GdsFile.cpp",
780]
781
782libtorch_python_cuda_sources = libtorch_python_cuda_core_sources + [
783"torch/csrc/cuda/python_nccl.cpp",
784"torch/csrc/cuda/shared/cudnn.cpp",
785"torch/csrc/cuda/shared/cusparselt.cpp",
786"torch/csrc/cuda/Tensor.cpp",
787]
788
789libtorch_python_xpu_sources = [
790"torch/csrc/xpu/Event.cpp",
791"torch/csrc/xpu/Module.cpp",
792"torch/csrc/xpu/Stream.cpp",
793]
794
795libtorch_python_core_sources = [
796"torch/csrc/DataLoader.cpp",
797"torch/csrc/Device.cpp",
798"torch/csrc/Dtype.cpp",
799"torch/csrc/DynamicTypes.cpp",
800"torch/csrc/Exceptions.cpp",
801"torch/csrc/Generator.cpp",
802"torch/csrc/Layout.cpp",
803"torch/csrc/MemoryFormat.cpp",
804"torch/csrc/QScheme.cpp",
805"torch/csrc/Module.cpp",
806"torch/csrc/PyInterpreter.cpp",
807"torch/csrc/python_dimname.cpp",
808"torch/csrc/Size.cpp",
809"torch/csrc/Storage.cpp",
810"torch/csrc/StorageMethods.cpp",
811"torch/csrc/StorageSharing.cpp",
812"torch/csrc/Stream.cpp",
813"torch/csrc/Event.cpp",
814"torch/csrc/TypeInfo.cpp",
815"torch/csrc/api/src/python/init.cpp",
816"torch/csrc/autograd/functions/init.cpp",
817"torch/csrc/autograd/init.cpp",
818"torch/csrc/autograd/profiler_python.cpp",
819"torch/csrc/autograd/python_anomaly_mode.cpp",
820"torch/csrc/autograd/python_saved_variable_hooks.cpp",
821"torch/csrc/autograd/python_cpp_function.cpp",
822"torch/csrc/autograd/python_engine.cpp",
823"torch/csrc/autograd/python_function.cpp",
824"torch/csrc/autograd/python_hook.cpp",
825"torch/csrc/autograd/python_legacy_variable.cpp",
826"torch/csrc/autograd/python_nested_functions_manual.cpp",
827"torch/csrc/autograd/python_torch_functions_manual.cpp",
828"torch/csrc/autograd/python_variable.cpp",
829"torch/csrc/autograd/python_variable_indexing.cpp",
830"torch/csrc/dynamo/python_compiled_autograd.cpp",
831"torch/csrc/dynamo/cache_entry.cpp",
832"torch/csrc/dynamo/cpp_shim.cpp",
833"torch/csrc/dynamo/cpython_defs.c",
834"torch/csrc/dynamo/eval_frame.c",
835"torch/csrc/dynamo/extra_state.cpp",
836"torch/csrc/dynamo/framelocals_mapping.cpp",
837"torch/csrc/dynamo/guards.cpp",
838"torch/csrc/dynamo/utils.cpp",
839"torch/csrc/dynamo/init.cpp",
840"torch/csrc/functorch/init.cpp",
841"torch/csrc/fx/node.cpp",
842"torch/csrc/mps/Module.cpp",
843"torch/csrc/mtia/Module.cpp",
844"torch/csrc/inductor/aoti_runner/pybind.cpp",
845"torch/csrc/inductor/aoti_eager/kernel_holder.cpp",
846"torch/csrc/inductor/aoti_eager/kernel_meta_info.cpp",
847"torch/csrc/inductor/resize_storage_bytes.cpp",
848"torch/csrc/jit/backends/backend_init.cpp",
849"torch/csrc/jit/python/init.cpp",
850"torch/csrc/jit/passes/onnx.cpp",
851"torch/csrc/jit/passes/onnx/cast_all_constant_to_floating.cpp",
852"torch/csrc/jit/passes/onnx/deduplicate_initializers.cpp",
853"torch/csrc/jit/passes/onnx/eval_peephole.cpp",
854"torch/csrc/jit/passes/onnx/constant_fold.cpp",
855"torch/csrc/jit/passes/onnx/constant_map.cpp",
856"torch/csrc/jit/passes/onnx/eliminate_unused_items.cpp",
857"torch/csrc/jit/passes/onnx/fixup_onnx_controlflow.cpp",
858"torch/csrc/jit/passes/onnx/list_model_parameters.cpp",
859"torch/csrc/jit/passes/onnx/function_substitution.cpp",
860"torch/csrc/jit/passes/onnx/helper.cpp",
861"torch/csrc/jit/passes/onnx/peephole.cpp",
862"torch/csrc/jit/passes/onnx/preprocess_for_onnx.cpp",
863"torch/csrc/jit/passes/onnx/prepare_division_for_onnx.cpp",
864"torch/csrc/jit/passes/onnx/scalar_type_analysis.cpp",
865"torch/csrc/jit/passes/onnx/unpack_quantized_weights.cpp",
866"torch/csrc/jit/passes/onnx/remove_inplace_ops_for_onnx.cpp",
867"torch/csrc/jit/passes/onnx/shape_type_inference.cpp",
868"torch/csrc/jit/passes/onnx/function_extraction.cpp",
869"torch/csrc/jit/passes/onnx/onnx_log.cpp",
870"torch/csrc/jit/passes/onnx/naming.cpp",
871"torch/csrc/jit/python/pybind_utils.cpp",
872"torch/csrc/jit/passes/onnx/pattern_conversion/autograd_function_process.cpp",
873"torch/csrc/jit/passes/onnx/pattern_conversion/common.cpp",
874"torch/csrc/jit/passes/onnx/pattern_conversion/pattern_encapsulation.cpp",
875"torch/csrc/jit/passes/onnx/pattern_conversion/pattern_conversion.cpp",
876"torch/csrc/jit/python/python_arg_flatten.cpp",
877"torch/csrc/jit/python/python_custom_class.cpp",
878"torch/csrc/jit/python/python_dict.cpp",
879"torch/csrc/jit/python/python_interpreter.cpp",
880"torch/csrc/jit/python/python_ir.cpp",
881"torch/csrc/jit/python/python_list.cpp",
882"torch/csrc/jit/python/python_tracer.cpp",
883"torch/csrc/jit/python/script_init.cpp",
884"torch/csrc/jit/frontend/concrete_module_type.cpp",
885"torch/csrc/jit/frontend/tree_views.cpp",
886"torch/csrc/jit/python/python_sugared_value.cpp",
887"torch/csrc/jit/python/python_tree_views.cpp",
888"torch/csrc/jit/runtime/static/init.cpp",
889"torch/csrc/jit/tensorexpr/tensorexpr_init.cpp",
890"torch/csrc/monitor/python_init.cpp",
891"torch/csrc/multiprocessing/init.cpp",
892"torch/csrc/onnx/init.cpp",
893"torch/csrc/profiler/python/init.cpp",
894"torch/csrc/profiler/python/combined_traceback.cpp",
895"torch/csrc/serialization.cpp",
896"torch/csrc/tensor/python_tensor.cpp",
897"torch/csrc/utils/init.cpp",
898"torch/csrc/utils/throughput_benchmark.cpp",
899"torch/csrc/utils.cpp",
900"torch/csrc/utils/device_lazy_init.cpp",
901"torch/csrc/utils/invalid_arguments.cpp",
902"torch/csrc/utils/nested.cpp",
903"torch/csrc/utils/object_ptr.cpp",
904"torch/csrc/utils/python_arg_parser.cpp",
905"torch/csrc/utils/python_dispatch.cpp",
906"torch/csrc/utils/python_symnode.cpp",
907"torch/csrc/utils/pybind.cpp",
908"torch/csrc/utils/pyobject_preservation.cpp",
909"torch/csrc/utils/structseq.cpp",
910"torch/csrc/utils/tensor_apply.cpp",
911"torch/csrc/utils/tensor_dtypes.cpp",
912"torch/csrc/utils/tensor_layouts.cpp",
913"torch/csrc/utils/tensor_memoryformats.cpp",
914"torch/csrc/utils/tensor_qschemes.cpp",
915"torch/csrc/utils/tensor_list.cpp",
916"torch/csrc/utils/tensor_new.cpp",
917"torch/csrc/utils/tensor_numpy.cpp",
918"torch/csrc/utils/tensor_types.cpp",
919"torch/csrc/utils/disable_torch_function.cpp",
920"torch/csrc/utils/verbose.cpp",
921"torch/csrc/cpu/Module.cpp",
922"torch/csrc/instruction_counter/Module.cpp",
923] + lazy_tensor_core_python_sources
924
925libtorch_python_distributed_core_sources = [
926"torch/csrc/distributed/c10d/init.cpp",
927"torch/csrc/distributed/c10d/python_comm_hook.cpp",
928]
929
930libtorch_python_distributed_sources = libtorch_python_distributed_core_sources + [
931"torch/csrc/distributed/autograd/init.cpp",
932"torch/csrc/distributed/rpc/init.cpp",
933"torch/csrc/distributed/rpc/py_rref.cpp",
934"torch/csrc/distributed/rpc/python_functions.cpp",
935"torch/csrc/distributed/rpc/python_rpc_handler.cpp",
936"torch/csrc/distributed/rpc/request_callback_impl.cpp",
937"torch/csrc/distributed/rpc/testing/init.cpp",
938"torch/csrc/distributed/rpc/unpickled_python_call.cpp",
939"torch/csrc/distributed/rpc/unpickled_python_remote_call.cpp",
940"torch/csrc/jit/runtime/register_distributed_ops.cpp",
941"torch/csrc/distributed/c10d/control_plane/PythonHandlers.cpp",
942]
943
944def glob_libtorch_python_sources(gencode_pattern = ":generate-code[{}]"):
945_libtorch_python_sources = [gencode_pattern.format(name) for name in [
946"torch/csrc/autograd/generated/python_functions_0.cpp",
947"torch/csrc/autograd/generated/python_functions_1.cpp",
948"torch/csrc/autograd/generated/python_functions_2.cpp",
949"torch/csrc/autograd/generated/python_functions_3.cpp",
950"torch/csrc/autograd/generated/python_functions_4.cpp",
951"torch/csrc/autograd/generated/python_nested_functions.cpp",
952"torch/csrc/autograd/generated/python_nn_functions.cpp",
953"torch/csrc/autograd/generated/python_fft_functions.cpp",
954"torch/csrc/autograd/generated/python_linalg_functions.cpp",
955"torch/csrc/autograd/generated/python_enum_tag.cpp",
956"torch/csrc/autograd/generated/python_return_types.cpp",
957"torch/csrc/autograd/generated/python_sparse_functions.cpp",
958"torch/csrc/autograd/generated/python_special_functions.cpp",
959"torch/csrc/autograd/generated/python_torch_functions_0.cpp",
960"torch/csrc/autograd/generated/python_torch_functions_1.cpp",
961"torch/csrc/autograd/generated/python_torch_functions_2.cpp",
962"torch/csrc/autograd/generated/python_variable_methods.cpp",
963]]
964
965_libtorch_python_sources.extend(libtorch_python_core_sources)
966_libtorch_python_sources.extend(libtorch_python_distributed_sources)
967
968return _libtorch_python_sources
969
970# List of non-globed source used to build ATen core internally
971aten_cpu_non_globed_sources = [
972"aten/src/ATen/detail/CUDAHooksInterface.cpp",
973"aten/src/ATen/detail/HIPHooksInterface.cpp",
974"aten/src/ATen/detail/MPSHooksInterface.cpp",
975"aten/src/ATen/detail/MAIAHooksInterface.cpp",
976"aten/src/ATen/detail/PrivateUse1HooksInterface.cpp",
977"aten/src/ATen/detail/XPUHooksInterface.cpp",
978"aten/src/ATen/detail/MTIAHooksInterface.cpp",
979"aten/src/ATen/detail/IPUHooksInterface.cpp",
980"aten/src/ATen/record_function.cpp",
981"aten/src/ATen/Dispatch.cpp",
982"aten/src/ATen/SequenceNumber.cpp",
983]
984
985aten_cpu_non_globed_headers = [
986"aten/src/ATen/CPUGeneratorImpl.h",
987"aten/src/ATen/NumericUtils.h",
988"aten/src/ATen/detail/AcceleratorHooksInterface.h",
989"aten/src/ATen/detail/CUDAHooksInterface.h",
990"aten/src/ATen/detail/MPSHooksInterface.h",
991"aten/src/ATen/detail/HIPHooksInterface.h",
992"aten/src/ATen/detail/MAIAHooksInterface.h",
993"aten/src/ATen/detail/PrivateUse1HooksInterface.h",
994"aten/src/ATen/detail/XPUHooksInterface.h",
995"aten/src/ATen/detail/MTIAHooksInterface.h",
996"aten/src/ATen/detail/IPUHooksInterface.h",
997]
998
999aten_cpu_source_non_codegen_list = [
1000"aten/src/ATen/AccumulateType.cpp",
1001"aten/src/ATen/LegacyBatchedTensorImpl.cpp",
1002"aten/src/ATen/CPUGeneratorImpl.cpp",
1003"aten/src/ATen/DeviceAccelerator.cpp",
1004"aten/src/ATen/Context.cpp",
1005"aten/src/ATen/DLConvertor.cpp",
1006"aten/src/ATen/EmptyTensor.cpp",
1007"aten/src/ATen/ExpandUtils.cpp",
1008"aten/src/ATen/CachedTensorUtils.cpp",
1009"aten/src/ATen/FunctionalInverses.cpp",
1010"aten/src/ATen/FunctionalStorageImpl.cpp",
1011"aten/src/ATen/FunctionalTensorWrapper.cpp",
1012"aten/src/ATen/FunctionalizeFallbackKernel.cpp",
1013"aten/src/ATen/MemoryOverlap.cpp",
1014"aten/src/ATen/MapAllocator.cpp",
1015"aten/src/ATen/NamedTensorUtils.cpp",
1016"aten/src/ATen/NestedTensorImpl.cpp",
1017"aten/src/ATen/ParallelCommon.cpp",
1018"aten/src/ATen/ParallelNative.cpp",
1019"aten/src/ATen/ParallelOpenMP.cpp",
1020"aten/src/ATen/ParallelThreadPoolNative.cpp",
1021"aten/src/ATen/PythonTorchFunctionTLS.cpp",
1022"aten/src/ATen/ThreadLocalPythonObjects.cpp",
1023"aten/src/ATen/ScalarOps.cpp",
1024"aten/src/ATen/SparseTensorImpl.cpp",
1025"aten/src/ATen/SparseCsrTensorImpl.cpp",
1026"aten/src/ATen/TensorGeometry.cpp",
1027"aten/src/ATen/TensorIndexing.cpp",
1028"aten/src/ATen/TensorMeta.cpp",
1029"aten/src/ATen/TensorNames.cpp",
1030"aten/src/ATen/TensorUtils.cpp",
1031"aten/src/ATen/ThreadLocalState.cpp",
1032"aten/src/ATen/FuncTorchTLS.cpp",
1033"aten/src/ATen/Utils.cpp",
1034"aten/src/ATen/Version.cpp",
1035"aten/src/ATen/LegacyVmapMode.cpp",
1036"aten/src/ATen/LegacyVmapTransforms.cpp",
1037"aten/src/ATen/core/BackendSelectFallbackKernel.cpp",
1038"aten/src/ATen/core/DeprecatedTypeProperties.cpp",
1039"aten/src/ATen/core/DeprecatedTypePropertiesRegistry.cpp",
1040"aten/src/ATen/core/Dict.cpp",
1041"aten/src/ATen/core/Dimname.cpp",
1042"aten/src/ATen/core/Formatting.cpp",
1043"aten/src/ATen/core/function_schema.cpp",
1044"aten/src/ATen/core/Generator.cpp",
1045"aten/src/ATen/core/PythonOpRegistrationTrampoline.cpp",
1046"aten/src/ATen/core/List.cpp",
1047"aten/src/ATen/core/NamedTensor.cpp",
1048"aten/src/ATen/core/Tensor.cpp",
1049"aten/src/ATen/core/VariableFallbackKernel.cpp",
1050"aten/src/ATen/core/VariableHooksInterface.cpp",
1051"aten/src/ATen/core/Vitals.cpp",
1052"aten/src/ATen/core/boxing/KernelFunction.cpp",
1053"aten/src/ATen/core/custom_class.cpp",
1054"aten/src/ATen/core/dispatch/DispatchKeyExtractor.cpp",
1055"aten/src/ATen/core/dispatch/Dispatcher.cpp",
1056"aten/src/ATen/core/dispatch/ObservedOperators.cpp",
1057"aten/src/ATen/core/dispatch/OperatorEntry.cpp",
1058"aten/src/ATen/core/interned_strings.cpp",
1059"aten/src/ATen/core/ivalue.cpp",
1060"aten/src/ATen/core/library.cpp",
1061"aten/src/ATen/core/op_registration/infer_schema.cpp",
1062"aten/src/ATen/core/op_registration/op_registration.cpp",
1063"aten/src/ATen/core/operator_name.cpp",
1064"aten/src/ATen/core/TorchDispatchUtils.cpp",
1065"aten/src/ATen/core/register_symbols.cpp",
1066"aten/src/ATen/core/NestedIntSymNodeImpl.cpp",
1067"aten/src/ATen/core/class_type.cpp",
1068"aten/src/ATen/core/type.cpp",
1069"aten/src/ATen/core/type_factory.cpp",
1070"aten/src/ATen/core/dynamic_type.cpp",
1071"aten/src/ATen/core/tensor_type.cpp",
1072"aten/src/ATen/core/union_type.cpp",
1073"aten/src/ATen/cpu/FlushDenormal.cpp",
1074"aten/src/ATen/detail/CPUGuardImpl.cpp",
1075"aten/src/ATen/metal/Context.cpp",
1076"aten/src/ATen/native/AutogradComposite.cpp",
1077"aten/src/ATen/native/ComparisonUtils.cpp",
1078"aten/src/ATen/native/DispatchStub.cpp",
1079"aten/src/ATen/native/UpSample.cpp",
1080"aten/src/ATen/native/mkldnn/BinaryOps.cpp",
1081"aten/src/ATen/native/mkldnn/Conv.cpp",
1082"aten/src/ATen/native/mkldnn/ConvPrepack.cpp",
1083"aten/src/ATen/native/mkldnn/Copy.cpp",
1084"aten/src/ATen/native/mkldnn/Gelu.cpp",
1085"aten/src/ATen/native/mkldnn/IDeepRegistration.cpp",
1086"aten/src/ATen/native/mkldnn/Linear.cpp",
1087"aten/src/ATen/native/mkldnn/MKLDNNCommon.cpp",
1088"aten/src/ATen/native/mkldnn/MKLDNNConversions.cpp",
1089"aten/src/ATen/native/mkldnn/MkldnnTensorMath.cpp",
1090"aten/src/ATen/native/mkldnn/Normalization.cpp",
1091"aten/src/ATen/native/mkldnn/OpContext.cpp",
1092"aten/src/ATen/native/mkldnn/Pooling.cpp",
1093"aten/src/ATen/native/mkldnn/Prelu.cpp",
1094"aten/src/ATen/native/mkldnn/RegisterMkldnnOpContextClass.cpp",
1095"aten/src/ATen/native/mkldnn/Relu.cpp",
1096"aten/src/ATen/native/mkldnn/RNN.cpp",
1097"aten/src/ATen/native/mkldnn/SoftMax.cpp",
1098"aten/src/ATen/native/mkldnn/TensorFactories.cpp",
1099"aten/src/ATen/native/mkldnn/TensorShape.cpp",
1100"aten/src/ATen/native/mkldnn/UnaryOps.cpp",
1101"aten/src/ATen/native/mkldnn/Utils.cpp",
1102"aten/src/ATen/native/mkldnn/Matmul.cpp",
1103"aten/src/ATen/native/quantized/cpu/init_qnnpack.cpp",
1104# This is moved to aten_cpu because some of the custom ops use empty_with_tail_padding
1105# which was available only within aten_native_cpu. Ideally the right fix is to make
1106# empty_with_tail_padding into an op and use dispatcher with it. But exposing it as an op
1107# has limited use and hence does not seem to really make sense.
1108"aten/src/ATen/native/utils/Factory.cpp",
1109"aten/src/ATen/SavedTensorHooks.cpp",
1110"aten/src/ATen/vulkan/Context.cpp",
1111"aten/src/ATen/native/prim_native_functions.cpp",
1112"aten/src/ATen/native/verbose_wrapper.cpp",
1113"aten/src/ATen/cpu/Utils.cpp",
1114] + aten_cpu_non_globed_sources
1115
1116aten_cpu_source_codegen_list = [
1117"aten/src/ATen/native/cpu/AdaptiveAvgPoolKernel.cpp",
1118"aten/src/ATen/native/cpu/AdaptiveMaxPoolKernel.cpp",
1119]
1120
1121aten_ufunc_headers = [
1122"aten/src/ATen/native/ufunc/add.h",
1123]
1124
1125# When building lite interpreter in OSS, "aten/src/ATen/native/cpu/AdaptiveAvgPoolKernel.cpp" will go through
1126# codegen process. The codegen version of this file, like Activation.cpp.DEFAULT.cpp, will be included
1127# in ${cpu_kernel_cpp} in aten/src/ATen/CMakeLists.txt. As a result, in aten/src/ATen/CMakeLists.txt,
1128# only aten_cpu_source_non_codegen_list need to be added to ${all_cpu_cpp}.
1129aten_cpu_source_list = sorted(aten_cpu_source_non_codegen_list + aten_cpu_source_codegen_list)
1130
1131# Same as ${aten_cpu_source_codegen_list}, this list will go through aten codegen, and be included in
1132# ${cpu_kernel_cpp} in aten/src/ATen/CMakeLists.txt.
1133aten_native_source_codegen_list = [
1134"aten/src/ATen/native/cpu/Activation.cpp",
1135"aten/src/ATen/native/cpu/AvgPoolKernel.cpp",
1136"aten/src/ATen/native/cpu/BinaryOpsKernel.cpp",
1137"aten/src/ATen/native/cpu/BlasKernel.cpp",
1138"aten/src/ATen/native/cpu/CatKernel.cpp",
1139"aten/src/ATen/native/cpu/ChannelShuffleKernel.cpp",
1140"aten/src/ATen/native/cpu/ComplexKernel.cpp",
1141"aten/src/ATen/native/cpu/CopyKernel.cpp",
1142"aten/src/ATen/native/cpu/CrossKernel.cpp",
1143"aten/src/ATen/native/cpu/DepthwiseConvKernel.cpp",
1144"aten/src/ATen/native/cpu/DistanceOpsKernel.cpp",
1145"aten/src/ATen/native/cpu/DistributionKernels.cpp",
1146"aten/src/ATen/native/cpu/FlashAttentionKernel.cpp",
1147"aten/src/ATen/native/cpu/FillKernel.cpp",
1148"aten/src/ATen/native/cpu/FunctionOfAMatrixUtilsKernel.cpp",
1149"aten/src/ATen/native/cpu/GridSamplerKernel.cpp",
1150"aten/src/ATen/native/cpu/HistogramKernel.cpp",
1151"aten/src/ATen/native/cpu/IndexKernel.cpp",
1152"aten/src/ATen/native/cpu/LerpKernel.cpp",
1153"aten/src/ATen/native/cpu/LinearAlgebraKernel.cpp",
1154"aten/src/ATen/native/cpu/MaxPoolKernel.cpp",
1155"aten/src/ATen/native/cpu/MaxPooling.cpp",
1156"aten/src/ATen/native/cpu/MaxUnpoolKernel.cpp",
1157"aten/src/ATen/native/cpu/MultinomialKernel.cpp",
1158"aten/src/ATen/native/cpu/NativeMultiheadAttnKernel.cpp",
1159"aten/src/ATen/native/cpu/PaddingKernel.cpp",
1160"aten/src/ATen/native/cpu/PixelShuffleKernel.cpp",
1161"aten/src/ATen/native/cpu/PointwiseOpsKernel.cpp",
1162"aten/src/ATen/native/cpu/PowKernel.cpp",
1163"aten/src/ATen/native/cpu/RangeFactoriesKernel.cpp",
1164"aten/src/ATen/native/cpu/ReduceAllOpsKernel.cpp",
1165"aten/src/ATen/native/cpu/ReduceOpsKernel.cpp",
1166"aten/src/ATen/native/cpu/RenormKernel.cpp",
1167"aten/src/ATen/native/cpu/ScatterGatherKernel.cpp",
1168"aten/src/ATen/native/cpu/SoftMaxKernel.cpp",
1169"aten/src/ATen/native/cpu/SortingKernel.cpp",
1170"aten/src/ATen/native/cpu/StackKernel.cpp",
1171"aten/src/ATen/native/cpu/SumKernel.cpp",
1172"aten/src/ATen/native/cpu/TensorCompareKernel.cpp",
1173"aten/src/ATen/native/cpu/UnaryOpsKernel.cpp",
1174"aten/src/ATen/native/cpu/Unfold2d.cpp",
1175"aten/src/ATen/native/cpu/UnfoldBackwardKernel.cpp",
1176"aten/src/ATen/native/cpu/UpSampleKernel.cpp",
1177"aten/src/ATen/native/cpu/UpSampleMoreKernel.cpp",
1178"aten/src/ATen/native/cpu/WeightNormKernel.cpp",
1179"aten/src/ATen/native/cpu/airy_ai.cpp",
1180"aten/src/ATen/native/cpu/batch_norm_kernel.cpp",
1181"aten/src/ATen/native/cpu/group_norm_kernel.cpp",
1182"aten/src/ATen/native/cpu/int4mm_kernel.cpp",
1183"aten/src/ATen/native/cpu/int8mm_kernel.cpp",
1184"aten/src/ATen/native/cpu/layer_norm_kernel.cpp",
1185"aten/src/ATen/native/cpu/AmpGradScalerKernels.cpp",
1186"aten/src/ATen/native/cpu/scaled_modified_bessel_k0.cpp",
1187"aten/src/ATen/native/cpu/scaled_modified_bessel_k1.cpp",
1188"aten/src/ATen/native/cpu/spherical_bessel_j0.cpp",
1189"aten/src/ATen/native/cpu/SampledAddmmKernel.cpp",
1190"aten/src/ATen/native/cpu/SpmmReduceKernel.cpp",
1191"aten/src/ATen/native/cpu/SparseFactories.cpp",
1192"aten/src/ATen/native/quantized/cpu/kernels/QuantizedOpKernels.cpp",
1193"aten/src/ATen/native/cpu/FusedAdamKernel.cpp",
1194"aten/src/ATen/native/cpu/FusedSGDKernel.cpp",
1195"aten/src/ATen/native/cpu/FusedAdagradKernel.cpp",
1196]
1197
1198# This aten native source file list will not go through aten codegen process
1199aten_native_source_non_codegen_list = [
1200"aten/src/ATen/native/ao_sparse/library.cpp",
1201"aten/src/ATen/native/ao_sparse/quantized/cpu/fbgemm_utils.cpp",
1202"aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear.cpp",
1203"aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_deserialize.cpp",
1204"aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_dynamic.cpp",
1205"aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_prepack.cpp",
1206"aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_serialize.cpp",
1207"aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_unpack.cpp",
1208"aten/src/ATen/native/quantized/cpu/fbgemm_utils.cpp",
1209"aten/src/ATen/native/quantized/cpu/fused_obs_fake_quant.cpp",
1210"aten/src/ATen/native/quantized/cpu/IntReprQuant.cpp",
1211"aten/src/ATen/native/quantized/cpu/MakePerTensorQuantizedTensor.cpp",
1212"aten/src/ATen/native/quantized/cpu/AdaptiveAveragePooling.cpp",
1213"aten/src/ATen/native/quantized/cpu/AveragePool2d.cpp",
1214"aten/src/ATen/native/quantized/cpu/AveragePool3d.cpp",
1215"aten/src/ATen/native/quantized/cpu/BinaryOps.cpp",
1216"aten/src/ATen/native/quantized/cpu/Normalization.cpp",
1217"aten/src/ATen/native/quantized/cpu/ChannelShuffle.cpp",
1218"aten/src/ATen/native/quantized/cpu/qclamp.cpp",
1219"aten/src/ATen/native/quantized/cpu/TensorShape.cpp",
1220"aten/src/ATen/native/quantized/cpu/qconv.cpp",
1221"aten/src/ATen/native/quantized/cpu/qconv_prepack.cpp",
1222"aten/src/ATen/native/quantized/cpu/qconv_unpack_impl.cpp",
1223"aten/src/ATen/native/quantized/cpu/qelu.cpp",
1224"aten/src/ATen/native/quantized/cpu/qembeddingbag.cpp",
1225"aten/src/ATen/native/quantized/cpu/qembeddingbag_prepack.cpp",
1226"aten/src/ATen/native/quantized/cpu/qembeddingbag_unpack.cpp",
1227"aten/src/ATen/native/quantized/cpu/qgelu.cpp",
1228"aten/src/ATen/native/quantized/cpu/qhardsigmoid.cpp",
1229"aten/src/ATen/native/quantized/cpu/qhardswish.cpp",
1230"aten/src/ATen/native/quantized/cpu/qlinear.cpp",
1231"aten/src/ATen/native/quantized/cpu/qlinear_dynamic.cpp",
1232"aten/src/ATen/native/quantized/cpu/qconv_dynamic.cpp",
1233"aten/src/ATen/native/quantized/cpu/qlinear_prepack.cpp",
1234"aten/src/ATen/native/quantized/cpu/LinearUnpackImpl.cpp",
1235"aten/src/ATen/native/quantized/cpu/qmatmul.cpp",
1236"aten/src/ATen/native/quantized/cpu/qmul.cpp",
1237"aten/src/ATen/native/quantized/cpu/qnormalization.cpp",
1238"aten/src/ATen/native/quantized/cpu/Pooling.cpp",
1239"aten/src/ATen/native/quantized/cpu/ReduceOps.cpp",
1240"aten/src/ATen/native/quantized/cpu/qrelu.cpp",
1241"aten/src/ATen/native/quantized/cpu/qsigmoid.cpp",
1242"aten/src/ATen/native/quantized/cpu/qsoftmax.cpp",
1243"aten/src/ATen/native/quantized/cpu/Sorting.cpp",
1244"aten/src/ATen/native/quantized/cpu/qtanh.cpp",
1245"aten/src/ATen/native/quantized/cpu/qthreshold.cpp",
1246"aten/src/ATen/native/quantized/cpu/UpSampleBilinear2d.cpp",
1247"aten/src/ATen/native/quantized/cpu/UpSampleNearest2d.cpp",
1248"aten/src/ATen/native/quantized/cpu/UpSampleNearest3d.cpp",
1249"aten/src/ATen/native/quantized/cpu/TensorOperators.cpp",
1250"aten/src/ATen/native/quantized/Copy.cpp",
1251"aten/src/ATen/native/quantized/QTensor.cpp",
1252"aten/src/ATen/native/quantized/TensorCompare.cpp",
1253"aten/src/ATen/native/quantized/TensorFactories.cpp",
1254"aten/src/ATen/native/quantized/AffineQuantizer.cpp",
1255"aten/src/ATen/native/quantized/AffineQuantizerBase.cpp",
1256"aten/src/ATen/native/quantized/FakeQuantPerChannelAffine.cpp",
1257"aten/src/ATen/native/quantized/FakeQuantPerTensorAffine.cpp",
1258"aten/src/ATen/native/quantized/library.cpp",
1259"aten/src/ATen/native/quantized/TensorAdvancedIndexing.cpp",
1260"aten/src/ATen/native/quantized/cpu/RuyUtils.cpp",
1261"aten/src/ATen/native/quantized/cpu/XnnpackUtils.cpp",
1262"aten/src/ATen/native/quantized/qlinear_unpack.cpp",
1263"aten/src/ATen/quantized/QTensorImpl.cpp",
1264"aten/src/ATen/quantized/Quantizer.cpp",
1265"aten/src/ATen/native/Activation.cpp",
1266"aten/src/ATen/native/AdaptiveAveragePooling.cpp",
1267"aten/src/ATen/native/AdaptiveAveragePooling3d.cpp",
1268"aten/src/ATen/native/AdaptiveMaxPooling2d.cpp",
1269"aten/src/ATen/native/AdaptiveMaxPooling3d.cpp",
1270"aten/src/ATen/native/AffineGridGenerator.cpp",
1271"aten/src/ATen/native/AveragePool2d.cpp",
1272"aten/src/ATen/native/AveragePool3d.cpp",
1273"aten/src/ATen/native/BatchLinearAlgebra.cpp",
1274"aten/src/ATen/native/BatchLinearAlgebraKernel.cpp",
1275"aten/src/ATen/native/LegacyBatching.cpp",
1276"aten/src/ATen/native/BinaryOps.cpp",
1277"aten/src/ATen/native/Blas.cpp",
1278"aten/src/ATen/native/BlasKernel.cpp",
1279"aten/src/ATen/native/Bucketization.cpp",
1280"aten/src/ATen/native/CPUBlas.cpp",
1281"aten/src/ATen/native/ChanelShuffle.cpp",
1282"aten/src/ATen/native/Col2Im.cpp",
1283"aten/src/ATen/native/PadNd.cpp",
1284"aten/src/ATen/native/Constraints.cpp",
1285"aten/src/ATen/native/Convolution.cpp",
1286"aten/src/ATen/native/ConvolutionMM2d.cpp",
1287"aten/src/ATen/native/ConvolutionMM3d.cpp",
1288"aten/src/ATen/native/ConvolutionTBC.cpp",
1289"aten/src/ATen/native/Copy.cpp",
1290"aten/src/ATen/native/Correlation.cpp",
1291"aten/src/ATen/native/CPUFallback.cpp",
1292"aten/src/ATen/native/Cross.cpp",
1293"aten/src/ATen/native/DilatedMaxPool2d.cpp",
1294"aten/src/ATen/native/DilatedMaxPool3d.cpp",
1295# Referenced by both native and ATen/Version.cpp. Does not reference to other native symbols
1296# "aten/src/ATen/native/DispatchStub.cpp",
1297# "aten/src/ATen/native/quantized/cpu/init_qnnpack.cpp",
1298"aten/src/ATen/native/Distance.cpp",
1299"aten/src/ATen/native/Distributions.cpp",
1300"aten/src/ATen/native/Dropout.cpp",
1301"aten/src/ATen/native/Embedding.cpp",
1302"aten/src/ATen/native/EmbeddingBag.cpp",
1303"aten/src/ATen/native/Fill.cpp",
1304"aten/src/ATen/native/ForeachOpsKernels.cpp",
1305"aten/src/ATen/native/FractionalMaxPool2d.cpp",
1306"aten/src/ATen/native/FractionalMaxPool3d.cpp",
1307"aten/src/ATen/native/FunctionOfAMatrixUtils.cpp",
1308"aten/src/ATen/native/GatedLinearUnit.cpp",
1309"aten/src/ATen/native/GridSampler.cpp",
1310"aten/src/ATen/native/Histogram.cpp",
1311"aten/src/ATen/native/Im2Col.cpp",
1312"aten/src/ATen/native/IndexingUtils.cpp",
1313"aten/src/ATen/native/Integration.cpp",
1314"aten/src/ATen/native/Itertools.cpp",
1315"aten/src/ATen/native/LegacyBridge.cpp",
1316"aten/src/ATen/native/Lerp.cpp",
1317"aten/src/ATen/native/Linear.cpp",
1318"aten/src/ATen/native/LinearAlgebra.cpp",
1319"aten/src/ATen/native/Loss.cpp",
1320"aten/src/ATen/native/LossCTC.cpp",
1321"aten/src/ATen/native/LossMultiLabelMargin.cpp",
1322"aten/src/ATen/native/LossMultiMargin.cpp",
1323"aten/src/ATen/native/LossNLL.cpp",
1324"aten/src/ATen/native/LossNLL2d.cpp",
1325"aten/src/ATen/native/MaxPooling.cpp",
1326"aten/src/ATen/native/MaxUnpooling.cpp",
1327"aten/src/ATen/native/Memory.cpp",
1328"aten/src/ATen/native/MetaTensor.cpp",
1329"aten/src/ATen/native/NNPACK.cpp",
1330"aten/src/ATen/native/NaiveConvolutionTranspose2d.cpp",
1331"aten/src/ATen/native/NaiveConvolutionTranspose3d.cpp",
1332"aten/src/ATen/native/NaiveDilatedConvolution.cpp",
1333"aten/src/ATen/native/NamedTensor.cpp",
1334"aten/src/ATen/native/Normalization.cpp",
1335"aten/src/ATen/native/Onehot.cpp",
1336"aten/src/ATen/native/PackedSequence.cpp",
1337"aten/src/ATen/native/PixelShuffle.cpp",
1338"aten/src/ATen/native/PointwiseOps.cpp",
1339"aten/src/ATen/native/Pooling.cpp",
1340"aten/src/ATen/native/Pow.cpp",
1341"aten/src/ATen/native/QuantizedLinear.cpp",
1342"aten/src/ATen/native/RNN.cpp",
1343"aten/src/ATen/native/RangeFactories.cpp",
1344"aten/src/ATen/native/ReduceAllOps.cpp",
1345"aten/src/ATen/native/ReduceOps.cpp",
1346"aten/src/ATen/native/ReflectionPad.cpp",
1347"aten/src/ATen/native/Repeat.cpp",
1348"aten/src/ATen/native/ReplicationPadding.cpp",
1349"aten/src/ATen/native/Resize.cpp",
1350"aten/src/ATen/native/RowwisePrune.cpp",
1351"aten/src/ATen/native/SegmentReduce.cpp",
1352"aten/src/ATen/native/Scalar.cpp",
1353"aten/src/ATen/native/SobolEngineOps.cpp",
1354"aten/src/ATen/native/SobolEngineOpsUtils.cpp",
1355"aten/src/ATen/native/SoftMax.cpp",
1356"aten/src/ATen/native/Sorting.cpp",
1357"aten/src/ATen/native/SparseTensorUtils.cpp",
1358"aten/src/ATen/native/SpectralOps.cpp",
1359"aten/src/ATen/native/SummaryOps.cpp",
1360"aten/src/ATen/native/TensorAdvancedIndexing.cpp",
1361"aten/src/ATen/native/TensorCompare.cpp",
1362"aten/src/ATen/native/TensorConversions.cpp",
1363"aten/src/ATen/native/TensorFactories.cpp",
1364"aten/src/ATen/native/TensorIteratorReduce.cpp",
1365"aten/src/ATen/native/TensorProperties.cpp",
1366"aten/src/ATen/native/TensorShape.cpp",
1367"aten/src/ATen/native/TensorTransformations.cpp",
1368"aten/src/ATen/native/TestOps.cpp",
1369"aten/src/ATen/native/TriangularOps.cpp",
1370"aten/src/ATen/native/TypeProperties.cpp",
1371"aten/src/ATen/native/UnaryOps.cpp",
1372"aten/src/ATen/native/Unfold2d.cpp",
1373"aten/src/ATen/native/Unfold3d.cpp",
1374"aten/src/ATen/native/UnfoldBackward.cpp",
1375"aten/src/ATen/native/Unique.cpp",
1376# Low-level functions that can be directly referenced
1377# "aten/src/ATen/native/UpSample.cpp",
1378"aten/src/ATen/native/UpSampleBicubic2d.cpp",
1379"aten/src/ATen/native/UpSampleBilinear2d.cpp",
1380"aten/src/ATen/native/UpSampleLinear1d.cpp",
1381"aten/src/ATen/native/UpSampleNearest1d.cpp",
1382"aten/src/ATen/native/UpSampleNearest2d.cpp",
1383"aten/src/ATen/native/UpSampleNearest3d.cpp",
1384"aten/src/ATen/native/UpSampleTrilinear3d.cpp",
1385"aten/src/ATen/native/VariableMethodStubs.cpp",
1386"aten/src/ATen/native/WeightNorm.cpp",
1387"aten/src/ATen/native/group_norm.cpp",
1388"aten/src/ATen/native/layer_norm.cpp",
1389"aten/src/ATen/native/AmpKernels.cpp",
1390"aten/src/ATen/native/mkl/LinearAlgebra.cpp",
1391"aten/src/ATen/native/mkl/SparseBlasImpl.cpp",
1392"aten/src/ATen/native/mkl/SparseCsrLinearAlgebra.cpp",
1393"aten/src/ATen/native/mkl/SpectralOps.cpp",
1394"aten/src/ATen/native/nested/NestedTensorAliases.cpp",
1395"aten/src/ATen/native/nested/NestedTensorBackward.cpp",
1396"aten/src/ATen/native/nested/NestedTensorBinaryOps.cpp",
1397"aten/src/ATen/native/nested/NestedTensorFactories.cpp",
1398"aten/src/ATen/native/nested/NestedTensorMath.cpp",
1399"aten/src/ATen/native/nested/NestedTensorMatmul.cpp",
1400"aten/src/ATen/native/nested/NestedTensorTransformerFunctions.cpp",
1401"aten/src/ATen/native/nested/NestedTensorUnaryOps.cpp",
1402"aten/src/ATen/native/nested/NestedTensorUtils.cpp",
1403"aten/src/ATen/native/sparse/ParamUtils.cpp",
1404"aten/src/ATen/native/sparse/SoftMax.cpp",
1405"aten/src/ATen/native/sparse/SparseBlas.cpp",
1406"aten/src/ATen/native/sparse/SparseBlasImpl.cpp",
1407"aten/src/ATen/native/sparse/SparseMatMul.cpp",
1408"aten/src/ATen/native/sparse/SparseTensor.cpp",
1409"aten/src/ATen/native/sparse/SparseCsrTensor.cpp",
1410"aten/src/ATen/native/sparse/SparseTensorMath.cpp",
1411"aten/src/ATen/native/sparse/SparseUnaryOps.cpp",
1412"aten/src/ATen/native/sparse/SparseCsrTensorMath.cpp",
1413"aten/src/ATen/native/sparse/SparseFactories.cpp",
1414"aten/src/ATen/native/sparse/ValidateCompressedIndicesKernel.cpp",
1415"aten/src/ATen/native/sparse/SparseBinaryOpIntersectionKernel.cpp",
1416"aten/src/ATen/native/sparse/FlattenIndicesKernel.cpp",
1417"aten/src/ATen/native/transformers/attention.cpp",
1418"aten/src/ATen/native/transformers/sdp_utils_cpp.cpp",
1419"aten/src/ATen/native/transformers/transformer.cpp",
1420"aten/src/ATen/native/xnnpack/Activation.cpp",
1421"aten/src/ATen/native/xnnpack/ChannelShuffle.cpp",
1422"aten/src/ATen/native/xnnpack/Convolution.cpp",
1423"aten/src/ATen/native/xnnpack/AveragePooling.cpp",
1424"aten/src/ATen/native/xnnpack/Init.cpp",
1425"aten/src/ATen/native/xnnpack/Linear.cpp",
1426"aten/src/ATen/native/xnnpack/MaxPooling.cpp",
1427"aten/src/ATen/native/xnnpack/OpContext.cpp",
1428"aten/src/ATen/native/xnnpack/RegisterOpContextClass.cpp",
1429"aten/src/ATen/native/xnnpack/Shim.cpp",
1430"aten/src/ATen/native/FusedAdam.cpp",
1431"aten/src/ATen/native/FusedSGD.cpp",
1432"aten/src/ATen/native/FusedAdagrad.cpp",
1433# Files not in native, but depends on native symbols
1434# "aten/src/ATen/TensorIndexing.cpp",
1435"aten/src/ATen/TensorIterator.cpp",
1436]
1437
1438# 1. Files in ATen/native with a few exceptions
1439# TODO: move the exceptions to proper locations
1440# 2. The whole aten native source list includes the list with and without aten codegen process.
1441aten_native_source_list = sorted(aten_native_source_non_codegen_list + aten_native_source_codegen_list)
1442
1443# These are cpp files which need to go in the torch_cuda_cu library
1444# .cu files can be found via glob
1445aten_cuda_cu_source_list = [
1446"aten/src/ATen/cuda/CUDABlas.cpp",
1447"aten/src/ATen/cuda/CUDASparseBlas.cpp",
1448"aten/src/ATen/cuda/CublasHandlePool.cpp",
1449"aten/src/ATen/native/cuda/linalg/CudssHandlePool.cpp",
1450"aten/src/ATen/cuda/tunable/StreamTimer.cpp",
1451"aten/src/ATen/cuda/tunable/Tunable.cpp",
1452"aten/src/ATen/native/cuda/Activation.cpp",
1453"aten/src/ATen/native/cuda/LinearAlgebraStubs.cpp",
1454"aten/src/ATen/native/cuda/Blas.cpp",
1455"aten/src/ATen/native/cuda/Distributions.cpp",
1456"aten/src/ATen/native/cuda/Equal.cpp",
1457"aten/src/ATen/native/cuda/GridSampler.cpp",
1458"aten/src/ATen/native/cuda/IndexKernel.cpp",
1459"aten/src/ATen/native/cuda/MultiTensorApply.cpp",
1460"aten/src/ATen/native/cuda/ReduceOps.cpp",
1461"aten/src/ATen/native/cuda/ScanKernels.cpp",
1462"aten/src/ATen/native/cuda/Sort.cpp",
1463"aten/src/ATen/native/cuda/Sorting.cpp",
1464"aten/src/ATen/native/cuda/TensorModeKernel.cpp",
1465"aten/src/ATen/native/cuda/TensorShapeCUDA.cpp",
1466"aten/src/ATen/native/cuda/TensorTopK.cpp",
1467"aten/src/ATen/native/cuda/jit_utils.cpp",
1468"aten/src/ATen/native/nested/cuda/NestedTensorTransformerFunctions.cpp",
1469"aten/src/ATen/native/sparse/cuda/SparseBlas.cpp",
1470"aten/src/ATen/native/sparse/cuda/SparseBlasImpl.cpp",
1471"aten/src/ATen/native/sparse/cuda/SparseBlasLegacy.cpp",
1472"aten/src/ATen/native/sparse/cuda/SparseCUDABlas.cpp",
1473"aten/src/ATen/native/transformers/cuda/flash_attn/flash_api.cpp",
1474]
1475
1476# Files using thrust::sort_by_key need to be linked last
1477aten_cuda_with_sort_by_key_source_list = [
1478# empty_cuda is needed by torch_cuda_cpp
1479"aten/src/ATen/native/cuda/TensorFactories.cu",
1480]
1481
1482aten_cuda_cu_with_sort_by_key_source_list = [
1483"aten/src/ATen/native/cuda/Unique.cu",
1484]
1485
1486# Followings are source code for xnnpack delegate
1487
1488xnnpack_delegate_serializer_header = [
1489"torch/csrc/jit/backends/xnnpack/serialization/serializer.h",
1490]
1491
1492xnnpack_delegate_serializer_source_list = [
1493"torch/csrc/jit/backends/xnnpack/serialization/serializer.cpp",
1494]
1495
1496xnnpack_delegate_core_source_list = [
1497"torch/csrc/jit/backends/xnnpack/compiler/xnn_compiler.cpp",
1498]
1499
1500xnnpack_delegate_core_header = [
1501"torch/csrc/jit/backends/xnnpack/compiler/xnn_compiler.h",
1502"torch/csrc/jit/backends/xnnpack/executor/xnn_executor.h",
1503]
1504
1505xnnpack_backend_header = [
1506"torch/csrc/jit/backends/xnnpack/xnnpack_graph_builder.h",
1507] + xnnpack_delegate_core_header
1508
1509xnnpack_backend_source_list = [
1510"torch/csrc/jit/backends/xnnpack/compiler/xnn_compiler.cpp",
1511"torch/csrc/jit/backends/xnnpack/xnnpack_backend_lib.cpp",
1512"torch/csrc/jit/backends/xnnpack/xnnpack_backend_preprocess.cpp",
1513"torch/csrc/jit/backends/xnnpack/xnnpack_graph_builder.cpp",
1514] + xnnpack_delegate_core_source_list
1515