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): 20 return [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( 480 core_sources_common + 481 torch_unpickler_common + 482 core_sources_full + 483 core_trainer_sources + 484 inductor_core_resources + 485 libtorch_profiler_sources + 486 lazy_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/Ops.cpp", 500 "torch/csrc/distributed/c10d/ParamCommsUtils.cpp", 501 "torch/csrc/distributed/c10d/PrefixStore.cpp", 502 "torch/csrc/distributed/c10d/ProcessGroup.cpp", 503 "torch/csrc/distributed/c10d/ProcessGroupGloo.cpp", 504 "torch/csrc/distributed/c10d/ProcessGroupMPI.cpp", 505 "torch/csrc/distributed/c10d/ProcessGroupWrapper.cpp", 506 "torch/csrc/distributed/c10d/Store.cpp", 507 "torch/csrc/distributed/c10d/SymmetricMemory.cpp", 508 "torch/csrc/distributed/c10d/TCPStore.cpp", 509 "torch/csrc/distributed/c10d/TCPStoreBackend.cpp", 510 "torch/csrc/distributed/c10d/TCPStoreLibUvBackend.cpp", 511 "torch/csrc/distributed/c10d/Utils.cpp", 512 "torch/csrc/distributed/c10d/comm.cpp", 513 "torch/csrc/distributed/c10d/debug.cpp", 514 "torch/csrc/distributed/c10d/default_comm_hooks.cpp", 515 "torch/csrc/distributed/c10d/logger.cpp", 516 "torch/csrc/distributed/c10d/logging.cpp", 517 "torch/csrc/distributed/c10d/quantization/quantization.cpp", 518 "torch/csrc/distributed/c10d/reducer.cpp", 519 "torch/csrc/distributed/c10d/sequence_num.cpp", 520 "torch/csrc/distributed/c10d/socket.cpp", 521 "torch/csrc/distributed/c10d/Work.cpp", 522 "torch/csrc/distributed/c10d/control_plane/Handlers.cpp", 523 "torch/csrc/distributed/c10d/control_plane/WorkerServer.cpp", 524] 525 526# These files are only supported on Linux (and others) but not on Windows. 527libtorch_distributed_extra_sources = [ 528 "torch/csrc/distributed/autograd/autograd.cpp", 529 "torch/csrc/distributed/autograd/utils.cpp", 530 "torch/csrc/distributed/autograd/context/container.cpp", 531 "torch/csrc/distributed/autograd/context/context.cpp", 532 "torch/csrc/distributed/autograd/engine/dist_engine.cpp", 533 "torch/csrc/distributed/autograd/functions/recvrpc_backward.cpp", 534 "torch/csrc/distributed/autograd/functions/sendrpc_backward.cpp", 535 "torch/csrc/distributed/autograd/rpc_messages/autograd_metadata.cpp", 536 "torch/csrc/distributed/autograd/rpc_messages/propagate_gradients_req.cpp", 537 "torch/csrc/distributed/autograd/rpc_messages/propagate_gradients_resp.cpp", 538 "torch/csrc/distributed/autograd/rpc_messages/cleanup_autograd_context_req.cpp", 539 "torch/csrc/distributed/autograd/rpc_messages/cleanup_autograd_context_resp.cpp", 540 "torch/csrc/distributed/autograd/rpc_messages/rpc_with_autograd.cpp", 541 "torch/csrc/distributed/autograd/rpc_messages/rpc_with_profiling_req.cpp", 542 "torch/csrc/distributed/autograd/rpc_messages/rpc_with_profiling_resp.cpp", 543 "torch/csrc/distributed/autograd/rpc_messages/rref_backward_req.cpp", 544 "torch/csrc/distributed/autograd/rpc_messages/rref_backward_resp.cpp", 545 "torch/csrc/distributed/c10d/HashStore.cpp", 546 "torch/csrc/distributed/rpc/agent_utils.cpp", 547 "torch/csrc/distributed/rpc/message.cpp", 548 "torch/csrc/distributed/rpc/profiler/remote_profiler_manager.cpp", 549 "torch/csrc/distributed/rpc/profiler/server_process_global_profiler.cpp", 550 "torch/csrc/distributed/rpc/python_call.cpp", 551 "torch/csrc/distributed/rpc/python_remote_call.cpp", 552 "torch/csrc/distributed/rpc/python_resp.cpp", 553 "torch/csrc/distributed/rpc/request_callback.cpp", 554 "torch/csrc/distributed/rpc/request_callback_no_python.cpp", 555 "torch/csrc/distributed/rpc/rpc_agent.cpp", 556 "torch/csrc/distributed/rpc/rref_context.cpp", 557 "torch/csrc/distributed/rpc/rref_impl.cpp", 558 "torch/csrc/distributed/rpc/rref_proto.cpp", 559 "torch/csrc/distributed/rpc/script_call.cpp", 560 "torch/csrc/distributed/rpc/script_remote_call.cpp", 561 "torch/csrc/distributed/rpc/script_resp.cpp", 562 "torch/csrc/distributed/rpc/tensorpipe_agent.cpp", 563 "torch/csrc/distributed/rpc/tensorpipe_utils.cpp", 564 "torch/csrc/distributed/rpc/testing/faulty_tensorpipe_agent.cpp", 565 "torch/csrc/distributed/rpc/torchscript_functions.cpp", 566 "torch/csrc/distributed/rpc/types.cpp", 567 "torch/csrc/distributed/rpc/utils.cpp", 568] 569 570libtorch_distributed_sources = libtorch_distributed_base_sources + libtorch_distributed_extra_sources 571 572jit_sources_full = [ 573 "torch/csrc/jit/codegen/cuda/interface.cpp", 574 "torch/csrc/jit/passes/lower_graph.cpp", 575 "torch/csrc/jit/runtime/register_c10_ops.cpp", 576 "torch/csrc/jit/runtime/register_prim_ops.cpp", 577 "torch/csrc/jit/runtime/register_prim_ops_fulljit.cpp", 578 "torch/csrc/jit/runtime/register_special_ops.cpp", 579 "torch/csrc/jit/passes/remove_inplace_ops.cpp", 580 "torch/csrc/jit/passes/utils/check_alias_annotation.cpp", 581 "torch/csrc/jit/passes/autocast.cpp", 582] 583 584libtorch_core_jit_sources = sorted(jit_sources_full) 585 586torch_mobile_tracer_sources = [ 587 "torch/csrc/jit/mobile/model_tracer/tracer.cpp", 588 "torch/csrc/jit/mobile/model_tracer/TensorUtils.cpp", 589 "torch/csrc/jit/mobile/model_tracer/TracerRunner.cpp", 590 "torch/csrc/jit/mobile/model_tracer/MobileModelRunner.cpp", 591 "torch/csrc/jit/mobile/model_tracer/OperatorCallTracer.cpp", 592 "torch/csrc/jit/mobile/model_tracer/KernelDTypeTracer.cpp", 593 "torch/csrc/jit/mobile/model_tracer/CustomClassTracer.cpp", 594 "torch/csrc/jit/mobile/model_tracer/BuildFeatureTracer.cpp", 595] 596 597libtorch_lite_eager_symbolication = [ 598 "torch/csrc/jit/frontend/source_range.cpp", 599 "torch/csrc/jit/ir/scope.cpp", 600 "torch/csrc/jit/mobile/debug_info.cpp", 601 "torch/csrc/jit/serialization/callstack_debug_info_serialization.cpp", 602 "torch/csrc/jit/serialization/source_range_serialization.cpp", 603 # Later we can split serialization and deserialization logic 604 # to have better separation within build and only build relevant parts. 605 "torch/csrc/jit/serialization/pickle.cpp", 606 "torch/csrc/jit/serialization/pickler.cpp", 607 "torch/csrc/jit/serialization/unpickler.cpp", 608] 609 610# TODO: core_trainer_sources is not necessary for libtorch lite 611libtorch_lite_cmake_sources = sorted( 612 core_trainer_sources + 613 core_sources_common + 614 torch_unpickler_common + 615 torch_mobile_core, 616) 617 618libtorch_cmake_sources = libtorch_core_sources + libtorch_core_jit_sources 619 620libtorch_extra_sources = libtorch_core_jit_sources + [ 621 "torch/csrc/autograd/TraceTypeManual.cpp", 622 "torch/csrc/autograd/VariableTypeManual.cpp", 623 "torch/csrc/autograd/FunctionsManual.cpp", 624 "torch/csrc/jit/api/module_save.cpp", 625 "torch/csrc/jit/codegen/fuser/cpu/fused_kernel.cpp", 626 "torch/csrc/jit/mobile/compatibility/backport.cpp", 627 "torch/csrc/jit/mobile/compatibility/backport_manager.cpp", 628 "torch/csrc/jit/mobile/compatibility/model_compatibility.cpp", 629 # To be included for eager symbolication in lite interpreter 630 # when it is built in libtorch 631 "torch/csrc/jit/mobile/debug_info.cpp", 632 "torch/csrc/jit/mobile/function.cpp", 633 "torch/csrc/jit/mobile/flatbuffer_loader.cpp", 634 "torch/csrc/jit/mobile/import.cpp", 635 "torch/csrc/jit/mobile/import_data.cpp", 636 "torch/csrc/jit/mobile/interpreter.cpp", 637 "torch/csrc/jit/mobile/module.cpp", 638 "torch/csrc/jit/mobile/observer.cpp", 639 "torch/csrc/jit/mobile/parse_bytecode.cpp", 640 "torch/csrc/jit/mobile/parse_operators.cpp", 641 "torch/csrc/jit/mobile/quantization.cpp", 642 "torch/csrc/jit/mobile/train/export_data.cpp", 643 "torch/csrc/jit/mobile/train/optim/sgd.cpp", 644 "torch/csrc/jit/mobile/train/random.cpp", 645 "torch/csrc/jit/mobile/train/sequential.cpp", 646 "torch/csrc/jit/mobile/upgrader_mobile.cpp", 647 "torch/csrc/jit/serialization/onnx.cpp", 648 "torch/csrc/jit/serialization/export.cpp", 649 "torch/csrc/jit/serialization/export_bytecode.cpp", 650 "torch/csrc/jit/serialization/export_module.cpp", 651 "torch/csrc/jit/serialization/flatbuffer_serializer.cpp", 652 "torch/csrc/utils/byte_order.cpp", 653 "torch/csrc/utils/out_types.cpp", 654] 655 656def libtorch_sources(gencode_pattern = ":generate-code[{}]"): 657 return ( 658 libtorch_generated_sources(gencode_pattern) + libtorch_core_sources + libtorch_distributed_sources + libtorch_extra_sources 659 ) 660 661libtorch_cuda_core_sources = [ 662 "torch/csrc/CudaIPCTypes.cpp", 663 "torch/csrc/cuda/comm.cpp", 664 "torch/csrc/cuda/memory_snapshot.cpp", 665 "torch/csrc/cuda/CUDAPluggableAllocator.cpp", 666 "torch/csrc/inductor/aoti_runner/model_container_runner_cuda.cpp", 667 "torch/csrc/inductor/aoti_torch/shim_cuda.cpp", 668 "torch/csrc/jit/codegen/fuser/cuda/fused_kernel.cpp", 669 "torch/csrc/profiler/stubs/cuda.cpp", 670 "torch/csrc/autograd/functions/comm.cpp", 671 "torch/csrc/jit/passes/frozen_conv_add_relu_fusion_cuda.cpp", 672 "torch/csrc/jit/tensorexpr/cuda_codegen.cpp", 673 "torch/csrc/jit/runtime/register_cuda_ops.cpp", 674] 675 676# These files are the only ones that are supported on Windows. 677libtorch_cuda_distributed_base_sources = [ 678 "torch/csrc/distributed/c10d/reducer_cuda.cpp", 679] 680 681# These files are only supported on Linux (and others) but not on Windows. 682libtorch_cuda_distributed_extra_sources = [ 683 "torch/csrc/distributed/c10d/CudaDMAConnectivity.cpp", 684 "torch/csrc/distributed/c10d/NCCLUtils.cpp", 685 "torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp", 686 "torch/csrc/distributed/c10d/ProcessGroupUCC.cpp", 687 "torch/csrc/distributed/c10d/UCCTracing.cpp", 688 "torch/csrc/distributed/c10d/UCCUtils.cpp", 689 "torch/csrc/distributed/c10d/intra_node_comm.cpp", 690 "torch/csrc/distributed/c10d/intra_node_comm.cu", 691 "torch/csrc/distributed/c10d/CUDASymmetricMemory.cu", 692 "torch/csrc/distributed/c10d/CUDASymmetricMemoryOps.cu", 693 "torch/csrc/distributed/c10d/NanCheck.cu", 694 "torch/csrc/distributed/rpc/tensorpipe_cuda.cpp", 695 "torch/csrc/distributed/c10d/quantization/quantization_gpu.cu", 696] 697 698libtorch_cuda_distributed_sources = libtorch_cuda_distributed_base_sources + libtorch_cuda_distributed_extra_sources 699 700libtorch_cuda_sources = libtorch_cuda_core_sources + libtorch_cuda_distributed_sources + [ 701 "torch/csrc/cuda/nccl.cpp", 702] 703 704torch_cpp_srcs = [ 705 "torch/csrc/api/src/cuda.cpp", # this just forwards stuff, no real CUDA 706 "torch/csrc/api/src/data/datasets/mnist.cpp", 707 "torch/csrc/api/src/data/samplers/distributed.cpp", 708 "torch/csrc/api/src/data/samplers/random.cpp", 709 "torch/csrc/api/src/data/samplers/sequential.cpp", 710 "torch/csrc/api/src/data/samplers/stream.cpp", 711 "torch/csrc/api/src/enum.cpp", 712 "torch/csrc/api/src/imethod.cpp", 713 "torch/csrc/api/src/jit.cpp", 714 "torch/csrc/api/src/mps.cpp", 715 "torch/csrc/api/src/serialize.cpp", 716 "torch/csrc/api/src/nn/init.cpp", 717 "torch/csrc/api/src/nn/module.cpp", 718 "torch/csrc/api/src/nn/modules/_functions.cpp", 719 "torch/csrc/api/src/nn/modules/activation.cpp", 720 "torch/csrc/api/src/nn/modules/adaptive.cpp", 721 "torch/csrc/api/src/nn/modules/batchnorm.cpp", 722 "torch/csrc/api/src/nn/modules/normalization.cpp", 723 "torch/csrc/api/src/nn/modules/instancenorm.cpp", 724 "torch/csrc/api/src/nn/modules/conv.cpp", 725 "torch/csrc/api/src/nn/modules/dropout.cpp", 726 "torch/csrc/api/src/nn/modules/distance.cpp", 727 "torch/csrc/api/src/nn/modules/embedding.cpp", 728 "torch/csrc/api/src/nn/modules/fold.cpp", 729 "torch/csrc/api/src/nn/modules/linear.cpp", 730 "torch/csrc/api/src/nn/modules/loss.cpp", 731 "torch/csrc/api/src/nn/modules/padding.cpp", 732 "torch/csrc/api/src/nn/modules/pixelshuffle.cpp", 733 "torch/csrc/api/src/nn/modules/pooling.cpp", 734 "torch/csrc/api/src/nn/modules/rnn.cpp", 735 "torch/csrc/api/src/nn/modules/upsampling.cpp", 736 "torch/csrc/api/src/nn/modules/transformer.cpp", 737 "torch/csrc/api/src/nn/modules/container/functional.cpp", 738 "torch/csrc/api/src/nn/options/activation.cpp", 739 "torch/csrc/api/src/nn/options/adaptive.cpp", 740 "torch/csrc/api/src/nn/options/batchnorm.cpp", 741 "torch/csrc/api/src/nn/options/conv.cpp", 742 "torch/csrc/api/src/nn/options/dropout.cpp", 743 "torch/csrc/api/src/nn/options/instancenorm.cpp", 744 "torch/csrc/api/src/nn/options/linear.cpp", 745 "torch/csrc/api/src/nn/options/normalization.cpp", 746 "torch/csrc/api/src/nn/options/embedding.cpp", 747 "torch/csrc/api/src/nn/options/padding.cpp", 748 "torch/csrc/api/src/nn/options/pooling.cpp", 749 "torch/csrc/api/src/nn/options/rnn.cpp", 750 "torch/csrc/api/src/nn/options/vision.cpp", 751 "torch/csrc/api/src/nn/options/transformer.cpp", 752 "torch/csrc/api/src/optim/adagrad.cpp", 753 "torch/csrc/api/src/optim/adam.cpp", 754 "torch/csrc/api/src/optim/adamw.cpp", 755 "torch/csrc/api/src/optim/lbfgs.cpp", 756 "torch/csrc/api/src/optim/optimizer.cpp", 757 "torch/csrc/api/src/optim/rmsprop.cpp", 758 "torch/csrc/api/src/optim/serialize.cpp", 759 "torch/csrc/api/src/optim/sgd.cpp", 760 "torch/csrc/api/src/optim/schedulers/lr_scheduler.cpp", 761 "torch/csrc/api/src/optim/schedulers/reduce_on_plateau_scheduler.cpp", 762 "torch/csrc/api/src/optim/schedulers/step_lr.cpp", 763 "torch/csrc/api/src/serialize/input-archive.cpp", 764 "torch/csrc/api/src/serialize/output-archive.cpp", 765 "torch/csrc/api/src/xpu.cpp", 766] 767 768libtorch_python_cuda_core_sources = [ 769 "torch/csrc/cuda/Event.cpp", 770 "torch/csrc/cuda/Module.cpp", 771 "torch/csrc/cuda/python_comm.cpp", 772 "torch/csrc/cuda/Stream.cpp", 773 "torch/csrc/cuda/Graph.cpp", 774 "torch/csrc/cuda/MemPool.cpp", 775 "torch/csrc/cuda/shared/cudart.cpp", 776 "torch/csrc/cuda/shared/nvtx.cpp", 777 "torch/csrc/cuda/utils.cpp", 778 "torch/csrc/cuda/GdsFile.cpp", 779] 780 781libtorch_python_cuda_sources = libtorch_python_cuda_core_sources + [ 782 "torch/csrc/cuda/python_nccl.cpp", 783 "torch/csrc/cuda/shared/cudnn.cpp", 784 "torch/csrc/cuda/shared/cusparselt.cpp", 785 "torch/csrc/cuda/Tensor.cpp", 786] 787 788libtorch_python_xpu_sources = [ 789 "torch/csrc/xpu/Event.cpp", 790 "torch/csrc/xpu/Module.cpp", 791 "torch/csrc/xpu/Stream.cpp", 792] 793 794libtorch_python_core_sources = [ 795 "torch/csrc/DataLoader.cpp", 796 "torch/csrc/Device.cpp", 797 "torch/csrc/Dtype.cpp", 798 "torch/csrc/DynamicTypes.cpp", 799 "torch/csrc/Exceptions.cpp", 800 "torch/csrc/Generator.cpp", 801 "torch/csrc/Layout.cpp", 802 "torch/csrc/MemoryFormat.cpp", 803 "torch/csrc/QScheme.cpp", 804 "torch/csrc/Module.cpp", 805 "torch/csrc/PyInterpreter.cpp", 806 "torch/csrc/python_dimname.cpp", 807 "torch/csrc/Size.cpp", 808 "torch/csrc/Storage.cpp", 809 "torch/csrc/StorageMethods.cpp", 810 "torch/csrc/StorageSharing.cpp", 811 "torch/csrc/Stream.cpp", 812 "torch/csrc/Event.cpp", 813 "torch/csrc/TypeInfo.cpp", 814 "torch/csrc/api/src/python/init.cpp", 815 "torch/csrc/autograd/functions/init.cpp", 816 "torch/csrc/autograd/init.cpp", 817 "torch/csrc/autograd/profiler_python.cpp", 818 "torch/csrc/autograd/python_anomaly_mode.cpp", 819 "torch/csrc/autograd/python_saved_variable_hooks.cpp", 820 "torch/csrc/autograd/python_cpp_function.cpp", 821 "torch/csrc/autograd/python_engine.cpp", 822 "torch/csrc/autograd/python_function.cpp", 823 "torch/csrc/autograd/python_hook.cpp", 824 "torch/csrc/autograd/python_legacy_variable.cpp", 825 "torch/csrc/autograd/python_nested_functions_manual.cpp", 826 "torch/csrc/autograd/python_torch_functions_manual.cpp", 827 "torch/csrc/autograd/python_variable.cpp", 828 "torch/csrc/autograd/python_variable_indexing.cpp", 829 "torch/csrc/dynamo/python_compiled_autograd.cpp", 830 "torch/csrc/dynamo/cache_entry.cpp", 831 "torch/csrc/dynamo/cpp_shim.cpp", 832 "torch/csrc/dynamo/cpython_defs.c", 833 "torch/csrc/dynamo/eval_frame.c", 834 "torch/csrc/dynamo/extra_state.cpp", 835 "torch/csrc/dynamo/framelocals_mapping.cpp", 836 "torch/csrc/dynamo/guards.cpp", 837 "torch/csrc/dynamo/utils.cpp", 838 "torch/csrc/dynamo/init.cpp", 839 "torch/csrc/functorch/init.cpp", 840 "torch/csrc/fx/node.cpp", 841 "torch/csrc/mps/Module.cpp", 842 "torch/csrc/mtia/Module.cpp", 843 "torch/csrc/inductor/aoti_runner/pybind.cpp", 844 "torch/csrc/inductor/aoti_eager/kernel_holder.cpp", 845 "torch/csrc/inductor/aoti_eager/kernel_meta_info.cpp", 846 "torch/csrc/inductor/resize_storage_bytes.cpp", 847 "torch/csrc/jit/backends/backend_init.cpp", 848 "torch/csrc/jit/python/init.cpp", 849 "torch/csrc/jit/passes/onnx.cpp", 850 "torch/csrc/jit/passes/onnx/cast_all_constant_to_floating.cpp", 851 "torch/csrc/jit/passes/onnx/deduplicate_initializers.cpp", 852 "torch/csrc/jit/passes/onnx/eval_peephole.cpp", 853 "torch/csrc/jit/passes/onnx/constant_fold.cpp", 854 "torch/csrc/jit/passes/onnx/constant_map.cpp", 855 "torch/csrc/jit/passes/onnx/eliminate_unused_items.cpp", 856 "torch/csrc/jit/passes/onnx/fixup_onnx_controlflow.cpp", 857 "torch/csrc/jit/passes/onnx/list_model_parameters.cpp", 858 "torch/csrc/jit/passes/onnx/function_substitution.cpp", 859 "torch/csrc/jit/passes/onnx/helper.cpp", 860 "torch/csrc/jit/passes/onnx/peephole.cpp", 861 "torch/csrc/jit/passes/onnx/preprocess_for_onnx.cpp", 862 "torch/csrc/jit/passes/onnx/prepare_division_for_onnx.cpp", 863 "torch/csrc/jit/passes/onnx/scalar_type_analysis.cpp", 864 "torch/csrc/jit/passes/onnx/unpack_quantized_weights.cpp", 865 "torch/csrc/jit/passes/onnx/remove_inplace_ops_for_onnx.cpp", 866 "torch/csrc/jit/passes/onnx/shape_type_inference.cpp", 867 "torch/csrc/jit/passes/onnx/function_extraction.cpp", 868 "torch/csrc/jit/passes/onnx/onnx_log.cpp", 869 "torch/csrc/jit/passes/onnx/naming.cpp", 870 "torch/csrc/jit/python/pybind_utils.cpp", 871 "torch/csrc/jit/passes/onnx/pattern_conversion/autograd_function_process.cpp", 872 "torch/csrc/jit/passes/onnx/pattern_conversion/common.cpp", 873 "torch/csrc/jit/passes/onnx/pattern_conversion/pattern_encapsulation.cpp", 874 "torch/csrc/jit/passes/onnx/pattern_conversion/pattern_conversion.cpp", 875 "torch/csrc/jit/python/python_arg_flatten.cpp", 876 "torch/csrc/jit/python/python_custom_class.cpp", 877 "torch/csrc/jit/python/python_dict.cpp", 878 "torch/csrc/jit/python/python_interpreter.cpp", 879 "torch/csrc/jit/python/python_ir.cpp", 880 "torch/csrc/jit/python/python_list.cpp", 881 "torch/csrc/jit/python/python_tracer.cpp", 882 "torch/csrc/jit/python/script_init.cpp", 883 "torch/csrc/jit/frontend/concrete_module_type.cpp", 884 "torch/csrc/jit/frontend/tree_views.cpp", 885 "torch/csrc/jit/python/python_sugared_value.cpp", 886 "torch/csrc/jit/python/python_tree_views.cpp", 887 "torch/csrc/jit/runtime/static/init.cpp", 888 "torch/csrc/jit/tensorexpr/tensorexpr_init.cpp", 889 "torch/csrc/monitor/python_init.cpp", 890 "torch/csrc/multiprocessing/init.cpp", 891 "torch/csrc/onnx/init.cpp", 892 "torch/csrc/profiler/python/init.cpp", 893 "torch/csrc/profiler/python/combined_traceback.cpp", 894 "torch/csrc/serialization.cpp", 895 "torch/csrc/tensor/python_tensor.cpp", 896 "torch/csrc/utils/init.cpp", 897 "torch/csrc/utils/throughput_benchmark.cpp", 898 "torch/csrc/utils.cpp", 899 "torch/csrc/utils/device_lazy_init.cpp", 900 "torch/csrc/utils/invalid_arguments.cpp", 901 "torch/csrc/utils/nested.cpp", 902 "torch/csrc/utils/object_ptr.cpp", 903 "torch/csrc/utils/python_arg_parser.cpp", 904 "torch/csrc/utils/python_dispatch.cpp", 905 "torch/csrc/utils/python_symnode.cpp", 906 "torch/csrc/utils/pybind.cpp", 907 "torch/csrc/utils/pyobject_preservation.cpp", 908 "torch/csrc/utils/structseq.cpp", 909 "torch/csrc/utils/tensor_apply.cpp", 910 "torch/csrc/utils/tensor_dtypes.cpp", 911 "torch/csrc/utils/tensor_layouts.cpp", 912 "torch/csrc/utils/tensor_memoryformats.cpp", 913 "torch/csrc/utils/tensor_qschemes.cpp", 914 "torch/csrc/utils/tensor_list.cpp", 915 "torch/csrc/utils/tensor_new.cpp", 916 "torch/csrc/utils/tensor_numpy.cpp", 917 "torch/csrc/utils/tensor_types.cpp", 918 "torch/csrc/utils/disable_torch_function.cpp", 919 "torch/csrc/utils/verbose.cpp", 920 "torch/csrc/cpu/Module.cpp", 921 "torch/csrc/instruction_counter/Module.cpp", 922] + lazy_tensor_core_python_sources 923 924libtorch_python_distributed_core_sources = [ 925 "torch/csrc/distributed/c10d/init.cpp", 926 "torch/csrc/distributed/c10d/python_comm_hook.cpp", 927] 928 929libtorch_python_distributed_sources = libtorch_python_distributed_core_sources + [ 930 "torch/csrc/distributed/autograd/init.cpp", 931 "torch/csrc/distributed/rpc/init.cpp", 932 "torch/csrc/distributed/rpc/py_rref.cpp", 933 "torch/csrc/distributed/rpc/python_functions.cpp", 934 "torch/csrc/distributed/rpc/python_rpc_handler.cpp", 935 "torch/csrc/distributed/rpc/request_callback_impl.cpp", 936 "torch/csrc/distributed/rpc/testing/init.cpp", 937 "torch/csrc/distributed/rpc/unpickled_python_call.cpp", 938 "torch/csrc/distributed/rpc/unpickled_python_remote_call.cpp", 939 "torch/csrc/jit/runtime/register_distributed_ops.cpp", 940 "torch/csrc/distributed/c10d/control_plane/PythonHandlers.cpp", 941] 942 943def glob_libtorch_python_sources(gencode_pattern = ":generate-code[{}]"): 944 _libtorch_python_sources = [gencode_pattern.format(name) for name in [ 945 "torch/csrc/autograd/generated/python_functions_0.cpp", 946 "torch/csrc/autograd/generated/python_functions_1.cpp", 947 "torch/csrc/autograd/generated/python_functions_2.cpp", 948 "torch/csrc/autograd/generated/python_functions_3.cpp", 949 "torch/csrc/autograd/generated/python_functions_4.cpp", 950 "torch/csrc/autograd/generated/python_nested_functions.cpp", 951 "torch/csrc/autograd/generated/python_nn_functions.cpp", 952 "torch/csrc/autograd/generated/python_fft_functions.cpp", 953 "torch/csrc/autograd/generated/python_linalg_functions.cpp", 954 "torch/csrc/autograd/generated/python_enum_tag.cpp", 955 "torch/csrc/autograd/generated/python_return_types.cpp", 956 "torch/csrc/autograd/generated/python_sparse_functions.cpp", 957 "torch/csrc/autograd/generated/python_special_functions.cpp", 958 "torch/csrc/autograd/generated/python_torch_functions_0.cpp", 959 "torch/csrc/autograd/generated/python_torch_functions_1.cpp", 960 "torch/csrc/autograd/generated/python_torch_functions_2.cpp", 961 "torch/csrc/autograd/generated/python_variable_methods.cpp", 962 ]] 963 964 _libtorch_python_sources.extend(libtorch_python_core_sources) 965 _libtorch_python_sources.extend(libtorch_python_distributed_sources) 966 967 return _libtorch_python_sources 968 969# List of non-globed source used to build ATen core internally 970aten_cpu_non_globed_sources = [ 971 "aten/src/ATen/detail/CUDAHooksInterface.cpp", 972 "aten/src/ATen/detail/HIPHooksInterface.cpp", 973 "aten/src/ATen/detail/MPSHooksInterface.cpp", 974 "aten/src/ATen/detail/MAIAHooksInterface.cpp", 975 "aten/src/ATen/detail/PrivateUse1HooksInterface.cpp", 976 "aten/src/ATen/detail/XPUHooksInterface.cpp", 977 "aten/src/ATen/detail/MTIAHooksInterface.cpp", 978 "aten/src/ATen/detail/IPUHooksInterface.cpp", 979 "aten/src/ATen/record_function.cpp", 980 "aten/src/ATen/Dispatch.cpp", 981 "aten/src/ATen/SequenceNumber.cpp", 982] 983 984aten_cpu_non_globed_headers = [ 985 "aten/src/ATen/CPUGeneratorImpl.h", 986 "aten/src/ATen/NumericUtils.h", 987 "aten/src/ATen/detail/AcceleratorHooksInterface.h", 988 "aten/src/ATen/detail/CUDAHooksInterface.h", 989 "aten/src/ATen/detail/MPSHooksInterface.h", 990 "aten/src/ATen/detail/HIPHooksInterface.h", 991 "aten/src/ATen/detail/MAIAHooksInterface.h", 992 "aten/src/ATen/detail/PrivateUse1HooksInterface.h", 993 "aten/src/ATen/detail/XPUHooksInterface.h", 994 "aten/src/ATen/detail/MTIAHooksInterface.h", 995 "aten/src/ATen/detail/IPUHooksInterface.h", 996] 997 998aten_cpu_source_non_codegen_list = [ 999 "aten/src/ATen/AccumulateType.cpp", 1000 "aten/src/ATen/LegacyBatchedTensorImpl.cpp", 1001 "aten/src/ATen/CPUGeneratorImpl.cpp", 1002 "aten/src/ATen/DeviceAccelerator.cpp", 1003 "aten/src/ATen/Context.cpp", 1004 "aten/src/ATen/DLConvertor.cpp", 1005 "aten/src/ATen/EmptyTensor.cpp", 1006 "aten/src/ATen/ExpandUtils.cpp", 1007 "aten/src/ATen/CachedTensorUtils.cpp", 1008 "aten/src/ATen/FunctionalInverses.cpp", 1009 "aten/src/ATen/FunctionalStorageImpl.cpp", 1010 "aten/src/ATen/FunctionalTensorWrapper.cpp", 1011 "aten/src/ATen/FunctionalizeFallbackKernel.cpp", 1012 "aten/src/ATen/MemoryOverlap.cpp", 1013 "aten/src/ATen/MapAllocator.cpp", 1014 "aten/src/ATen/NamedTensorUtils.cpp", 1015 "aten/src/ATen/NestedTensorImpl.cpp", 1016 "aten/src/ATen/ParallelCommon.cpp", 1017 "aten/src/ATen/ParallelNative.cpp", 1018 "aten/src/ATen/ParallelOpenMP.cpp", 1019 "aten/src/ATen/ParallelThreadPoolNative.cpp", 1020 "aten/src/ATen/PythonTorchFunctionTLS.cpp", 1021 "aten/src/ATen/ThreadLocalPythonObjects.cpp", 1022 "aten/src/ATen/ScalarOps.cpp", 1023 "aten/src/ATen/SparseTensorImpl.cpp", 1024 "aten/src/ATen/SparseCsrTensorImpl.cpp", 1025 "aten/src/ATen/TensorGeometry.cpp", 1026 "aten/src/ATen/TensorIndexing.cpp", 1027 "aten/src/ATen/TensorMeta.cpp", 1028 "aten/src/ATen/TensorNames.cpp", 1029 "aten/src/ATen/TensorUtils.cpp", 1030 "aten/src/ATen/ThreadLocalState.cpp", 1031 "aten/src/ATen/FuncTorchTLS.cpp", 1032 "aten/src/ATen/Utils.cpp", 1033 "aten/src/ATen/Version.cpp", 1034 "aten/src/ATen/LegacyVmapMode.cpp", 1035 "aten/src/ATen/LegacyVmapTransforms.cpp", 1036 "aten/src/ATen/core/BackendSelectFallbackKernel.cpp", 1037 "aten/src/ATen/core/DeprecatedTypeProperties.cpp", 1038 "aten/src/ATen/core/DeprecatedTypePropertiesRegistry.cpp", 1039 "aten/src/ATen/core/Dict.cpp", 1040 "aten/src/ATen/core/Dimname.cpp", 1041 "aten/src/ATen/core/Formatting.cpp", 1042 "aten/src/ATen/core/function_schema.cpp", 1043 "aten/src/ATen/core/Generator.cpp", 1044 "aten/src/ATen/core/PythonOpRegistrationTrampoline.cpp", 1045 "aten/src/ATen/core/List.cpp", 1046 "aten/src/ATen/core/NamedTensor.cpp", 1047 "aten/src/ATen/core/Tensor.cpp", 1048 "aten/src/ATen/core/VariableFallbackKernel.cpp", 1049 "aten/src/ATen/core/VariableHooksInterface.cpp", 1050 "aten/src/ATen/core/Vitals.cpp", 1051 "aten/src/ATen/core/boxing/KernelFunction.cpp", 1052 "aten/src/ATen/core/custom_class.cpp", 1053 "aten/src/ATen/core/dispatch/DispatchKeyExtractor.cpp", 1054 "aten/src/ATen/core/dispatch/Dispatcher.cpp", 1055 "aten/src/ATen/core/dispatch/ObservedOperators.cpp", 1056 "aten/src/ATen/core/dispatch/OperatorEntry.cpp", 1057 "aten/src/ATen/core/interned_strings.cpp", 1058 "aten/src/ATen/core/ivalue.cpp", 1059 "aten/src/ATen/core/library.cpp", 1060 "aten/src/ATen/core/op_registration/infer_schema.cpp", 1061 "aten/src/ATen/core/op_registration/op_registration.cpp", 1062 "aten/src/ATen/core/operator_name.cpp", 1063 "aten/src/ATen/core/TorchDispatchUtils.cpp", 1064 "aten/src/ATen/core/register_symbols.cpp", 1065 "aten/src/ATen/core/NestedIntSymNodeImpl.cpp", 1066 "aten/src/ATen/core/class_type.cpp", 1067 "aten/src/ATen/core/type.cpp", 1068 "aten/src/ATen/core/type_factory.cpp", 1069 "aten/src/ATen/core/dynamic_type.cpp", 1070 "aten/src/ATen/core/tensor_type.cpp", 1071 "aten/src/ATen/core/union_type.cpp", 1072 "aten/src/ATen/cpu/FlushDenormal.cpp", 1073 "aten/src/ATen/detail/CPUGuardImpl.cpp", 1074 "aten/src/ATen/metal/Context.cpp", 1075 "aten/src/ATen/native/AutogradComposite.cpp", 1076 "aten/src/ATen/native/ComparisonUtils.cpp", 1077 "aten/src/ATen/native/DispatchStub.cpp", 1078 "aten/src/ATen/native/UpSample.cpp", 1079 "aten/src/ATen/native/mkldnn/BinaryOps.cpp", 1080 "aten/src/ATen/native/mkldnn/Conv.cpp", 1081 "aten/src/ATen/native/mkldnn/ConvPrepack.cpp", 1082 "aten/src/ATen/native/mkldnn/Copy.cpp", 1083 "aten/src/ATen/native/mkldnn/Gelu.cpp", 1084 "aten/src/ATen/native/mkldnn/IDeepRegistration.cpp", 1085 "aten/src/ATen/native/mkldnn/Linear.cpp", 1086 "aten/src/ATen/native/mkldnn/MKLDNNCommon.cpp", 1087 "aten/src/ATen/native/mkldnn/MKLDNNConversions.cpp", 1088 "aten/src/ATen/native/mkldnn/MkldnnTensorMath.cpp", 1089 "aten/src/ATen/native/mkldnn/Normalization.cpp", 1090 "aten/src/ATen/native/mkldnn/OpContext.cpp", 1091 "aten/src/ATen/native/mkldnn/Pooling.cpp", 1092 "aten/src/ATen/native/mkldnn/Prelu.cpp", 1093 "aten/src/ATen/native/mkldnn/RegisterMkldnnOpContextClass.cpp", 1094 "aten/src/ATen/native/mkldnn/Relu.cpp", 1095 "aten/src/ATen/native/mkldnn/RNN.cpp", 1096 "aten/src/ATen/native/mkldnn/SoftMax.cpp", 1097 "aten/src/ATen/native/mkldnn/TensorFactories.cpp", 1098 "aten/src/ATen/native/mkldnn/TensorShape.cpp", 1099 "aten/src/ATen/native/mkldnn/UnaryOps.cpp", 1100 "aten/src/ATen/native/mkldnn/Utils.cpp", 1101 "aten/src/ATen/native/mkldnn/Matmul.cpp", 1102 "aten/src/ATen/native/quantized/cpu/init_qnnpack.cpp", 1103 # This is moved to aten_cpu because some of the custom ops use empty_with_tail_padding 1104 # which was available only within aten_native_cpu. Ideally the right fix is to make 1105 # empty_with_tail_padding into an op and use dispatcher with it. But exposing it as an op 1106 # has limited use and hence does not seem to really make sense. 1107 "aten/src/ATen/native/utils/Factory.cpp", 1108 "aten/src/ATen/SavedTensorHooks.cpp", 1109 "aten/src/ATen/vulkan/Context.cpp", 1110 "aten/src/ATen/native/prim_native_functions.cpp", 1111 "aten/src/ATen/native/verbose_wrapper.cpp", 1112 "aten/src/ATen/cpu/Utils.cpp", 1113] + aten_cpu_non_globed_sources 1114 1115aten_cpu_source_codegen_list = [ 1116 "aten/src/ATen/native/cpu/AdaptiveAvgPoolKernel.cpp", 1117 "aten/src/ATen/native/cpu/AdaptiveMaxPoolKernel.cpp", 1118] 1119 1120aten_ufunc_headers = [ 1121 "aten/src/ATen/native/ufunc/add.h", 1122] 1123 1124# When building lite interpreter in OSS, "aten/src/ATen/native/cpu/AdaptiveAvgPoolKernel.cpp" will go through 1125# codegen process. The codegen version of this file, like Activation.cpp.DEFAULT.cpp, will be included 1126# in ${cpu_kernel_cpp} in aten/src/ATen/CMakeLists.txt. As a result, in aten/src/ATen/CMakeLists.txt, 1127# only aten_cpu_source_non_codegen_list need to be added to ${all_cpu_cpp}. 1128aten_cpu_source_list = sorted(aten_cpu_source_non_codegen_list + aten_cpu_source_codegen_list) 1129 1130# Same as ${aten_cpu_source_codegen_list}, this list will go through aten codegen, and be included in 1131# ${cpu_kernel_cpp} in aten/src/ATen/CMakeLists.txt. 1132aten_native_source_codegen_list = [ 1133 "aten/src/ATen/native/cpu/Activation.cpp", 1134 "aten/src/ATen/native/cpu/AvgPoolKernel.cpp", 1135 "aten/src/ATen/native/cpu/BinaryOpsKernel.cpp", 1136 "aten/src/ATen/native/cpu/BlasKernel.cpp", 1137 "aten/src/ATen/native/cpu/CatKernel.cpp", 1138 "aten/src/ATen/native/cpu/ChannelShuffleKernel.cpp", 1139 "aten/src/ATen/native/cpu/ComplexKernel.cpp", 1140 "aten/src/ATen/native/cpu/CopyKernel.cpp", 1141 "aten/src/ATen/native/cpu/CrossKernel.cpp", 1142 "aten/src/ATen/native/cpu/DepthwiseConvKernel.cpp", 1143 "aten/src/ATen/native/cpu/DistanceOpsKernel.cpp", 1144 "aten/src/ATen/native/cpu/DistributionKernels.cpp", 1145 "aten/src/ATen/native/cpu/FlashAttentionKernel.cpp", 1146 "aten/src/ATen/native/cpu/FillKernel.cpp", 1147 "aten/src/ATen/native/cpu/FunctionOfAMatrixUtilsKernel.cpp", 1148 "aten/src/ATen/native/cpu/GridSamplerKernel.cpp", 1149 "aten/src/ATen/native/cpu/HistogramKernel.cpp", 1150 "aten/src/ATen/native/cpu/IndexKernel.cpp", 1151 "aten/src/ATen/native/cpu/LerpKernel.cpp", 1152 "aten/src/ATen/native/cpu/LinearAlgebraKernel.cpp", 1153 "aten/src/ATen/native/cpu/MaxPoolKernel.cpp", 1154 "aten/src/ATen/native/cpu/MaxPooling.cpp", 1155 "aten/src/ATen/native/cpu/MaxUnpoolKernel.cpp", 1156 "aten/src/ATen/native/cpu/MultinomialKernel.cpp", 1157 "aten/src/ATen/native/cpu/NativeMultiheadAttnKernel.cpp", 1158 "aten/src/ATen/native/cpu/PaddingKernel.cpp", 1159 "aten/src/ATen/native/cpu/PixelShuffleKernel.cpp", 1160 "aten/src/ATen/native/cpu/PointwiseOpsKernel.cpp", 1161 "aten/src/ATen/native/cpu/PowKernel.cpp", 1162 "aten/src/ATen/native/cpu/RangeFactoriesKernel.cpp", 1163 "aten/src/ATen/native/cpu/ReduceAllOpsKernel.cpp", 1164 "aten/src/ATen/native/cpu/ReduceOpsKernel.cpp", 1165 "aten/src/ATen/native/cpu/RenormKernel.cpp", 1166 "aten/src/ATen/native/cpu/ScatterGatherKernel.cpp", 1167 "aten/src/ATen/native/cpu/SoftMaxKernel.cpp", 1168 "aten/src/ATen/native/cpu/SortingKernel.cpp", 1169 "aten/src/ATen/native/cpu/StackKernel.cpp", 1170 "aten/src/ATen/native/cpu/SumKernel.cpp", 1171 "aten/src/ATen/native/cpu/TensorCompareKernel.cpp", 1172 "aten/src/ATen/native/cpu/UnaryOpsKernel.cpp", 1173 "aten/src/ATen/native/cpu/Unfold2d.cpp", 1174 "aten/src/ATen/native/cpu/UnfoldBackwardKernel.cpp", 1175 "aten/src/ATen/native/cpu/UpSampleKernel.cpp", 1176 "aten/src/ATen/native/cpu/UpSampleMoreKernel.cpp", 1177 "aten/src/ATen/native/cpu/WeightNormKernel.cpp", 1178 "aten/src/ATen/native/cpu/airy_ai.cpp", 1179 "aten/src/ATen/native/cpu/batch_norm_kernel.cpp", 1180 "aten/src/ATen/native/cpu/group_norm_kernel.cpp", 1181 "aten/src/ATen/native/cpu/int4mm_kernel.cpp", 1182 "aten/src/ATen/native/cpu/int8mm_kernel.cpp", 1183 "aten/src/ATen/native/cpu/layer_norm_kernel.cpp", 1184 "aten/src/ATen/native/cpu/AmpGradScalerKernels.cpp", 1185 "aten/src/ATen/native/cpu/scaled_modified_bessel_k0.cpp", 1186 "aten/src/ATen/native/cpu/scaled_modified_bessel_k1.cpp", 1187 "aten/src/ATen/native/cpu/spherical_bessel_j0.cpp", 1188 "aten/src/ATen/native/cpu/SampledAddmmKernel.cpp", 1189 "aten/src/ATen/native/cpu/SpmmReduceKernel.cpp", 1190 "aten/src/ATen/native/cpu/SparseFactories.cpp", 1191 "aten/src/ATen/native/quantized/cpu/kernels/QuantizedOpKernels.cpp", 1192 "aten/src/ATen/native/cpu/FusedAdamKernel.cpp", 1193 "aten/src/ATen/native/cpu/FusedSGDKernel.cpp", 1194 "aten/src/ATen/native/cpu/FusedAdagradKernel.cpp", 1195] 1196 1197# This aten native source file list will not go through aten codegen process 1198aten_native_source_non_codegen_list = [ 1199 "aten/src/ATen/native/ao_sparse/library.cpp", 1200 "aten/src/ATen/native/ao_sparse/quantized/cpu/fbgemm_utils.cpp", 1201 "aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear.cpp", 1202 "aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_deserialize.cpp", 1203 "aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_dynamic.cpp", 1204 "aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_prepack.cpp", 1205 "aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_serialize.cpp", 1206 "aten/src/ATen/native/ao_sparse/quantized/cpu/qlinear_unpack.cpp", 1207 "aten/src/ATen/native/quantized/cpu/fbgemm_utils.cpp", 1208 "aten/src/ATen/native/quantized/cpu/fused_obs_fake_quant.cpp", 1209 "aten/src/ATen/native/quantized/cpu/IntReprQuant.cpp", 1210 "aten/src/ATen/native/quantized/cpu/MakePerTensorQuantizedTensor.cpp", 1211 "aten/src/ATen/native/quantized/cpu/AdaptiveAveragePooling.cpp", 1212 "aten/src/ATen/native/quantized/cpu/AveragePool2d.cpp", 1213 "aten/src/ATen/native/quantized/cpu/AveragePool3d.cpp", 1214 "aten/src/ATen/native/quantized/cpu/BinaryOps.cpp", 1215 "aten/src/ATen/native/quantized/cpu/Normalization.cpp", 1216 "aten/src/ATen/native/quantized/cpu/ChannelShuffle.cpp", 1217 "aten/src/ATen/native/quantized/cpu/qclamp.cpp", 1218 "aten/src/ATen/native/quantized/cpu/TensorShape.cpp", 1219 "aten/src/ATen/native/quantized/cpu/qconv.cpp", 1220 "aten/src/ATen/native/quantized/cpu/qconv_prepack.cpp", 1221 "aten/src/ATen/native/quantized/cpu/qconv_unpack_impl.cpp", 1222 "aten/src/ATen/native/quantized/cpu/qelu.cpp", 1223 "aten/src/ATen/native/quantized/cpu/qembeddingbag.cpp", 1224 "aten/src/ATen/native/quantized/cpu/qembeddingbag_prepack.cpp", 1225 "aten/src/ATen/native/quantized/cpu/qembeddingbag_unpack.cpp", 1226 "aten/src/ATen/native/quantized/cpu/qgelu.cpp", 1227 "aten/src/ATen/native/quantized/cpu/qhardsigmoid.cpp", 1228 "aten/src/ATen/native/quantized/cpu/qhardswish.cpp", 1229 "aten/src/ATen/native/quantized/cpu/qlinear.cpp", 1230 "aten/src/ATen/native/quantized/cpu/qlinear_dynamic.cpp", 1231 "aten/src/ATen/native/quantized/cpu/qconv_dynamic.cpp", 1232 "aten/src/ATen/native/quantized/cpu/qlinear_prepack.cpp", 1233 "aten/src/ATen/native/quantized/cpu/LinearUnpackImpl.cpp", 1234 "aten/src/ATen/native/quantized/cpu/qmatmul.cpp", 1235 "aten/src/ATen/native/quantized/cpu/qmul.cpp", 1236 "aten/src/ATen/native/quantized/cpu/qnormalization.cpp", 1237 "aten/src/ATen/native/quantized/cpu/Pooling.cpp", 1238 "aten/src/ATen/native/quantized/cpu/ReduceOps.cpp", 1239 "aten/src/ATen/native/quantized/cpu/qrelu.cpp", 1240 "aten/src/ATen/native/quantized/cpu/qsigmoid.cpp", 1241 "aten/src/ATen/native/quantized/cpu/qsoftmax.cpp", 1242 "aten/src/ATen/native/quantized/cpu/Sorting.cpp", 1243 "aten/src/ATen/native/quantized/cpu/qtanh.cpp", 1244 "aten/src/ATen/native/quantized/cpu/qthreshold.cpp", 1245 "aten/src/ATen/native/quantized/cpu/UpSampleBilinear2d.cpp", 1246 "aten/src/ATen/native/quantized/cpu/UpSampleNearest2d.cpp", 1247 "aten/src/ATen/native/quantized/cpu/UpSampleNearest3d.cpp", 1248 "aten/src/ATen/native/quantized/cpu/TensorOperators.cpp", 1249 "aten/src/ATen/native/quantized/Copy.cpp", 1250 "aten/src/ATen/native/quantized/QTensor.cpp", 1251 "aten/src/ATen/native/quantized/TensorCompare.cpp", 1252 "aten/src/ATen/native/quantized/TensorFactories.cpp", 1253 "aten/src/ATen/native/quantized/AffineQuantizer.cpp", 1254 "aten/src/ATen/native/quantized/AffineQuantizerBase.cpp", 1255 "aten/src/ATen/native/quantized/FakeQuantPerChannelAffine.cpp", 1256 "aten/src/ATen/native/quantized/FakeQuantPerTensorAffine.cpp", 1257 "aten/src/ATen/native/quantized/library.cpp", 1258 "aten/src/ATen/native/quantized/TensorAdvancedIndexing.cpp", 1259 "aten/src/ATen/native/quantized/cpu/RuyUtils.cpp", 1260 "aten/src/ATen/native/quantized/cpu/XnnpackUtils.cpp", 1261 "aten/src/ATen/native/quantized/qlinear_unpack.cpp", 1262 "aten/src/ATen/quantized/QTensorImpl.cpp", 1263 "aten/src/ATen/quantized/Quantizer.cpp", 1264 "aten/src/ATen/native/Activation.cpp", 1265 "aten/src/ATen/native/AdaptiveAveragePooling.cpp", 1266 "aten/src/ATen/native/AdaptiveAveragePooling3d.cpp", 1267 "aten/src/ATen/native/AdaptiveMaxPooling2d.cpp", 1268 "aten/src/ATen/native/AdaptiveMaxPooling3d.cpp", 1269 "aten/src/ATen/native/AffineGridGenerator.cpp", 1270 "aten/src/ATen/native/AveragePool2d.cpp", 1271 "aten/src/ATen/native/AveragePool3d.cpp", 1272 "aten/src/ATen/native/BatchLinearAlgebra.cpp", 1273 "aten/src/ATen/native/BatchLinearAlgebraKernel.cpp", 1274 "aten/src/ATen/native/LegacyBatching.cpp", 1275 "aten/src/ATen/native/BinaryOps.cpp", 1276 "aten/src/ATen/native/Blas.cpp", 1277 "aten/src/ATen/native/BlasKernel.cpp", 1278 "aten/src/ATen/native/Bucketization.cpp", 1279 "aten/src/ATen/native/CPUBlas.cpp", 1280 "aten/src/ATen/native/ChanelShuffle.cpp", 1281 "aten/src/ATen/native/Col2Im.cpp", 1282 "aten/src/ATen/native/PadNd.cpp", 1283 "aten/src/ATen/native/Constraints.cpp", 1284 "aten/src/ATen/native/Convolution.cpp", 1285 "aten/src/ATen/native/ConvolutionMM2d.cpp", 1286 "aten/src/ATen/native/ConvolutionMM3d.cpp", 1287 "aten/src/ATen/native/ConvolutionTBC.cpp", 1288 "aten/src/ATen/native/Copy.cpp", 1289 "aten/src/ATen/native/Correlation.cpp", 1290 "aten/src/ATen/native/CPUFallback.cpp", 1291 "aten/src/ATen/native/Cross.cpp", 1292 "aten/src/ATen/native/DilatedMaxPool2d.cpp", 1293 "aten/src/ATen/native/DilatedMaxPool3d.cpp", 1294 # Referenced by both native and ATen/Version.cpp. Does not reference to other native symbols 1295 # "aten/src/ATen/native/DispatchStub.cpp", 1296 # "aten/src/ATen/native/quantized/cpu/init_qnnpack.cpp", 1297 "aten/src/ATen/native/Distance.cpp", 1298 "aten/src/ATen/native/Distributions.cpp", 1299 "aten/src/ATen/native/Dropout.cpp", 1300 "aten/src/ATen/native/Embedding.cpp", 1301 "aten/src/ATen/native/EmbeddingBag.cpp", 1302 "aten/src/ATen/native/Fill.cpp", 1303 "aten/src/ATen/native/ForeachOpsKernels.cpp", 1304 "aten/src/ATen/native/FractionalMaxPool2d.cpp", 1305 "aten/src/ATen/native/FractionalMaxPool3d.cpp", 1306 "aten/src/ATen/native/FunctionOfAMatrixUtils.cpp", 1307 "aten/src/ATen/native/GatedLinearUnit.cpp", 1308 "aten/src/ATen/native/GridSampler.cpp", 1309 "aten/src/ATen/native/Histogram.cpp", 1310 "aten/src/ATen/native/Im2Col.cpp", 1311 "aten/src/ATen/native/IndexingUtils.cpp", 1312 "aten/src/ATen/native/Integration.cpp", 1313 "aten/src/ATen/native/Itertools.cpp", 1314 "aten/src/ATen/native/LegacyBridge.cpp", 1315 "aten/src/ATen/native/Lerp.cpp", 1316 "aten/src/ATen/native/Linear.cpp", 1317 "aten/src/ATen/native/LinearAlgebra.cpp", 1318 "aten/src/ATen/native/Loss.cpp", 1319 "aten/src/ATen/native/LossCTC.cpp", 1320 "aten/src/ATen/native/LossMultiLabelMargin.cpp", 1321 "aten/src/ATen/native/LossMultiMargin.cpp", 1322 "aten/src/ATen/native/LossNLL.cpp", 1323 "aten/src/ATen/native/LossNLL2d.cpp", 1324 "aten/src/ATen/native/MaxPooling.cpp", 1325 "aten/src/ATen/native/MaxUnpooling.cpp", 1326 "aten/src/ATen/native/Memory.cpp", 1327 "aten/src/ATen/native/MetaTensor.cpp", 1328 "aten/src/ATen/native/NNPACK.cpp", 1329 "aten/src/ATen/native/NaiveConvolutionTranspose2d.cpp", 1330 "aten/src/ATen/native/NaiveConvolutionTranspose3d.cpp", 1331 "aten/src/ATen/native/NaiveDilatedConvolution.cpp", 1332 "aten/src/ATen/native/NamedTensor.cpp", 1333 "aten/src/ATen/native/Normalization.cpp", 1334 "aten/src/ATen/native/Onehot.cpp", 1335 "aten/src/ATen/native/PackedSequence.cpp", 1336 "aten/src/ATen/native/PixelShuffle.cpp", 1337 "aten/src/ATen/native/PointwiseOps.cpp", 1338 "aten/src/ATen/native/Pooling.cpp", 1339 "aten/src/ATen/native/Pow.cpp", 1340 "aten/src/ATen/native/QuantizedLinear.cpp", 1341 "aten/src/ATen/native/RNN.cpp", 1342 "aten/src/ATen/native/RangeFactories.cpp", 1343 "aten/src/ATen/native/ReduceAllOps.cpp", 1344 "aten/src/ATen/native/ReduceOps.cpp", 1345 "aten/src/ATen/native/ReflectionPad.cpp", 1346 "aten/src/ATen/native/Repeat.cpp", 1347 "aten/src/ATen/native/ReplicationPadding.cpp", 1348 "aten/src/ATen/native/Resize.cpp", 1349 "aten/src/ATen/native/RowwisePrune.cpp", 1350 "aten/src/ATen/native/SegmentReduce.cpp", 1351 "aten/src/ATen/native/Scalar.cpp", 1352 "aten/src/ATen/native/SobolEngineOps.cpp", 1353 "aten/src/ATen/native/SobolEngineOpsUtils.cpp", 1354 "aten/src/ATen/native/SoftMax.cpp", 1355 "aten/src/ATen/native/Sorting.cpp", 1356 "aten/src/ATen/native/SparseTensorUtils.cpp", 1357 "aten/src/ATen/native/SpectralOps.cpp", 1358 "aten/src/ATen/native/SummaryOps.cpp", 1359 "aten/src/ATen/native/TensorAdvancedIndexing.cpp", 1360 "aten/src/ATen/native/TensorCompare.cpp", 1361 "aten/src/ATen/native/TensorConversions.cpp", 1362 "aten/src/ATen/native/TensorFactories.cpp", 1363 "aten/src/ATen/native/TensorIteratorReduce.cpp", 1364 "aten/src/ATen/native/TensorProperties.cpp", 1365 "aten/src/ATen/native/TensorShape.cpp", 1366 "aten/src/ATen/native/TensorTransformations.cpp", 1367 "aten/src/ATen/native/TestOps.cpp", 1368 "aten/src/ATen/native/TriangularOps.cpp", 1369 "aten/src/ATen/native/TypeProperties.cpp", 1370 "aten/src/ATen/native/UnaryOps.cpp", 1371 "aten/src/ATen/native/Unfold2d.cpp", 1372 "aten/src/ATen/native/Unfold3d.cpp", 1373 "aten/src/ATen/native/UnfoldBackward.cpp", 1374 "aten/src/ATen/native/Unique.cpp", 1375 # Low-level functions that can be directly referenced 1376 # "aten/src/ATen/native/UpSample.cpp", 1377 "aten/src/ATen/native/UpSampleBicubic2d.cpp", 1378 "aten/src/ATen/native/UpSampleBilinear2d.cpp", 1379 "aten/src/ATen/native/UpSampleLinear1d.cpp", 1380 "aten/src/ATen/native/UpSampleNearest1d.cpp", 1381 "aten/src/ATen/native/UpSampleNearest2d.cpp", 1382 "aten/src/ATen/native/UpSampleNearest3d.cpp", 1383 "aten/src/ATen/native/UpSampleTrilinear3d.cpp", 1384 "aten/src/ATen/native/VariableMethodStubs.cpp", 1385 "aten/src/ATen/native/WeightNorm.cpp", 1386 "aten/src/ATen/native/group_norm.cpp", 1387 "aten/src/ATen/native/layer_norm.cpp", 1388 "aten/src/ATen/native/AmpKernels.cpp", 1389 "aten/src/ATen/native/mkl/LinearAlgebra.cpp", 1390 "aten/src/ATen/native/mkl/SparseBlasImpl.cpp", 1391 "aten/src/ATen/native/mkl/SparseCsrLinearAlgebra.cpp", 1392 "aten/src/ATen/native/mkl/SpectralOps.cpp", 1393 "aten/src/ATen/native/nested/NestedTensorAliases.cpp", 1394 "aten/src/ATen/native/nested/NestedTensorBackward.cpp", 1395 "aten/src/ATen/native/nested/NestedTensorBinaryOps.cpp", 1396 "aten/src/ATen/native/nested/NestedTensorFactories.cpp", 1397 "aten/src/ATen/native/nested/NestedTensorMath.cpp", 1398 "aten/src/ATen/native/nested/NestedTensorMatmul.cpp", 1399 "aten/src/ATen/native/nested/NestedTensorTransformerFunctions.cpp", 1400 "aten/src/ATen/native/nested/NestedTensorUnaryOps.cpp", 1401 "aten/src/ATen/native/nested/NestedTensorUtils.cpp", 1402 "aten/src/ATen/native/sparse/ParamUtils.cpp", 1403 "aten/src/ATen/native/sparse/SoftMax.cpp", 1404 "aten/src/ATen/native/sparse/SparseBlas.cpp", 1405 "aten/src/ATen/native/sparse/SparseBlasImpl.cpp", 1406 "aten/src/ATen/native/sparse/SparseMatMul.cpp", 1407 "aten/src/ATen/native/sparse/SparseTensor.cpp", 1408 "aten/src/ATen/native/sparse/SparseCsrTensor.cpp", 1409 "aten/src/ATen/native/sparse/SparseTensorMath.cpp", 1410 "aten/src/ATen/native/sparse/SparseUnaryOps.cpp", 1411 "aten/src/ATen/native/sparse/SparseCsrTensorMath.cpp", 1412 "aten/src/ATen/native/sparse/SparseFactories.cpp", 1413 "aten/src/ATen/native/sparse/ValidateCompressedIndicesKernel.cpp", 1414 "aten/src/ATen/native/sparse/SparseBinaryOpIntersectionKernel.cpp", 1415 "aten/src/ATen/native/sparse/FlattenIndicesKernel.cpp", 1416 "aten/src/ATen/native/transformers/attention.cpp", 1417 "aten/src/ATen/native/transformers/sdp_utils_cpp.cpp", 1418 "aten/src/ATen/native/transformers/transformer.cpp", 1419 "aten/src/ATen/native/xnnpack/Activation.cpp", 1420 "aten/src/ATen/native/xnnpack/ChannelShuffle.cpp", 1421 "aten/src/ATen/native/xnnpack/Convolution.cpp", 1422 "aten/src/ATen/native/xnnpack/AveragePooling.cpp", 1423 "aten/src/ATen/native/xnnpack/Init.cpp", 1424 "aten/src/ATen/native/xnnpack/Linear.cpp", 1425 "aten/src/ATen/native/xnnpack/MaxPooling.cpp", 1426 "aten/src/ATen/native/xnnpack/OpContext.cpp", 1427 "aten/src/ATen/native/xnnpack/RegisterOpContextClass.cpp", 1428 "aten/src/ATen/native/xnnpack/Shim.cpp", 1429 "aten/src/ATen/native/FusedAdam.cpp", 1430 "aten/src/ATen/native/FusedSGD.cpp", 1431 "aten/src/ATen/native/FusedAdagrad.cpp", 1432 # Files not in native, but depends on native symbols 1433 # "aten/src/ATen/TensorIndexing.cpp", 1434 "aten/src/ATen/TensorIterator.cpp", 1435] 1436 1437# 1. Files in ATen/native with a few exceptions 1438# TODO: move the exceptions to proper locations 1439# 2. The whole aten native source list includes the list with and without aten codegen process. 1440aten_native_source_list = sorted(aten_native_source_non_codegen_list + aten_native_source_codegen_list) 1441 1442# These are cpp files which need to go in the torch_cuda_cu library 1443# .cu files can be found via glob 1444aten_cuda_cu_source_list = [ 1445 "aten/src/ATen/cuda/CUDABlas.cpp", 1446 "aten/src/ATen/cuda/CUDASparseBlas.cpp", 1447 "aten/src/ATen/cuda/CublasHandlePool.cpp", 1448 "aten/src/ATen/native/cuda/linalg/CudssHandlePool.cpp", 1449 "aten/src/ATen/cuda/tunable/StreamTimer.cpp", 1450 "aten/src/ATen/cuda/tunable/Tunable.cpp", 1451 "aten/src/ATen/native/cuda/Activation.cpp", 1452 "aten/src/ATen/native/cuda/LinearAlgebraStubs.cpp", 1453 "aten/src/ATen/native/cuda/Blas.cpp", 1454 "aten/src/ATen/native/cuda/Distributions.cpp", 1455 "aten/src/ATen/native/cuda/Equal.cpp", 1456 "aten/src/ATen/native/cuda/GridSampler.cpp", 1457 "aten/src/ATen/native/cuda/IndexKernel.cpp", 1458 "aten/src/ATen/native/cuda/ReduceOps.cpp", 1459 "aten/src/ATen/native/cuda/ScanKernels.cpp", 1460 "aten/src/ATen/native/cuda/Sort.cpp", 1461 "aten/src/ATen/native/cuda/Sorting.cpp", 1462 "aten/src/ATen/native/cuda/TensorModeKernel.cpp", 1463 "aten/src/ATen/native/cuda/TensorShapeCUDA.cpp", 1464 "aten/src/ATen/native/cuda/TensorTopK.cpp", 1465 "aten/src/ATen/native/cuda/jit_utils.cpp", 1466 "aten/src/ATen/native/nested/cuda/NestedTensorTransformerFunctions.cpp", 1467 "aten/src/ATen/native/sparse/cuda/SparseBlas.cpp", 1468 "aten/src/ATen/native/sparse/cuda/SparseBlasImpl.cpp", 1469 "aten/src/ATen/native/sparse/cuda/SparseBlasLegacy.cpp", 1470 "aten/src/ATen/native/sparse/cuda/SparseCUDABlas.cpp", 1471 "aten/src/ATen/native/transformers/cuda/flash_attn/flash_api.cpp", 1472] 1473 1474# Files using thrust::sort_by_key need to be linked last 1475aten_cuda_with_sort_by_key_source_list = [ 1476 # empty_cuda is needed by torch_cuda_cpp 1477 "aten/src/ATen/native/cuda/TensorFactories.cu", 1478] 1479 1480aten_cuda_cu_with_sort_by_key_source_list = [ 1481 "aten/src/ATen/native/cuda/Unique.cu", 1482] 1483 1484# Followings are source code for xnnpack delegate 1485 1486xnnpack_delegate_serializer_header = [ 1487 "torch/csrc/jit/backends/xnnpack/serialization/serializer.h", 1488] 1489 1490xnnpack_delegate_serializer_source_list = [ 1491 "torch/csrc/jit/backends/xnnpack/serialization/serializer.cpp", 1492] 1493 1494xnnpack_delegate_core_source_list = [ 1495 "torch/csrc/jit/backends/xnnpack/compiler/xnn_compiler.cpp", 1496] 1497 1498xnnpack_delegate_core_header = [ 1499 "torch/csrc/jit/backends/xnnpack/compiler/xnn_compiler.h", 1500 "torch/csrc/jit/backends/xnnpack/executor/xnn_executor.h", 1501] 1502 1503xnnpack_backend_header = [ 1504 "torch/csrc/jit/backends/xnnpack/xnnpack_graph_builder.h", 1505] + xnnpack_delegate_core_header 1506 1507xnnpack_backend_source_list = [ 1508 "torch/csrc/jit/backends/xnnpack/compiler/xnn_compiler.cpp", 1509 "torch/csrc/jit/backends/xnnpack/xnnpack_backend_lib.cpp", 1510 "torch/csrc/jit/backends/xnnpack/xnnpack_backend_preprocess.cpp", 1511 "torch/csrc/jit/backends/xnnpack/xnnpack_graph_builder.cpp", 1512] + xnnpack_delegate_core_source_list 1513