"Fossies" - the Fresh Open Source Software Archive

Member "pytorch-1.8.2/BUILD.bazel" (23 Jul 2021, 73494 Bytes) of package /linux/misc/pytorch-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "BUILD.bazel": 1.13.0-rc3_vs_1.13.0-rc4.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


    1 load("@bazel_skylib//lib:paths.bzl", "paths")
    2 load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
    3 load("@rules_proto//proto:defs.bzl", "proto_library")
    4 load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "cc_test")
    5 load("//third_party:substitution.bzl", "header_template_rule")
    6 load("//:tools/build_variables.bzl", "torch_cpp_srcs", "libtorch_python_core_sources", "libtorch_core_sources", "libtorch_distributed_sources", "libtorch_extra_sources", "jit_core_sources")
    7 load("//tools/rules:cu.bzl", "cu_library")
    8 load("//tools/config:defs.bzl", "if_cuda")
    9 load("//:aten.bzl", "intern_build_aten_ops")
   10 
   11 COMMON_COPTS = [
   12     "-DHAVE_MALLOC_USABLE_SIZE=1",
   13     "-DHAVE_MMAP=1",
   14     "-DHAVE_SHM_OPEN=1",
   15     "-DHAVE_SHM_UNLINK=1",
   16     "-D_FILE_OFFSET_BITS=64",
   17     "-DHAVE_GCC_GET_CPUID",
   18     "-DUSE_GCC_GET_CPUID",
   19     "-DTH_HAVE_THREAD",
   20     "-DUSE_FBGEMM",
   21     "-DUSE_DISTRIBUTED",
   22     "-DATEN_THREADING=NATIVE",
   23     "-DNO_CUDNN_DESTROY_HANDLE",
   24 ] + if_cuda([
   25     "-DUSE_CUDA",
   26     "-DUSE_CUDNN",
   27 ])
   28 
   29 # c10
   30 header_template_rule(
   31     name = "cmake_macros_h",
   32     src = "c10/macros/cmake_macros.h.in",
   33     out = "c10/macros/cmake_macros.h",
   34     substitutions = {
   35         "cmakedefine": "define",
   36         "#define FEATURE_TORCH_MOBILE": "/* #undef FEATURE_TORCH_MOBILE */",
   37         "#define C10_USE_NUMA": "/* #undef C10_USE_NUMA */",
   38     },
   39 )
   40 
   41 header_template_rule(
   42     name = "cuda_cmake_macros_h",
   43     src = "c10/cuda/impl/cuda_cmake_macros.h.in",
   44     out = "c10/cuda/impl/cuda_cmake_macros.h",
   45     substitutions = {
   46         "cmakedefine": "define",
   47     },
   48 )
   49 
   50 cc_library(
   51     name = "c10_headers",
   52     hdrs = glob([
   53         "c10/core/*.h",
   54         "c10/core/impl/*.h",
   55         "c10/cuda/*.h",
   56         "c10/cuda/impl/*.h",
   57         "c10/macros/*.h",
   58         "c10/mobile/*.h",
   59         "c10/util/*.h",
   60         "c10/util/*.hpp",
   61     ]),
   62     deps = [
   63         "@com_github_gflags_gflags//:gflags",
   64         "@com_github_glog//:glog",
   65         ":cmake_macros_h",
   66         ":cuda_cmake_macros_h",
   67     ],
   68 )
   69 
   70 cc_library(
   71     name = "c10",
   72     srcs = glob([
   73         "c10/core/*.cpp",
   74         "c10/core/impl/*.cpp",
   75         "c10/mobile/*.cpp",
   76         "c10/util/*.cpp",
   77     ]) + if_cuda(
   78         glob([
   79             "c10/cuda/*.cpp",
   80             "c10/cuda/impl/*.cpp",
   81         ]),
   82         [],
   83     ),
   84     copts = ["-DCAFFE2_BUILD_MAIN_LIB"],
   85     deps = [
   86         ":c10_headers",
   87     ] + if_cuda(
   88         ["@cuda"],
   89         [],
   90     ),
   91     alwayslink = True,
   92 )
   93 
   94 cc_test(
   95     name = "c10_tests",
   96     size = "small",
   97     srcs = glob([
   98         "c10/test/util/*.cpp",
   99         "c10/test/util/*.h",
  100         "c10/test/core/*.cpp",
  101         "c10/test/core/impl/*.cpp",
  102     ]),
  103     copts = ["-Wno-deprecated-declarations"],
  104     deps = [
  105         ":c10",
  106         ":c10_headers",
  107         "@com_google_googletest//:gtest_main",
  108     ],
  109 )
  110 
  111 # TODO: refactor this into its own library (but how to make
  112 # a binary based off of a module in a library?)
  113 py_binary(
  114     name = "gen",
  115     srcs = ["tools/setup_helpers/gen.py"],
  116     deps = [
  117         ":tools_codegen"
  118     ],
  119 )
  120 
  121 genrule(
  122     name = "generated_cpp",
  123     srcs = [
  124         "aten/src/ATen/native/native_functions.yaml",
  125     ] + glob(["aten/src/ATen/templates/**"]),
  126     outs = [
  127         "aten/src/ATen/Declarations.yaml",
  128         "aten/src/ATen/RegisterBackendSelect.cpp",
  129         "aten/src/ATen/RegisterCPU.cpp",
  130         "aten/src/ATen/RegisterMkldnnCPU.cpp",
  131         "aten/src/ATen/RegisterQuantizedCPU.cpp",
  132         "aten/src/ATen/RegisterSparseCPU.cpp",
  133         "aten/src/ATen/RegisterMath.cpp",
  134         "aten/src/ATen/RegisterMeta.cpp",
  135         "aten/src/ATen/RegisterDefaultBackend.cpp",
  136         "aten/src/ATen/RegisterSchema.cpp",
  137         "aten/src/ATen/CPUFunctions.h",
  138         "aten/src/ATen/CUDAFunctions.h",
  139         "aten/src/ATen/Functions.h",
  140         "aten/src/ATen/Functions.cpp",
  141         "aten/src/ATen/NativeFunctions.h",
  142         "aten/src/ATen/MetaFunctions.h",
  143         "aten/src/ATen/core/TensorBody.h",
  144         "aten/src/ATen/core/TensorMethods.cpp",
  145         "aten/src/ATen/core/ATenOpList.cpp",
  146     ],
  147     cmd = "$(location :gen) --source-path aten/src/ATen --install_dir `dirname $(location aten/src/ATen/Declarations.yaml)`",
  148     tools = [":gen"],
  149 )
  150 
  151 py_library(
  152     name = "tools_codegen",
  153     srcs = glob(["tools/codegen/**/*.py"]),
  154 )
  155 
  156 py_library(
  157     name = "tools_autograd",
  158     srcs = glob(["tools/autograd/*.py"]),
  159     data = glob([
  160         "tools/autograd/*.yaml",
  161         "tools/autograd/templates/*",
  162     ]),
  163     deps = [":tools_codegen"],
  164 )
  165 
  166 py_library(
  167     name = "tools_jit",
  168     srcs = glob(["tools/jit/*.py"]),
  169     data = glob(["tools/jit/templates/*"]),
  170 )
  171 
  172 py_binary(
  173     name = "generate_code",
  174     srcs = ["tools/setup_helpers/generate_code.py"],
  175     deps = [
  176         ":tools_autograd",
  177         ":tools_jit",
  178     ],
  179 )
  180 
  181 libtorch_cpp_generated_sources = [
  182         "torch/csrc/autograd/generated/VariableType.h",
  183         "torch/csrc/autograd/generated/VariableType_0.cpp",
  184         "torch/csrc/autograd/generated/VariableType_1.cpp",
  185         "torch/csrc/autograd/generated/VariableType_2.cpp",
  186         "torch/csrc/autograd/generated/VariableType_3.cpp",
  187         "torch/csrc/autograd/generated/VariableType_4.cpp",
  188         # "torch/csrc/autograd/generated/VariableTypeEverything.cpp",
  189         "torch/csrc/autograd/generated/TraceType_0.cpp",
  190         "torch/csrc/autograd/generated/TraceType_1.cpp",
  191         "torch/csrc/autograd/generated/TraceType_2.cpp",
  192         "torch/csrc/autograd/generated/TraceType_3.cpp",
  193         "torch/csrc/autograd/generated/TraceType_4.cpp",
  194         # "torch/csrc/autograd/generated/TraceTypeEverything.cpp",
  195         "torch/csrc/autograd/generated/Functions.h",
  196         "torch/csrc/autograd/generated/Functions.cpp",
  197         "torch/csrc/autograd/generated/variable_factories.h",
  198 ]
  199 
  200 libtorch_python_generated_sources = [
  201         "torch/csrc/autograd/generated/python_functions.h",
  202         "torch/csrc/autograd/generated/python_functions.cpp",
  203         "torch/csrc/autograd/generated/python_variable_methods.cpp",
  204         "torch/csrc/autograd/generated/python_torch_functions.cpp",
  205         "torch/csrc/autograd/generated/python_nn_functions.cpp",
  206         "torch/csrc/autograd/generated/python_fft_functions.cpp",
  207         "torch/csrc/autograd/generated/python_linalg_functions.cpp",
  208 ]
  209 
  210 genrule(
  211     name = "all_generated_code",
  212     srcs = [
  213         "aten/src/ATen/Declarations.yaml",
  214         "aten/src/ATen/native/native_functions.yaml",
  215     ],
  216     outs = libtorch_cpp_generated_sources + libtorch_python_generated_sources,
  217     cmd = "$(location :generate_code) --install_dir `dirname $(location torch/csrc/autograd/generated/variable_factories.h)`/../.. --declarations-path $(location aten/src/ATen/Declarations.yaml) --native-functions-path $(location aten/src/ATen/native/native_functions.yaml) --nn-path aten/src",
  218     tools = [":generate_code"],
  219 )
  220 
  221 filegroup(
  222     name = "cpp_generated_code",
  223     data = [":all_generated_code"],
  224     srcs = libtorch_cpp_generated_sources,
  225 )
  226 
  227 filegroup(
  228     name = "python_generated_code",
  229     data = [":all_generated_code"],
  230     srcs = libtorch_python_generated_sources,
  231 )
  232 
  233 exports_files(
  234     srcs = ["aten/src/ATen/cpu/tbb/extra/version_string.ver.in"],
  235 )
  236 
  237 # ATen
  238 filegroup(
  239     name = "aten_base_cpp",
  240     srcs = glob([
  241         "aten/src/ATen/*.cpp",
  242         "aten/src/ATen/detail/*.cpp",
  243         "aten/src/ATen/cpu/*.cpp",
  244     ]),
  245 )
  246 
  247 filegroup(
  248     name = "ATen_CORE_SRCS",
  249     srcs = glob(
  250         [
  251             "aten/src/ATen/core/**/*.cpp",
  252         ],
  253         exclude = [
  254             "aten/src/ATen/core/**/*_test.cpp",
  255         ],
  256     ),
  257 )
  258 
  259 filegroup(
  260     name = "aten_native_cpp",
  261     srcs = glob(["aten/src/ATen/native/*.cpp"]),
  262 )
  263 
  264 filegroup(
  265     name = "aten_native_sparse_cpp",
  266     srcs = glob(["aten/src/ATen/native/sparse/*.cpp"]),
  267 )
  268 
  269 filegroup(
  270     name = "aten_native_quantized_cpp",
  271     srcs = glob(
  272         [
  273             "aten/src/ATen/native/quantized/*.cpp",
  274             "aten/src/ATen/native/quantized/cpu/*.cpp",
  275         ],
  276     ),
  277 )
  278 
  279 filegroup(
  280     name = "aten_native_mkl_cpp",
  281     srcs = glob(["aten/src/ATen/native/mkl/*.cpp"]),
  282 )
  283 
  284 filegroup(
  285     name = "aten_native_mkldnn_cpp",
  286     srcs = glob(["aten/src/ATen/native/mkldnn/*.cpp"]),
  287 )
  288 
  289 filegroup(
  290     name = "aten_native_xnnpack",
  291     srcs = glob(["aten/src/ATen/native/xnnpack/*.cpp"]),
  292 )
  293 
  294 filegroup(
  295     name = "aten_base_vulkan",
  296     srcs = glob(["aten/src/ATen/vulkan/*.cpp"]),
  297 )
  298 
  299 filegroup(
  300     name = "aten_base_metal",
  301     srcs = glob(["aten/src/ATen/metal/*.cpp"]),
  302 )
  303 
  304 filegroup(
  305     name = "ATen_QUANTIZED_SRCS",
  306     srcs = glob(
  307         [
  308             "aten/src/ATen/quantized/**/*.cpp",
  309         ],
  310         exclude = [
  311             "aten/src/ATen/quantized/**/*_test.cpp",
  312         ],
  313     ),
  314 )
  315 
  316 filegroup(
  317     name = "th_srcs",
  318     srcs = [
  319         "aten/src/TH/THAllocator.cpp",
  320         "aten/src/TH/THBlas.cpp",
  321         "aten/src/TH/THGeneral.cpp",
  322         "aten/src/TH/THLapack.cpp",
  323         "aten/src/TH/THStorageFunctions.cpp",
  324         "aten/src/TH/THTensor.cpp",
  325         "aten/src/TH/THTensorEvenMoreMath.cpp",
  326         "aten/src/TH/THTensorLapack.cpp",
  327         "aten/src/TH/THTensorMath.cpp",
  328         "aten/src/TH/THTensorMoreMath.cpp",
  329         "aten/src/TH/THTensorRandom.cpp",
  330         "aten/src/TH/THVector.cpp",
  331         "aten/src/TH/vector/AVX.cpp",
  332     ],
  333 )
  334 
  335 filegroup(
  336     name = "aten_cuda_srcs",
  337     srcs = [
  338         "aten/src/ATen/cuda/CUDABlas.cpp",
  339         "aten/src/ATen/cuda/CUDASolver.cpp",
  340         "aten/src/ATen/cuda/CUDAContext.cpp",
  341         "aten/src/ATen/cuda/CUDAGeneratorImpl.cpp",
  342         "aten/src/ATen/cuda/CUDAGraph.cpp",
  343         "aten/src/ATen/cuda/CuSparseHandlePool.cpp",
  344         "aten/src/ATen/cuda/CublasHandlePool.cpp",
  345         "aten/src/ATen/cuda/CusolverDnHandlePool.cpp",
  346         "aten/src/ATen/cuda/PinnedMemoryAllocator.cpp",
  347         "aten/src/ATen/cuda/detail/CUDAHooks.cpp",
  348         "aten/src/ATen/cudnn/AutocastRNN.cpp",
  349         "aten/src/ATen/cudnn/Descriptors.cpp",
  350         "aten/src/ATen/cudnn/Handle.cpp",
  351         "aten/src/ATen/cudnn/Types.cpp",
  352         "aten/src/ATen/native/cuda/CUDAUnaryOps.cpp",
  353         "aten/src/ATen/native/cuda/TensorShapeCUDA.cpp",
  354         "aten/src/ATen/native/cudnn/AffineGridGenerator.cpp",
  355         "aten/src/ATen/native/cudnn/BatchNorm.cpp",
  356         "aten/src/ATen/native/cudnn/Conv.cpp",
  357         "aten/src/ATen/native/cudnn/GridSampler.cpp",
  358         "aten/src/ATen/native/cudnn/LossCTC.cpp",
  359         "aten/src/ATen/native/cudnn/RNN.cpp",
  360         "aten/src/ATen/native/miopen/BatchNorm_miopen.cpp",
  361         "aten/src/ATen/native/miopen/Conv_miopen.cpp",
  362         "aten/src/ATen/native/miopen/RNN_miopen.cpp",
  363         "aten/src/ATen/native/sparse/cuda/SparseCUDATensor.cpp",
  364         "aten/src/THC/THCCachingHostAllocator.cpp",
  365         "aten/src/THC/THCGeneral.cpp",
  366         "aten/src/THC/THCStorageCopy.cpp",
  367         "aten/src/THC/THCTensor.cpp",
  368     ],
  369 )
  370 
  371 filegroup(
  372     name = "thc_srcs_cu",
  373     srcs = [
  374         "aten/src/THC/THCReduceApplyUtils.cu.cc",
  375         "aten/src/THC/THCSleep.cu.cc",
  376         "aten/src/THC/THCSortUtils.cu.cc",
  377         "aten/src/THC/THCStorage.cu.cc",
  378         "aten/src/THC/THCStorageCopy.cu.cc",
  379         "aten/src/THC/THCTensor.cu.cc",
  380         "aten/src/THC/THCTensorCopy.cu.cc",
  381         "aten/src/THC/THCTensorIndex.cu.cc",
  382         "aten/src/THC/THCTensorMath.cu.cc",
  383         "aten/src/THC/THCTensorMathMagma.cu.cc",
  384         "aten/src/THC/THCTensorMathPairwise.cu.cc",
  385         "aten/src/THC/THCTensorMathReduce.cu.cc",
  386         "aten/src/THC/THCTensorMathScan.cu.cc",
  387         "aten/src/THC/THCTensorMode.cu.cc",
  388         "aten/src/THC/THCTensorRandom.cu.cc",
  389         "aten/src/THC/THCTensorScatterGather.cu.cc",
  390         "aten/src/THC/THCTensorSort.cu.cc",
  391         "aten/src/THC/THCTensorTopK.cu.cc",
  392         "aten/src/THC/generated/THCTensorMaskedBFloat16.cu.cc",
  393         "aten/src/THC/generated/THCTensorMaskedBool.cu.cc",
  394         "aten/src/THC/generated/THCTensorMaskedByte.cu.cc",
  395         "aten/src/THC/generated/THCTensorMaskedChar.cu.cc",
  396         "aten/src/THC/generated/THCTensorMaskedDouble.cu.cc",
  397         "aten/src/THC/generated/THCTensorMaskedFloat.cu.cc",
  398         "aten/src/THC/generated/THCTensorMaskedHalf.cu.cc",
  399         "aten/src/THC/generated/THCTensorMaskedInt.cu.cc",
  400         "aten/src/THC/generated/THCTensorMaskedLong.cu.cc",
  401         "aten/src/THC/generated/THCTensorMaskedShort.cu.cc",
  402         "aten/src/THC/generated/THCTensorMathPointwiseBool.cu.cc",
  403         "aten/src/THC/generated/THCTensorMathPointwiseByte.cu.cc",
  404         "aten/src/THC/generated/THCTensorMathPointwiseChar.cu.cc",
  405         "aten/src/THC/generated/THCTensorMathPointwiseDouble.cu.cc",
  406         "aten/src/THC/generated/THCTensorMathPointwiseFloat.cu.cc",
  407         "aten/src/THC/generated/THCTensorMathPointwiseHalf.cu.cc",
  408         "aten/src/THC/generated/THCTensorMathPointwiseInt.cu.cc",
  409         "aten/src/THC/generated/THCTensorMathPointwiseLong.cu.cc",
  410         "aten/src/THC/generated/THCTensorMathPointwiseShort.cu.cc",
  411         "aten/src/THC/generated/THCTensorMathReduceBFloat16.cu.cc",
  412         "aten/src/THC/generated/THCTensorMathReduceBool.cu.cc",
  413         "aten/src/THC/generated/THCTensorMathReduceByte.cu.cc",
  414         "aten/src/THC/generated/THCTensorMathReduceChar.cu.cc",
  415         "aten/src/THC/generated/THCTensorMathReduceDouble.cu.cc",
  416         "aten/src/THC/generated/THCTensorMathReduceFloat.cu.cc",
  417         "aten/src/THC/generated/THCTensorMathReduceHalf.cu.cc",
  418         "aten/src/THC/generated/THCTensorMathReduceInt.cu.cc",
  419         "aten/src/THC/generated/THCTensorMathReduceLong.cu.cc",
  420         "aten/src/THC/generated/THCTensorMathReduceShort.cu.cc",
  421         "aten/src/THC/generated/THCTensorSortByte.cu.cc",
  422         "aten/src/THC/generated/THCTensorSortChar.cu.cc",
  423         "aten/src/THC/generated/THCTensorSortDouble.cu.cc",
  424         "aten/src/THC/generated/THCTensorSortFloat.cu.cc",
  425         "aten/src/THC/generated/THCTensorSortHalf.cu.cc",
  426         "aten/src/THC/generated/THCTensorSortInt.cu.cc",
  427         "aten/src/THC/generated/THCTensorSortLong.cu.cc",
  428         "aten/src/THC/generated/THCTensorSortShort.cu.cc",
  429     ],
  430 )
  431 
  432 filegroup(
  433     name = "thcunn_srcs_cu",
  434     srcs = [
  435         "aten/src/THCUNN/BCECriterion.cu.cc",
  436         "aten/src/THCUNN/ClassNLLCriterion.cu.cc",
  437         "aten/src/THCUNN/ELU.cu.cc",
  438         "aten/src/THCUNN/GatedLinearUnit.cu.cc",
  439         "aten/src/THCUNN/HardTanh.cu.cc",
  440         "aten/src/THCUNN/LeakyReLU.cu.cc",
  441         "aten/src/THCUNN/LogSigmoid.cu.cc",
  442         "aten/src/THCUNN/MultiLabelMarginCriterion.cu.cc",
  443         "aten/src/THCUNN/MultiMarginCriterion.cu.cc",
  444         "aten/src/THCUNN/RReLU.cu.cc",
  445         "aten/src/THCUNN/SoftMarginCriterion.cu.cc",
  446         "aten/src/THCUNN/SoftPlus.cu.cc",
  447         "aten/src/THCUNN/SoftShrink.cu.cc",
  448         "aten/src/THCUNN/SpatialClassNLLCriterion.cu.cc",
  449         "aten/src/THCUNN/SpatialConvolutionMM.cu.cc",
  450         "aten/src/THCUNN/SpatialDepthwiseConvolution.cu.cc",
  451         "aten/src/THCUNN/Tanh.cu.cc",
  452     ],
  453 )
  454 
  455 filegroup(
  456     name = "aten_srcs_cu",
  457     srcs = [
  458         "aten/src/ATen/cuda/detail/IndexUtils.cu.cc",
  459         "aten/src/ATen/cuda/detail/CUDAGraphsUtils.cu.cc",
  460         "aten/src/ATen/native/cuda/Activation.cu.cc",
  461         "aten/src/ATen/native/cuda/AdaptiveAveragePooling.cu.cc",
  462         "aten/src/ATen/native/cuda/AdaptiveAveragePooling3d.cu.cc",
  463         "aten/src/ATen/native/cuda/AdaptiveMaxPooling2d.cu.cc",
  464         "aten/src/ATen/native/cuda/AdaptiveMaxPooling3d.cu.cc",
  465         "aten/src/ATen/native/cuda/AveragePool2d.cu.cc",
  466         "aten/src/ATen/native/cuda/AveragePool3d.cu.cc",
  467         "aten/src/ATen/native/cuda/BatchLinearAlgebra.cu.cc",
  468         "aten/src/ATen/native/cuda/BatchLinearAlgebraLib.cu.cc",
  469         "aten/src/ATen/native/cuda/BinaryArithmeticKernel.cu.cc",
  470         "aten/src/ATen/native/cuda/BinaryCompareKernel.cu.cc",
  471         "aten/src/ATen/native/cuda/BinaryMiscOpsKernels.cu.cc",
  472         "aten/src/ATen/native/cuda/CUDAScalar.cu.cc",
  473         "aten/src/ATen/native/cuda/Col2Im.cu.cc",
  474         "aten/src/ATen/native/cuda/Copy.cu.cc",
  475         "aten/src/ATen/native/cuda/CrossKernel.cu.cc",
  476         "aten/src/ATen/native/cuda/DilatedMaxPool2d.cu.cc",
  477         "aten/src/ATen/native/cuda/DilatedMaxPool3d.cu.cc",
  478         "aten/src/ATen/native/cuda/DistanceKernel.cu.cc",
  479         "aten/src/ATen/native/cuda/Distributions.cu.cc",
  480         "aten/src/ATen/native/cuda/Dropout.cu.cc",
  481         "aten/src/ATen/native/cuda/Embedding.cu.cc",
  482         "aten/src/ATen/native/cuda/EmbeddingBackwardKernel.cu.cc",
  483         "aten/src/ATen/native/cuda/EmbeddingBag.cu.cc",
  484         "aten/src/ATen/native/cuda/FillKernel.cu.cc",
  485         "aten/src/ATen/native/cuda/FractionalMaxPool2d.cu.cc",
  486         "aten/src/ATen/native/cuda/FractionalMaxPool3d.cu.cc",
  487         "aten/src/ATen/native/cuda/GridSampler.cu.cc",
  488         "aten/src/ATen/native/cuda/Im2Col.cu.cc",
  489         "aten/src/ATen/native/cuda/IndexKernel.cu.cc",
  490         "aten/src/ATen/native/cuda/Indexing.cu.cc",
  491         "aten/src/ATen/native/cuda/Lerp.cu.cc",
  492         "aten/src/ATen/native/cuda/LinearAlgebra.cu.cc",
  493         "aten/src/ATen/native/cuda/Loss.cu.cc",
  494         "aten/src/ATen/native/cuda/LossCTC.cu.cc",
  495         "aten/src/ATen/native/cuda/MaxUnpooling.cu.cc",
  496         "aten/src/ATen/native/cuda/MultinomialKernel.cu.cc",
  497         "aten/src/ATen/native/cuda/NaiveConvolutionTranspose2d.cu.cc",
  498         "aten/src/ATen/native/cuda/NaiveConvolutionTranspose3d.cu.cc",
  499         "aten/src/ATen/native/cuda/NaiveDilatedConvolution.cu.cc",
  500         "aten/src/ATen/native/cuda/Normalization.cu.cc",
  501         "aten/src/ATen/native/cuda/PointwiseOpsKernel.cu.cc",
  502         "aten/src/ATen/native/cuda/PowKernel.cu.cc",
  503         "aten/src/ATen/native/cuda/RNN.cu.cc",
  504         "aten/src/ATen/native/cuda/RangeFactories.cu.cc",
  505         "aten/src/ATen/native/cuda/Reduce.cu.cc",
  506         "aten/src/ATen/native/cuda/ReduceOpsKernel.cu.cc",
  507         "aten/src/ATen/native/cuda/ReflectionPad.cu.cc",
  508         "aten/src/ATen/native/cuda/Repeat.cu.cc",
  509         "aten/src/ATen/native/cuda/ReplicationPadding.cu.cc",
  510         "aten/src/ATen/native/cuda/Resize.cu.cc",
  511         "aten/src/ATen/native/cuda/SoftMax.cu.cc",
  512         "aten/src/ATen/native/cuda/SortingKthValue.cu.cc",
  513         "aten/src/ATen/native/cuda/SparseMM.cu.cc",
  514         "aten/src/ATen/native/cuda/SpectralOps.cu.cc",
  515         "aten/src/ATen/native/cuda/SummaryOps.cu.cc",
  516         "aten/src/ATen/native/cuda/TensorCompare.cu.cc",
  517         "aten/src/ATen/native/cuda/TensorFactories.cu.cc",
  518         "aten/src/ATen/native/cuda/TensorTransformations.cu.cc",
  519         "aten/src/ATen/native/cuda/TriangularOps.cu.cc",
  520         "aten/src/ATen/native/cuda/UnaryOpsKernel.cu.cc",
  521         "aten/src/ATen/native/cuda/Unique.cu.cc",
  522         "aten/src/ATen/native/cuda/UpSampleBicubic2d.cu.cc",
  523         "aten/src/ATen/native/cuda/UpSampleBilinear2d.cu.cc",
  524         "aten/src/ATen/native/cuda/UpSampleLinear1d.cu.cc",
  525         "aten/src/ATen/native/cuda/UpSampleNearest1d.cu.cc",
  526         "aten/src/ATen/native/cuda/UpSampleNearest2d.cu.cc",
  527         "aten/src/ATen/native/cuda/UpSampleNearest3d.cu.cc",
  528         "aten/src/ATen/native/cuda/UpSampleTrilinear3d.cu.cc",
  529         "aten/src/ATen/native/cuda/WeightNorm.cu.cc",
  530         "aten/src/ATen/native/cuda/layer_norm_kernel.cu.cc",
  531         "aten/src/ATen/native/quantized/cuda/fake_quantize_core.cu.cc",
  532         "aten/src/ATen/native/sparse/cuda/SparseCUDABlas.cu.cc",
  533         "aten/src/ATen/native/sparse/cuda/SparseCUDATensor.cu.cc",
  534         "aten/src/ATen/native/sparse/cuda/SparseCUDATensorMath.cu.cc",
  535     ],
  536 )
  537 
  538 header_template_rule(
  539     name = "aten_src_ATen_config",
  540     src = "aten/src/ATen/Config.h.in",
  541     out = "aten/src/ATen/Config.h",
  542     substitutions = {
  543         "@AT_MKLDNN_ENABLED@": "1",
  544         "@AT_MKL_ENABLED@": "0",
  545         "@AT_FFTW_ENABLED@": "0",
  546         "@AT_NNPACK_ENABLED@": "0",
  547         "@CAFFE2_STATIC_LINK_CUDA_INT@": "0",
  548         "@USE_BLAS@": "1",
  549         "@AT_PARALLEL_OPENMP@": "0",
  550         "@AT_PARALLEL_NATIVE@": "1",
  551         "@AT_PARALLEL_NATIVE_TBB@": "0",
  552     },
  553 )
  554 
  555 header_template_rule(
  556     name = "aten_src_ATen_cuda_config",
  557     src = "aten/src/ATen/cuda/CUDAConfig.h.in",
  558     out = "aten/src/ATen/cuda/CUDAConfig.h",
  559     substitutions = {
  560         "@AT_CUDNN_ENABLED@": "1",
  561         "@AT_ROCM_ENABLED@": "0",
  562         "@NVCC_FLAGS_EXTRA@": "",
  563     },
  564 )
  565 
  566 header_template_rule(
  567     name = "aten_src_TH_THGeneral",
  568     src = "aten/src/TH/THGeneral.h.in",
  569     out = "aten/src/TH/THGeneral.h",
  570     substitutions = {
  571         "#cmakedefine USE_BLAS": "#define USE_BLAS",
  572         "#cmakedefine USE_LAPACK": "#define USE_LAPACK",
  573         "#cmakedefine BLAS_F2C": "/* #undef BLAS_F2C */",
  574         "#cmakedefine BLAS_USE_CBLAS_DOT": "#define BLAS_USE_CBLAS_DOT",
  575     },
  576 )
  577 
  578 header_template_rule(
  579     name = "aten_src_THC_THCGeneral",
  580     src = "aten/src/THC/THCGeneral.h.in",
  581     out = "aten/src/THC/THCGeneral.h",
  582     substitutions = {
  583         "#cmakedefine USE_MAGMA": "",
  584     },
  585 )
  586 
  587 cc_library(
  588     name = "aten_headers",
  589     hdrs = [
  590         "torch/csrc/WindowsTorchApiMacro.h",
  591         "torch/csrc/jit/frontend/function_schema_parser.h",
  592     ] + glob([
  593         "aten/src/**/*.h",
  594         "aten/src/**/*.hpp",
  595         "aten/src/TH/**/*.cpp",
  596         "aten/src/THC/**/*.cpp",
  597         "aten/src/THC/*.cuh",
  598         "aten/src/THC/generic/*.cu.cc",
  599         "aten/src/THCUNN/*.cuh",
  600         "aten/src/THCUNN/generic/*.cu.cc",
  601     ],
  602     exclude = [
  603         "aten/src/ATen/Config.h",
  604     ],) + [
  605         ":generated_cpp",
  606         ":aten_src_ATen_config",
  607     ],
  608     includes = [
  609         "aten/src",
  610         "aten/src/TH",
  611     ],
  612     deps = [
  613         ":c10_headers",
  614         ":aten_src_TH_THGeneral",
  615         ":aten_src_THC_THCGeneral",
  616     ],
  617 )
  618 
  619 ATEN_COPTS = COMMON_COPTS + [
  620     "-DUSE_AVX",
  621     "-DUSE_AVX2",
  622     "-DCAFFE2_BUILD_MAIN_LIBS",
  623     "-DHAVE_AVX_CPU_DEFINITION",
  624     "-DHAVE_AVX2_CPU_DEFINITION",
  625     "-fvisibility-inlines-hidden",
  626     "-fno-math-errno",
  627     "-fno-trapping-math",
  628 ]
  629 
  630 intern_build_aten_ops(
  631     copts = ATEN_COPTS,
  632     deps = [
  633         ":aten_headers",
  634         "@sleef",
  635         "@fbgemm",
  636     ],
  637 )
  638 
  639 cc_library(
  640     name = "th",
  641     srcs = [
  642         ":th_srcs",
  643     ],
  644     copts = ATEN_COPTS + [
  645         "-mavx",
  646     ],
  647     deps = [
  648         ":aten_headers",
  649         "@fbgemm",
  650     ],
  651 )
  652 
  653 cc_library(
  654     name = "aten",
  655     srcs = [
  656         ":ATen_CORE_SRCS",
  657         ":ATen_QUANTIZED_SRCS",
  658         ":aten_base_cpp",
  659         ":aten_base_metal",
  660         ":aten_base_vulkan",
  661         ":aten_native_cpp",
  662         ":aten_native_mkl_cpp",
  663         ":aten_native_mkldnn_cpp",
  664         ":aten_native_quantized_cpp",
  665         ":aten_native_sparse_cpp",
  666         ":aten_native_xnnpack",
  667         ":aten_src_ATen_config",
  668         ":generated_cpp",
  669     ],
  670     copts = ATEN_COPTS,
  671     data = if_cuda(
  672         [":libcaffe2_nvrtc.so"],
  673         [],
  674     ),
  675     visibility = ["//visibility:public"],
  676     deps = [
  677         ":ATen_CPU",
  678         ":aten_headers",
  679         ":caffe2_for_aten_headers",
  680         ":th",
  681         ":torch_headers",
  682         "@fbgemm",
  683         "@ideep",
  684     ],
  685     alwayslink = True,
  686 )
  687 
  688 cc_library(
  689     name = "aten_nvrtc",
  690     srcs = glob([
  691         "aten/src/ATen/cuda/nvrtc_stub/*.cpp",
  692     ]),
  693     copts = ATEN_COPTS,
  694     linkstatic = True,
  695     visibility = ["//visibility:public"],
  696     deps = [
  697         ":aten_headers",
  698         ":c10_headers",
  699         "@cuda",
  700         "@cuda//:cuda_driver",
  701         "@cuda//:nvrtc",
  702     ],
  703     alwayslink = True,
  704 )
  705 
  706 cc_binary(
  707     name = "libcaffe2_nvrtc.so",
  708     linkshared = True,
  709     visibility = ["//visibility:public"],
  710     deps = [
  711         ":aten_nvrtc",
  712     ],
  713 )
  714 
  715 cc_library(
  716     name = "aten_cuda_cpp",
  717     srcs = [":aten_cuda_srcs"],
  718     copts = ATEN_COPTS,
  719     visibility = ["//visibility:public"],
  720     deps = [
  721         ":aten",
  722         "@cuda",
  723         "@cuda//:nvrtc",
  724         "@cudnn",
  725     ],
  726     alwayslink = True,
  727 )
  728 
  729 torch_cuda_half_options = [
  730     "-DCUDA_HAS_FP16=1",
  731     "-D__CUDA_NO_HALF_OPERATORS__",
  732     "-D__CUDA_NO_HALF_CONVERSIONS__",
  733     "-D__CUDA_NO_BFLOAT16_CONVERSIONS__",
  734     "-D__CUDA_NO_HALF2_OPERATORS__",
  735 ]
  736 
  737 cu_library(
  738     name = "aten_cuda",
  739     srcs = [
  740         ":aten_srcs_cu",
  741         ":thc_srcs_cu",
  742         ":thcunn_srcs_cu",
  743     ],
  744     copts = ATEN_COPTS + torch_cuda_half_options,
  745     visibility = ["//visibility:public"],
  746     deps = [
  747         ":aten_cuda_cpp",
  748         "@cuda//:cublas",
  749         "@cuda//:cufft",
  750         "@cuda//:cusparse",
  751     ],
  752     alwayslink = True,
  753 )
  754 
  755 # caffe2
  756 CAFFE2_COPTS = COMMON_COPTS + [
  757     "-Dcaffe2_EXPORTS",
  758     "-DCAFFE2_USE_GLOO",
  759     "-DCAFFE2_USE_CUDNN",
  760     "-DCAFFE2_BUILD_MAIN_LIB",
  761     "-fvisibility-inlines-hidden",
  762     "-fno-math-errno",
  763     "-fno-trapping-math",
  764 ]
  765 
  766 proto_library(
  767     name = "caffe2_proto_source",
  768     srcs = glob([
  769         "caffe2/proto/*.proto",
  770     ]),
  771     visibility = ["//visibility:public"],
  772 )
  773 
  774 cc_proto_library(
  775     name = "caffe2_protos",
  776     deps = [":caffe2_proto_source"],
  777 )
  778 
  779 header_template_rule(
  780     name = "caffe2_core_macros_h",
  781     src = "caffe2/core/macros.h.in",
  782     out = "caffe2/core/macros.h",
  783     substitutions = {
  784         "@CAFFE2_VERSION_MAJOR@": "1",
  785         "@CAFFE2_VERSION_MINOR@": "3",
  786         "@CAFFE2_VERSION_PATCH@": "0",
  787         "cmakedefine": "define",
  788         "#define CAFFE2_FORCE_FALLBACK_CUDA_MPI": "/* #undef CAFFE2_FORCE_FALLBACK_CUDA_MPI */",
  789         "#define CAFFE2_HAS_MKL_DNN": "/* #undef CAFFE2_HAS_MKL_DNN */",
  790         "#define CAFFE2_HAS_MKL_SGEMM_PACK": "/* #undef CAFFE2_HAS_MKL_SGEMM_PACK */",
  791         "#define CAFFE2_THREADPOOL_MAIN_IMBALANCE": "/* #undef CAFFE2_THREADPOOL_MAIN_IMBALANCE */",
  792         "#define CAFFE2_THREADPOOL_STATS": "/* #undef CAFFE2_THREADPOOL_STATS */",
  793         "#define CAFFE2_USE_ACCELERATE": "/* #undef CAFFE2_USE_ACCELERATE */",
  794         "#define CAFFE2_USE_EIGEN_FOR_BLAS": "/* #undef CAFFE2_USE_EIGEN_FOR_BLAS */",
  795         "#define CAFFE2_USE_FBCODE": "/* #undef CAFFE2_USE_FBCODE */",
  796         "#define CAFFE2_USE_GOOGLE_GLOG": "/* #undef CAFFE2_USE_GOOGLE_GLOG */",
  797         "#define CAFFE2_USE_LITE_PROTO": "/* #undef CAFFE2_USE_LITE_PROTO */",
  798         "#define CAFFE2_USE_MKL\n": "/* #undef CAFFE2_USE_MKL */\n",
  799         "#define CAFFE2_USE_NVTX": "/* #undef CAFFE2_USE_NVTX */",
  800         "#define CAFFE2_USE_TRT": "/* #undef CAFFE2_USE_TRT */",
  801     },
  802 )
  803 
  804 filegroup(
  805     name = "caffe2_contrib_srcs",
  806     srcs = [
  807         "caffe2/contrib/gloo/allgather_ops.cc",
  808         "caffe2/contrib/gloo/allreduce_ops.cc",
  809         "caffe2/contrib/gloo/barrier_ops.cc",
  810         "caffe2/contrib/gloo/broadcast_ops.cc",
  811         "caffe2/contrib/gloo/common.cc",
  812         "caffe2/contrib/gloo/common_world_ops.cc",
  813         "caffe2/contrib/gloo/context.cc",
  814         "caffe2/contrib/gloo/reduce_scatter_ops.cc",
  815         "caffe2/contrib/gloo/store_handler.cc",
  816     ],
  817 )
  818 
  819 filegroup(
  820     name = "caffe2_core_srcs",
  821     srcs = [
  822         "caffe2/core/allocator.cc",
  823         "caffe2/core/blob_serialization.cc",
  824         "caffe2/core/blob_stats.cc",
  825         "caffe2/core/common.cc",
  826         "caffe2/core/context.cc",
  827         "caffe2/core/context_base.cc",
  828         "caffe2/core/db.cc",
  829         "caffe2/core/event.cc",
  830         "caffe2/core/export_c10_op_to_caffe2.cc",
  831         "caffe2/core/graph.cc",
  832         "caffe2/core/init.cc",
  833         "caffe2/core/init_denormals.cc",
  834         "caffe2/core/init_intrinsics_check.cc",
  835         "caffe2/core/init_omp.cc",
  836         "caffe2/core/int8_serialization.cc",
  837         "caffe2/core/memonger.cc",
  838         "caffe2/core/module.cc",
  839         "caffe2/core/net.cc",
  840         "caffe2/core/net_async_base.cc",
  841         "caffe2/core/net_async_scheduling.cc",
  842         "caffe2/core/net_async_task.cc",
  843         "caffe2/core/net_async_task_future.cc",
  844         "caffe2/core/net_async_task_graph.cc",
  845         "caffe2/core/net_async_tracing.cc",
  846         "caffe2/core/net_dag_utils.cc",
  847         "caffe2/core/net_parallel.cc",
  848         "caffe2/core/net_simple.cc",
  849         "caffe2/core/net_simple_refcount.cc",
  850         "caffe2/core/nomnigraph/Representations/NeuralNet.cc",
  851         "caffe2/core/nomnigraph/tests/test_util.cc",
  852         "caffe2/core/numa.cc",
  853         "caffe2/core/operator.cc",
  854         "caffe2/core/operator_schema.cc",
  855         "caffe2/core/plan_executor.cc",
  856         "caffe2/core/prof_dag_counters.cc",
  857         "caffe2/core/qtensor.cc",
  858         "caffe2/core/qtensor_serialization.cc",
  859         "caffe2/core/stats.cc",
  860         "caffe2/core/tensor.cc",
  861         "caffe2/core/tensor_int8.cc",
  862         "caffe2/core/test_utils.cc",
  863         "caffe2/core/transform.cc",
  864         "caffe2/core/types.cc",
  865         "caffe2/core/workspace.cc",
  866     ],
  867 )
  868 
  869 filegroup(
  870     name = "caffe2_distributed_srcs",
  871     srcs = [
  872         "caffe2/distributed/file_store_handler.cc",
  873         "caffe2/distributed/file_store_handler_op.cc",
  874         "caffe2/distributed/store_handler.cc",
  875         "caffe2/distributed/store_ops.cc",
  876     ],
  877 )
  878 
  879 filegroup(
  880     name = "caffe2_ideep_srcs",
  881     srcs = [
  882         "caffe2/ideep/operators/adam_op.cc",
  883         "caffe2/ideep/operators/channel_shuffle_op.cc",
  884         "caffe2/ideep/operators/concat_split_op.cc",
  885         "caffe2/ideep/operators/conv_op.cc",
  886         "caffe2/ideep/operators/conv_transpose_op.cc",
  887         "caffe2/ideep/operators/dropout_op.cc",
  888         "caffe2/ideep/operators/elementwise_sum_op.cc",
  889         "caffe2/ideep/operators/expand_squeeze_dims_op.cc",
  890         "caffe2/ideep/operators/fully_connected_op.cc",
  891         "caffe2/ideep/operators/local_response_normalization_op.cc",
  892         "caffe2/ideep/operators/momentum_sgd_op.cc",
  893         "caffe2/ideep/operators/operator_fallback_ideep.cc",
  894         "caffe2/ideep/operators/order_switch_ops.cc",
  895         "caffe2/ideep/operators/pool_op.cc",
  896         "caffe2/ideep/operators/quantization/int8_add_op.cc",
  897         "caffe2/ideep/operators/quantization/int8_conv_op.cc",
  898         "caffe2/ideep/operators/quantization/int8_dequantize_op.cc",
  899         "caffe2/ideep/operators/quantization/int8_fully_connected_op.cc",
  900         "caffe2/ideep/operators/quantization/int8_given_tensor_fill_op.cc",
  901         "caffe2/ideep/operators/quantization/int8_pool_op.cc",
  902         "caffe2/ideep/operators/quantization/int8_quantize_op.cc",
  903         "caffe2/ideep/operators/quantization/int8_relu_op.cc",
  904         "caffe2/ideep/operators/queue_ops.cc",
  905         "caffe2/ideep/operators/relu_op.cc",
  906         "caffe2/ideep/operators/reshape_op.cc",
  907         "caffe2/ideep/operators/shape_op.cc",
  908         "caffe2/ideep/operators/sigmoid_op.cc",
  909         "caffe2/ideep/operators/spatial_batch_norm_op.cc",
  910         "caffe2/ideep/operators/transpose_op.cc",
  911         "caffe2/ideep/operators/utility_ops.cc",
  912         "caffe2/ideep/utils/ideep_register.cc",
  913     ],
  914 )
  915 
  916 filegroup(
  917     name = "caffe2_onnx_srcs",
  918     srcs = [
  919         "caffe2/onnx/backend.cc",
  920         "caffe2/onnx/backend_rep.cc",
  921         "caffe2/onnx/device.cc",
  922         "caffe2/onnx/helper.cc",
  923         "caffe2/onnx/offline_tensor.cc",
  924         "caffe2/onnx/onnx_exporter.cc",
  925         "caffe2/onnx/onnxifi_graph_info.cc",
  926         "caffe2/onnx/onnxifi_init.cc",
  927     ],
  928 )
  929 
  930 filegroup(
  931     name = "caffe2_operators_srcs",
  932     srcs = [
  933         "caffe2/operators/abs_op.cc",
  934         "caffe2/operators/accumulate_op.cc",
  935         "caffe2/operators/accuracy_op.cc",
  936         "caffe2/operators/acos_op.cc",
  937         "caffe2/operators/affine_channel_op.cc",
  938         "caffe2/operators/alias_with_name.cc",
  939         "caffe2/operators/apmeter_op.cc",
  940         "caffe2/operators/arg_ops.cc",
  941         "caffe2/operators/asin_op.cc",
  942         "caffe2/operators/assert_op.cc",
  943         "caffe2/operators/atan_op.cc",
  944         "caffe2/operators/atomic_ops.cc",
  945         "caffe2/operators/batch_box_cox_op.cc",
  946         "caffe2/operators/batch_bucketize_op.cc",
  947         "caffe2/operators/batch_gather_ops.cc",
  948         "caffe2/operators/batch_matmul_op.cc",
  949         "caffe2/operators/batch_moments_op.cc",
  950         "caffe2/operators/batch_permutation_op.cc",
  951         "caffe2/operators/batch_sparse_to_dense_op.cc",
  952         "caffe2/operators/bbox_transform_op.cc",
  953         "caffe2/operators/bisect_percentile_op.cc",
  954         "caffe2/operators/boolean_mask_ops.cc",
  955         "caffe2/operators/boolean_unmask_ops.cc",
  956         "caffe2/operators/box_with_nms_limit_op.cc",
  957         "caffe2/operators/bucketize_op.cc",
  958         "caffe2/operators/byte_weight_dequant_op.cc",
  959         "caffe2/operators/cast_op.cc",
  960         "caffe2/operators/cbrt_op.cc",
  961         "caffe2/operators/cc_bmm_bg_op.cc",
  962         "caffe2/operators/ceil_op.cc",
  963         "caffe2/operators/channel_backprop_stats_op.cc",
  964         "caffe2/operators/channel_shuffle_op.cc",
  965         "caffe2/operators/channel_stats_op.cc",
  966         "caffe2/operators/clip_op.cc",
  967         "caffe2/operators/collect_and_distribute_fpn_rpn_proposals_op.cc",
  968         "caffe2/operators/communicator_op.cc",
  969         "caffe2/operators/concat_split_op.cc",
  970         "caffe2/operators/conditional_op.cc",
  971         "caffe2/operators/conv_gradient_op.cc",
  972         "caffe2/operators/conv_op.cc",
  973         "caffe2/operators/conv_op_eigen.cc",
  974         "caffe2/operators/conv_op_shared.cc",
  975         "caffe2/operators/conv_transpose_gradient_op.cc",
  976         "caffe2/operators/conv_transpose_op_mobile.cc",
  977         "caffe2/operators/copy_op.cc",
  978         "caffe2/operators/copy_rows_to_tensor_op.cc",
  979         "caffe2/operators/cos_op.cc",
  980         "caffe2/operators/cosh_op.cc",
  981         "caffe2/operators/cosine_embedding_criterion_op.cc",
  982         "caffe2/operators/counter_ops.cc",
  983         "caffe2/operators/crash_op.cc",
  984         "caffe2/operators/create_scope_op.cc",
  985         "caffe2/operators/crf_viterbi_op.cc",
  986         "caffe2/operators/cross_entropy_op.cc",
  987         "caffe2/operators/ctc_beam_search_decoder_op.cc",
  988         "caffe2/operators/ctc_greedy_decoder_op.cc",
  989         "caffe2/operators/cube_op.cc",
  990         "caffe2/operators/data_couple.cc",
  991         "caffe2/operators/dataset_ops.cc",
  992         "caffe2/operators/deform_conv_gradient_op.cc",
  993         "caffe2/operators/deform_conv_op.cc",
  994         "caffe2/operators/dense_vector_to_id_list_op.cc",
  995         "caffe2/operators/distance_op.cc",
  996         "caffe2/operators/do_op.cc",
  997         "caffe2/operators/dropout_op.cc",
  998         "caffe2/operators/elementwise_add_gradient_op.cc",
  999         "caffe2/operators/elementwise_add_op.cc",
 1000         "caffe2/operators/elementwise_div_gradient_op.cc",
 1001         "caffe2/operators/elementwise_div_op.cc",
 1002         "caffe2/operators/elementwise_linear_op.cc",
 1003         "caffe2/operators/elementwise_logical_ops.cc",
 1004         "caffe2/operators/elementwise_mul_gradient_op.cc",
 1005         "caffe2/operators/elementwise_mul_op.cc",
 1006         "caffe2/operators/elementwise_ops.cc",
 1007         "caffe2/operators/elementwise_ops_schema.cc",
 1008         "caffe2/operators/elementwise_ops_utils.cc",
 1009         "caffe2/operators/elementwise_sub_gradient_op.cc",
 1010         "caffe2/operators/elementwise_sub_op.cc",
 1011         "caffe2/operators/elementwise_sum_op.cc",
 1012         "caffe2/operators/elu_op.cc",
 1013         "caffe2/operators/enforce_finite_op.cc",
 1014         "caffe2/operators/ensure_clipped_op.cc",
 1015         "caffe2/operators/ensure_cpu_output_op.cc",
 1016         "caffe2/operators/erf_op.cc",
 1017         "caffe2/operators/exp_op.cc",
 1018         "caffe2/operators/expand_op.cc",
 1019         "caffe2/operators/expand_squeeze_dims_op.cc",
 1020         "caffe2/operators/fc_inference.cc",
 1021         "caffe2/operators/feature_maps_ops.cc",
 1022         "caffe2/operators/feed_blob_op.cc",
 1023         "caffe2/operators/filler_op.cc",
 1024         "caffe2/operators/find_duplicate_elements_op.cc",
 1025         "caffe2/operators/find_op.cc",
 1026         "caffe2/operators/flatten_op.cc",
 1027         "caffe2/operators/flexible_top_k.cc",
 1028         "caffe2/operators/floor_op.cc",
 1029         "caffe2/operators/free_op.cc",
 1030         "caffe2/operators/fully_connected_op.cc",
 1031         "caffe2/operators/fused_rowwise_8bit_conversion_ops.cc",
 1032         "caffe2/operators/fused_rowwise_random_quantization_ops.cc",
 1033         "caffe2/operators/gather_fused_8bit_rowwise_op.cc",
 1034         "caffe2/operators/gather_op.cc",
 1035         "caffe2/operators/gather_ranges_to_dense_op.cc",
 1036         "caffe2/operators/gelu_op.cc",
 1037         "caffe2/operators/generate_proposals_op.cc",
 1038         "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.cc",
 1039         "caffe2/operators/given_tensor_fill_op.cc",
 1040         "caffe2/operators/glu_op.cc",
 1041         "caffe2/operators/group_norm_op.cc",
 1042         "caffe2/operators/gru_unit_op.cc",
 1043         "caffe2/operators/h_softmax_op.cc",
 1044         "caffe2/operators/half_float_ops.cc",
 1045         "caffe2/operators/hard_sigmoid_op.cc",
 1046         "caffe2/operators/heatmap_max_keypoint_op.cc",
 1047         "caffe2/operators/if_op.cc",
 1048         "caffe2/operators/im2col_op.cc",
 1049         "caffe2/operators/index_hash_ops.cc",
 1050         "caffe2/operators/index_ops.cc",
 1051         "caffe2/operators/inference_lstm_op.cc",
 1052         "caffe2/operators/instance_norm_gradient_op.cc",
 1053         "caffe2/operators/instance_norm_op.cc",
 1054         "caffe2/operators/integral_image_op.cc",
 1055         "caffe2/operators/is_empty_op.cc",
 1056         "caffe2/operators/jsd_op.cc",
 1057         "caffe2/operators/key_split_ops.cc",
 1058         "caffe2/operators/last_n_window_collector.cc",
 1059         "caffe2/operators/layer_norm_op.cc",
 1060         "caffe2/operators/leaky_relu_op.cc",
 1061         "caffe2/operators/length_split_op.cc",
 1062         "caffe2/operators/lengths_pad_op.cc",
 1063         "caffe2/operators/lengths_reducer_fused_8bit_rowwise_ops.cc",
 1064         "caffe2/operators/lengths_reducer_ops.cc",
 1065         "caffe2/operators/lengths_reducer_rowwise_8bit_ops.cc",
 1066         "caffe2/operators/lengths_tile_op.cc",
 1067         "caffe2/operators/lengths_top_k_op.cc",
 1068         "caffe2/operators/listwise_l2r_op.cc",
 1069         "caffe2/operators/load_save_op.cc",
 1070         "caffe2/operators/load_save_op_util.cc",
 1071         "caffe2/operators/local_response_normalization_op.cc",
 1072         "caffe2/operators/locally_connected_op.cc",
 1073         "caffe2/operators/locally_connected_op_util.cc",
 1074         "caffe2/operators/log_op.cc",
 1075         "caffe2/operators/logit_op.cc",
 1076         "caffe2/operators/loss_op.cc",
 1077         "caffe2/operators/lp_pool_op.cc",
 1078         "caffe2/operators/lpnorm_op.cc",
 1079         "caffe2/operators/lstm_unit_op.cc",
 1080         "caffe2/operators/map_ops.cc",
 1081         "caffe2/operators/margin_ranking_criterion_op.cc",
 1082         "caffe2/operators/matmul_op.cc",
 1083         "caffe2/operators/mean_op.cc",
 1084         "caffe2/operators/merge_id_lists_op.cc",
 1085         "caffe2/operators/minmax_gradient_ops.cc",
 1086         "caffe2/operators/minmax_ops.cc",
 1087         "caffe2/operators/mod_op.cc",
 1088         "caffe2/operators/moments_op.cc",
 1089         "caffe2/operators/multi_class_accuracy_op.cc",
 1090         "caffe2/operators/negate_gradient_op.cc",
 1091         "caffe2/operators/negative_op.cc",
 1092         "caffe2/operators/ngram_ops.cc",
 1093         "caffe2/operators/norm_planar_yuv_op.cc",
 1094         "caffe2/operators/normalize_l1_op.cc",
 1095         "caffe2/operators/normalize_op.cc",
 1096         "caffe2/operators/numpy_tile_op.cc",
 1097         "caffe2/operators/one_hot_ops.cc",
 1098         "caffe2/operators/onnx_while_op.cc",
 1099         "caffe2/operators/order_switch_ops.cc",
 1100         "caffe2/operators/pack_rnn_sequence_op.cc",
 1101         "caffe2/operators/pack_segments.cc",
 1102         "caffe2/operators/pad_op.cc",
 1103         "caffe2/operators/partition_ops.cc",
 1104         "caffe2/operators/percentile_op.cc",
 1105         "caffe2/operators/perplexity_op.cc",
 1106         "caffe2/operators/piecewise_linear_transform_op.cc",
 1107         "caffe2/operators/pool_gradient_op.cc",
 1108         "caffe2/operators/pool_op.cc",
 1109         "caffe2/operators/pool_op_util.cc",
 1110         "caffe2/operators/pow_op.cc",
 1111         "caffe2/operators/prelu_op.cc",
 1112         "caffe2/operators/prepend_dim_op.cc",
 1113         "caffe2/operators/quant_decode_op.cc",
 1114         "caffe2/operators/rank_loss_op.cc",
 1115         "caffe2/operators/reciprocal_gradient_op.cc",
 1116         "caffe2/operators/reciprocal_op.cc",
 1117         "caffe2/operators/reduce_front_back_max_ops.cc",
 1118         "caffe2/operators/reduce_front_back_mean_ops.cc",
 1119         "caffe2/operators/reduce_front_back_sum_ops.cc",
 1120         "caffe2/operators/reduce_ops.cc",
 1121         "caffe2/operators/reduction_ops.cc",
 1122         "caffe2/operators/relu_n_op.cc",
 1123         "caffe2/operators/relu_op.cc",
 1124         "caffe2/operators/remove_data_blocks_op.cc",
 1125         "caffe2/operators/replace_nan_op.cc",
 1126         "caffe2/operators/reservoir_sampling.cc",
 1127         "caffe2/operators/reshape_op.cc",
 1128         "caffe2/operators/resize_3d_op.cc",
 1129         "caffe2/operators/resize_op.cc",
 1130         "caffe2/operators/reverse_packed_segs_op.cc",
 1131         "caffe2/operators/rmac_regions_op.cc",
 1132         "caffe2/operators/rnn/recurrent_network_blob_fetcher_op.cc",
 1133         "caffe2/operators/rnn/recurrent_network_executor.cc",
 1134         "caffe2/operators/rnn/recurrent_network_op.cc",
 1135         "caffe2/operators/roi_align_gradient_op.cc",
 1136         "caffe2/operators/roi_align_op.cc",
 1137         "caffe2/operators/roi_align_rotated_gradient_op.cc",
 1138         "caffe2/operators/roi_align_rotated_op.cc",
 1139         "caffe2/operators/roi_pool_op.cc",
 1140         "caffe2/operators/rowmul_op.cc",
 1141         "caffe2/operators/rsqrt_op.cc",
 1142         "caffe2/operators/scale_blobs_op.cc",
 1143         "caffe2/operators/scale_op.cc",
 1144         "caffe2/operators/segment_reduction_op.cc",
 1145         "caffe2/operators/selu_op.cc",
 1146         "caffe2/operators/sequence_ops.cc",
 1147         "caffe2/operators/shape_op.cc",
 1148         "caffe2/operators/sigmoid_gradient_op.cc",
 1149         "caffe2/operators/sigmoid_op.cc",
 1150         "caffe2/operators/sin_op.cc",
 1151         "caffe2/operators/sinh_op.cc",
 1152         "caffe2/operators/sinusoid_position_encoding_op.cc",
 1153         "caffe2/operators/slice_op.cc",
 1154         "caffe2/operators/softmax_op.cc",
 1155         "caffe2/operators/softmax_utils.cc",
 1156         "caffe2/operators/softmax_with_loss_op.cc",
 1157         "caffe2/operators/softplus_op.cc",
 1158         "caffe2/operators/softsign_op.cc",
 1159         "caffe2/operators/space_batch_op.cc",
 1160         "caffe2/operators/sparse_dropout_with_replacement_op.cc",
 1161         "caffe2/operators/sparse_normalize_op.cc",
 1162         "caffe2/operators/sparse_to_dense_mask_op.cc",
 1163         "caffe2/operators/sparse_to_dense_op.cc",
 1164         "caffe2/operators/spatial_batch_norm_gradient_op.cc",
 1165         "caffe2/operators/spatial_batch_norm_op.cc",
 1166         "caffe2/operators/spatial_softmax_with_loss_op.cc",
 1167         "caffe2/operators/sqr_op.cc",
 1168         "caffe2/operators/sqrt_op.cc",
 1169         "caffe2/operators/square_root_divide_op.cc",
 1170         "caffe2/operators/stats_ops.cc",
 1171         "caffe2/operators/stats_put_ops.cc",
 1172         "caffe2/operators/stop_gradient.cc",
 1173         "caffe2/operators/string_ops.cc",
 1174         "caffe2/operators/stump_func_op.cc",
 1175         "caffe2/operators/stylizer_ops.cc",
 1176         "caffe2/operators/summarize_op.cc",
 1177         "caffe2/operators/swish_op.cc",
 1178         "caffe2/operators/tan_op.cc",
 1179         "caffe2/operators/tanh_gradient_op.cc",
 1180         "caffe2/operators/tanh_op.cc",
 1181         "caffe2/operators/tensor_protos_db_input.cc",
 1182         "caffe2/operators/text_file_reader.cc",
 1183         "caffe2/operators/text_file_reader_utils.cc",
 1184         "caffe2/operators/thresholded_relu_op.cc",
 1185         "caffe2/operators/tile_op.cc",
 1186         "caffe2/operators/top_k.cc",
 1187         "caffe2/operators/transpose_op.cc",
 1188         "caffe2/operators/tt_linear_op.cc",
 1189         "caffe2/operators/unique_ops.cc",
 1190         "caffe2/operators/upsample_op.cc",
 1191         "caffe2/operators/utility_ops.cc",
 1192         "caffe2/operators/variable_length_sequence_padding.cc",
 1193         "caffe2/operators/weighted_multi_sampling_op.cc",
 1194         "caffe2/operators/weighted_sample_op.cc",
 1195         "caffe2/operators/while_op.cc",
 1196         "caffe2/operators/workspace_ops.cc",
 1197         "caffe2/operators/zero_gradient_op.cc",
 1198     ],
 1199 )
 1200 
 1201 filegroup(
 1202     name = "caffe2_opt_srcs",
 1203     srcs = [
 1204         "caffe2/opt/annotations.cc",
 1205         "caffe2/opt/backend_cutting.cc",
 1206         "caffe2/opt/backend_transformer_base.cc",
 1207         "caffe2/opt/bound_shape_inferencer.cc",
 1208         "caffe2/opt/converter.cc",
 1209         "caffe2/opt/dead_code_elim.cc",
 1210         "caffe2/opt/device.cc",
 1211         "caffe2/opt/distributed.cc",
 1212         "caffe2/opt/distributed_converter.cc",
 1213         "caffe2/opt/fusion.cc",
 1214         "caffe2/opt/mobile.cc",
 1215         "caffe2/opt/onnxifi_op.cc",
 1216         "caffe2/opt/onnxifi_transformer.cc",
 1217         "caffe2/opt/optimize_ideep.cc",
 1218         "caffe2/opt/optimizer.cc",
 1219         "caffe2/opt/passes.cc",
 1220         "caffe2/opt/shape_info.cc",
 1221         "caffe2/opt/tvm_transformer.cc",
 1222     ],
 1223 )
 1224 
 1225 filegroup(
 1226     name = "caffe2_perfkernels_srcs",
 1227     srcs = [
 1228         "caffe2/perfkernels/adagrad.cc",
 1229         "caffe2/perfkernels/embedding_lookup.cc",
 1230         "caffe2/perfkernels/embedding_lookup_idx.cc",
 1231         "caffe2/perfkernels/fused_8bit_rowwise_embedding_lookup.cc",
 1232         "caffe2/perfkernels/fused_8bit_rowwise_embedding_lookup_idx.cc",
 1233         "caffe2/perfkernels/fused_nbit_rowwise_conversion.cc",
 1234         "caffe2/perfkernels/lstm_unit_cpu_common.cc",
 1235         "caffe2/perfkernels/math_cpu_base.cc",
 1236         "caffe2/perfkernels/typed_axpy.cc",
 1237     ],
 1238 )
 1239 
 1240 filegroup(
 1241     name = "caffe2_predictor_srcs",
 1242     srcs = [
 1243         "caffe2/predictor/emulator/data_filler.cc",
 1244         "caffe2/predictor/emulator/data_filler.h",
 1245         "caffe2/predictor/predictor.cc",
 1246         "caffe2/predictor/predictor_config.cc",
 1247         "caffe2/predictor/predictor_utils.cc",
 1248     ],
 1249 )
 1250 
 1251 filegroup(
 1252     name = "caffe2_quantization_srcs",
 1253     srcs = [
 1254         "caffe2/quantization/server/activation_distribution_observer.cc",
 1255         "caffe2/quantization/server/batch_matmul_dnnlowp_op.cc",
 1256         "caffe2/quantization/server/caffe2_dnnlowp_utils.cc",
 1257         "caffe2/quantization/server/channel_shuffle_dnnlowp_op.cc",
 1258         "caffe2/quantization/server/concat_dnnlowp_op.cc",
 1259         "caffe2/quantization/server/conv_dnnlowp_acc16_op.cc",
 1260         "caffe2/quantization/server/conv_dnnlowp_op.cc",
 1261         "caffe2/quantization/server/conv_relu_op.cc",
 1262         "caffe2/quantization/server/dequantize_dnnlowp_op.cc",
 1263         "caffe2/quantization/server/dnnlowp.cc",
 1264         "caffe2/quantization/server/dnnlowp_partition.cc",
 1265         "caffe2/quantization/server/dynamic_histogram.cc",
 1266         "caffe2/quantization/server/elementwise_add_dnnlowp_op.cc",
 1267         "caffe2/quantization/server/elementwise_linear_dnnlowp_op.cc",
 1268         "caffe2/quantization/server/elementwise_mul_dnnlowp_op.cc",
 1269         "caffe2/quantization/server/elementwise_sum_dnnlowp_op.cc",
 1270         "caffe2/quantization/server/elementwise_sum_relu_op.cc",
 1271         "caffe2/quantization/server/fbgemm_pack_matrix_cache.cc",
 1272         "caffe2/quantization/server/fbgemm_pack_op.cc",
 1273         "caffe2/quantization/server/fully_connected_dnnlowp_acc16_op.cc",
 1274         "caffe2/quantization/server/fully_connected_dnnlowp_op.cc",
 1275         "caffe2/quantization/server/fully_connected_fake_lowp_op.cc",
 1276         "caffe2/quantization/server/group_norm_dnnlowp_op.cc",
 1277         "caffe2/quantization/server/int8_gen_quant_params.cc",
 1278         "caffe2/quantization/server/kl_minimization.cc",
 1279         "caffe2/quantization/server/lstm_unit_dnnlowp_op.cc",
 1280         "caffe2/quantization/server/norm_minimization.cc",
 1281         "caffe2/quantization/server/p99.cc",
 1282         "caffe2/quantization/server/pool_dnnlowp_op.cc",
 1283         "caffe2/quantization/server/quantize_dnnlowp_op.cc",
 1284         "caffe2/quantization/server/relu_dnnlowp_op.cc",
 1285         "caffe2/quantization/server/sigmoid.cc",
 1286         "caffe2/quantization/server/sigmoid_dnnlowp_op.cc",
 1287         "caffe2/quantization/server/spatial_batch_norm_dnnlowp_op.cc",
 1288         "caffe2/quantization/server/tanh.cc",
 1289         "caffe2/quantization/server/tanh_dnnlowp_op.cc",
 1290         "caffe2/quantization/server/utility_dnnlowp_ops.cc",
 1291     ],
 1292 )
 1293 
 1294 filegroup(
 1295     name = "caffe2_queue_srcs",
 1296     srcs = [
 1297         "caffe2/queue/blobs_queue.cc",
 1298         "caffe2/queue/blobs_queue_db.cc",
 1299         "caffe2/queue/queue_ops.cc",
 1300         "caffe2/queue/rebatching_queue.cc",
 1301         "caffe2/queue/rebatching_queue_ops.cc",
 1302     ],
 1303 )
 1304 
 1305 filegroup(
 1306     name = "caffe2_serialize_srcs",
 1307     srcs = [
 1308         "caffe2/serialize/file_adapter.cc",
 1309         "caffe2/serialize/inline_container.cc",
 1310         "caffe2/serialize/istream_adapter.cc",
 1311         "caffe2/serialize/read_adapter_interface.cc",
 1312     ],
 1313 )
 1314 
 1315 filegroup(
 1316     name = "caffe2_sgd_srcs",
 1317     srcs = [
 1318         "caffe2/sgd/adadelta_op.cc",
 1319         "caffe2/sgd/adagrad_op.cc",
 1320         "caffe2/sgd/adam_op.cc",
 1321         "caffe2/sgd/clip_tensor_op.cc",
 1322         "caffe2/sgd/ftrl_op.cc",
 1323         "caffe2/sgd/gftrl_op.cc",
 1324         "caffe2/sgd/iter_op.cc",
 1325         "caffe2/sgd/lars_op.cc",
 1326         "caffe2/sgd/learning_rate_adaption_op.cc",
 1327         "caffe2/sgd/learning_rate_op.cc",
 1328         "caffe2/sgd/momentum_sgd_op.cc",
 1329         "caffe2/sgd/rmsprop_op.cc",
 1330         "caffe2/sgd/wngrad_op.cc",
 1331         "caffe2/sgd/yellowfin_op.cc",
 1332     ],
 1333 )
 1334 
 1335 filegroup(
 1336     name = "caffe2_transforms_srcs",
 1337     srcs = [
 1338         "caffe2/transforms/common_subexpression_elimination.cc",
 1339         "caffe2/transforms/conv_to_nnpack_transform.cc",
 1340         "caffe2/transforms/pattern_net_transform.cc",
 1341         "caffe2/transforms/single_op_transform.cc",
 1342     ],
 1343 )
 1344 
 1345 filegroup(
 1346     name = "caffe2_utils_srcs",
 1347     srcs = [
 1348         "caffe2/utils/bench_utils.cc",
 1349         "caffe2/utils/cpuid.cc",
 1350         "caffe2/utils/math/broadcast.cc",
 1351         "caffe2/utils/math/elementwise.cc",
 1352         "caffe2/utils/math/reduce.cc",
 1353         "caffe2/utils/math/transpose.cc",
 1354         "caffe2/utils/math/utils.cc",
 1355         "caffe2/utils/math_cpu.cc",
 1356         "caffe2/utils/murmur_hash3.cc",
 1357         "caffe2/utils/proto_convert.cc",
 1358         "caffe2/utils/proto_utils.cc",
 1359         "caffe2/utils/proto_wrap.cc",
 1360         "caffe2/utils/signal_handler.cc",
 1361         "caffe2/utils/smart_tensor_printer.cc",
 1362         "caffe2/utils/string_utils.cc",
 1363         "caffe2/utils/threadpool/ThreadPool.cc",
 1364         "caffe2/utils/threadpool/pthreadpool.cc",
 1365         "caffe2/utils/threadpool/pthreadpool_impl.cc",
 1366     ],
 1367 )
 1368 
 1369 filegroup(
 1370     name = "caffe2_cuda_srcs",
 1371     srcs = [
 1372         "caffe2/contrib/aten/aten_op_gpu.cc",
 1373         "caffe2/contrib/gloo/allreduce_ops_gpu.cc",
 1374         "caffe2/contrib/gloo/broadcast_ops_gpu.cc",
 1375         "caffe2/contrib/gloo/common_world_ops_gpu.cc",
 1376         "caffe2/core/blob_serialization_gpu.cc",
 1377         "caffe2/core/common_cudnn.cc",
 1378         "caffe2/core/common_gpu.cc",
 1379         "caffe2/core/event_gpu.cc",
 1380         "caffe2/db/create_db_op_gpu.cc",
 1381         "caffe2/distributed/file_store_handler_op_gpu.cc",
 1382         "caffe2/operators/communicator_op_gpu.cc",
 1383         "caffe2/operators/concat_split_op_gpu.cc",
 1384         "caffe2/operators/conv_op_cache_cudnn.cc",
 1385         "caffe2/operators/conv_op_cudnn.cc",
 1386         "caffe2/operators/conv_op_gpu.cc",
 1387         "caffe2/operators/conv_op_shared_gpu.cc",
 1388         "caffe2/operators/conv_transpose_op_cudnn.cc",
 1389         "caffe2/operators/conv_transpose_op_gpu.cc",
 1390         "caffe2/operators/counter_ops_gpu.cc",
 1391         "caffe2/operators/do_op_gpu.cc",
 1392         "caffe2/operators/dropout_op_cudnn.cc",
 1393         "caffe2/operators/elementwise_add_op_gpu.cc",
 1394         "caffe2/operators/elementwise_sub_op_gpu.cc",
 1395         "caffe2/operators/elu_op_cudnn.cc",
 1396         "caffe2/operators/exp_op_gpu.cc",
 1397         "caffe2/operators/expand_op_gpu.cc",
 1398         "caffe2/operators/expand_squeeze_dims_op_gpu.cc",
 1399         "caffe2/operators/free_op_gpu.cc",
 1400         "caffe2/operators/fully_connected_op_gpu.cc",
 1401         "caffe2/operators/if_op_gpu.cc",
 1402         "caffe2/operators/im2col_op_gpu.cc",
 1403         "caffe2/operators/load_save_op_gpu.cc",
 1404         "caffe2/operators/local_response_normalization_op_cudnn.cc",
 1405         "caffe2/operators/locally_connected_op_gpu.cc",
 1406         "caffe2/operators/log_op_gpu.cc",
 1407         "caffe2/operators/matmul_op_gpu.cc",
 1408         "caffe2/operators/negate_gradient_op_gpu.cc",
 1409         "caffe2/operators/negative_op_gpu.cc",
 1410         "caffe2/operators/order_switch_ops_cudnn.cc",
 1411         "caffe2/operators/order_switch_ops_gpu.cc",
 1412         "caffe2/operators/pool_op_cudnn.cc",
 1413         "caffe2/operators/prepend_dim_op_gpu.cc",
 1414         "caffe2/operators/reshape_op_gpu.cc",
 1415         "caffe2/operators/rnn/recurrent_network_blob_fetcher_op_gpu.cc",
 1416         "caffe2/operators/rnn/recurrent_network_executor_gpu.cc",
 1417         "caffe2/operators/rnn/recurrent_op_cudnn.cc",
 1418         "caffe2/operators/scale_op_gpu.cc",
 1419         "caffe2/operators/shape_op_gpu.cc",
 1420         "caffe2/operators/sigmoid_op_cudnn.cc",
 1421         "caffe2/operators/softmax_op_cudnn.cc",
 1422         "caffe2/operators/sqr_op_gpu.cc",
 1423         "caffe2/operators/sqrt_op_gpu.cc",
 1424         "caffe2/operators/stop_gradient_gpu.cc",
 1425         "caffe2/operators/tanh_op_cudnn.cc",
 1426         "caffe2/operators/tensor_protos_db_input_gpu.cc",
 1427         "caffe2/operators/transpose_op_cudnn.cc",
 1428         "caffe2/operators/while_op_gpu.cc",
 1429         "caffe2/operators/zero_gradient_op_gpu.cc",
 1430         "caffe2/queue/queue_ops_gpu.cc",
 1431         "caffe2/sgd/iter_op_gpu.cc",
 1432         "caffe2/sgd/learning_rate_op_gpu.cc",
 1433     ],
 1434 )
 1435 
 1436 filegroup(
 1437     name = "caffe2_cu_srcs",
 1438     srcs = [
 1439         "caffe2/core/context_gpu.cu.cc",
 1440         "caffe2/operators/abs_op.cu.cc",
 1441         "caffe2/operators/accumulate_op.cu.cc",
 1442         "caffe2/operators/accuracy_op.cu.cc",
 1443         "caffe2/operators/acos_op.cu.cc",
 1444         "caffe2/operators/affine_channel_op.cu.cc",
 1445         "caffe2/operators/alias_with_name.cu.cc",
 1446         "caffe2/operators/arg_ops.cu.cc",
 1447         "caffe2/operators/asin_op.cu.cc",
 1448         "caffe2/operators/assert_op.cu.cc",
 1449         "caffe2/operators/atan_op.cu.cc",
 1450         "caffe2/operators/batch_gather_ops.cu.cc",
 1451         "caffe2/operators/batch_matmul_op.cu.cc",
 1452         "caffe2/operators/batch_moments_op.cu.cc",
 1453         "caffe2/operators/batch_permutation_op.cu.cc",
 1454         "caffe2/operators/batch_sparse_to_dense_op.cu.cc",
 1455         "caffe2/operators/boolean_mask_ops.cu.cc",
 1456         "caffe2/operators/boolean_unmask_ops.cu.cc",
 1457         "caffe2/operators/bucketize_op.cu.cc",
 1458         "caffe2/operators/cast_op.cu.cc",
 1459         "caffe2/operators/cbrt_op.cu.cc",
 1460         "caffe2/operators/ceil_op.cu.cc",
 1461         "caffe2/operators/channel_backprop_stats_op.cu.cc",
 1462         "caffe2/operators/channel_shuffle_op.cu.cc",
 1463         "caffe2/operators/channel_stats_op.cu.cc",
 1464         "caffe2/operators/channelwise_conv3d_op_cudnn.cu.cc",
 1465         "caffe2/operators/clip_op.cu.cc",
 1466         "caffe2/operators/copy_op.cu.cc",
 1467         "caffe2/operators/cos_op.cu.cc",
 1468         "caffe2/operators/cosh_op.cu.cc",
 1469         "caffe2/operators/cosine_embedding_criterion_op.cu.cc",
 1470         "caffe2/operators/cross_entropy_op.cu.cc",
 1471         "caffe2/operators/cube_op.cu.cc",
 1472         "caffe2/operators/data_couple_gpu.cu.cc",
 1473         "caffe2/operators/deform_conv_op.cu.cc",
 1474         "caffe2/operators/depthwise_3x3_conv_op_cudnn.cu.cc",
 1475         "caffe2/operators/distance_op.cu.cc",
 1476         "caffe2/operators/dropout_op.cu.cc",
 1477         "caffe2/operators/elementwise_div_op.cu.cc",
 1478         "caffe2/operators/elementwise_linear_op.cu.cc",
 1479         "caffe2/operators/elementwise_mul_op.cu.cc",
 1480         "caffe2/operators/elementwise_ops.cu.cc",
 1481         "caffe2/operators/elu_op.cu.cc",
 1482         "caffe2/operators/enforce_finite_op.cu.cc",
 1483         "caffe2/operators/ensure_cpu_output_op.cu.cc",
 1484         "caffe2/operators/erf_op.cu.cc",
 1485         "caffe2/operators/filler_op.cu.cc",
 1486         "caffe2/operators/find_op.cu.cc",
 1487         "caffe2/operators/floor_op.cu.cc",
 1488         "caffe2/operators/gather_op.cu.cc",
 1489         "caffe2/operators/gelu_op.cu.cc",
 1490         "caffe2/operators/generate_proposals_op.cu.cc",
 1491         "caffe2/operators/generate_proposals_op_util_nms_gpu.cu.cc",
 1492         "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.cu.cc",
 1493         "caffe2/operators/given_tensor_fill_op.cu.cc",
 1494         "caffe2/operators/glu_op.cu.cc",
 1495         "caffe2/operators/group_norm_op.cu.cc",
 1496         "caffe2/operators/gru_unit_op_gpu.cu.cc",
 1497         "caffe2/operators/half_float_ops.cu.cc",
 1498         "caffe2/operators/hard_sigmoid_op.cu.cc",
 1499         "caffe2/operators/instance_norm_op.cu.cc",
 1500         "caffe2/operators/integral_image_op.cu.cc",
 1501         "caffe2/operators/layer_norm_op.cu.cc",
 1502         "caffe2/operators/leaky_relu_op.cu.cc",
 1503         "caffe2/operators/lengths_pad_op.cu.cc",
 1504         "caffe2/operators/lengths_tile_op.cu.cc",
 1505         "caffe2/operators/local_response_normalization_op.cu.cc",
 1506         "caffe2/operators/logit_op.cu.cc",
 1507         "caffe2/operators/loss_op.cu.cc",
 1508         "caffe2/operators/lp_pool_op.cu.cc",
 1509         "caffe2/operators/lstm_unit_op_gpu.cu.cc",
 1510         "caffe2/operators/margin_ranking_criterion_op.cu.cc",
 1511         "caffe2/operators/max_pool_with_index.cu.cc",
 1512         "caffe2/operators/mean_op.cu.cc",
 1513         "caffe2/operators/mem_query_op.cu.cc",
 1514         "caffe2/operators/minmax_ops.cu.cc",
 1515         "caffe2/operators/moments_op.cu.cc",
 1516         "caffe2/operators/multi_class_accuracy_op.cu.cc",
 1517         "caffe2/operators/normalize_ops.cu.cc",
 1518         "caffe2/operators/one_hot_ops.cu.cc",
 1519         "caffe2/operators/pack_segments.cu.cc",
 1520         "caffe2/operators/pad_op_gpu.cu.cc",
 1521         "caffe2/operators/perplexity_op.cu.cc",
 1522         "caffe2/operators/piecewise_linear_transform_op.cu.cc",
 1523         "caffe2/operators/pool_op.cu.cc",
 1524         "caffe2/operators/pow_op.cu.cc",
 1525         "caffe2/operators/prelu_op.cu.cc",
 1526         "caffe2/operators/reciprocal_op.cu.cc",
 1527         "caffe2/operators/reduce_front_back_max_ops.cu.cc",
 1528         "caffe2/operators/reduce_front_back_sum_mean_ops.cu.cc",
 1529         "caffe2/operators/reduce_ops.cu.cc",
 1530         "caffe2/operators/reduction_ops.cu.cc",
 1531         "caffe2/operators/relu_n_op.cu.cc",
 1532         "caffe2/operators/relu_op.cu.cc",
 1533         "caffe2/operators/replace_nan_op.cu.cc",
 1534         "caffe2/operators/resize_3d_op.cu.cc",
 1535         "caffe2/operators/resize_op.cu.cc",
 1536         "caffe2/operators/reverse_packed_segs_op.cu.cc",
 1537         "caffe2/operators/rmac_regions_op.cu.cc",
 1538         "caffe2/operators/rnn/recurrent_network_op_gpu.cu.cc",
 1539         "caffe2/operators/roi_align_gradient_op.cu.cc",
 1540         "caffe2/operators/roi_align_op.cu.cc",
 1541         "caffe2/operators/roi_align_rotated_gradient_op.cu.cc",
 1542         "caffe2/operators/roi_align_rotated_op.cu.cc",
 1543         "caffe2/operators/roi_pool_op.cu.cc",
 1544         "caffe2/operators/rsqrt_op.cu.cc",
 1545         "caffe2/operators/scale_blobs_op.cu.cc",
 1546         "caffe2/operators/segment_reduction_op_gpu.cu.cc",
 1547         "caffe2/operators/selu_op.cu.cc",
 1548         "caffe2/operators/sequence_ops.cu.cc",
 1549         "caffe2/operators/sigmoid_op.cu.cc",
 1550         "caffe2/operators/sin_op.cu.cc",
 1551         "caffe2/operators/sinh_op.cu.cc",
 1552         "caffe2/operators/slice_op.cu.cc",
 1553         "caffe2/operators/softmax_ops.cu.cc",
 1554         "caffe2/operators/softplus_op.cu.cc",
 1555         "caffe2/operators/softsign_op.cu.cc",
 1556         "caffe2/operators/space_batch_op_gpu.cu.cc",
 1557         "caffe2/operators/sparse_normalize_op_gpu.cu.cc",
 1558         "caffe2/operators/sparse_to_dense_op.cu.cc",
 1559         "caffe2/operators/spatial_batch_norm_op.cu.cc",
 1560         "caffe2/operators/spatial_batch_norm_op_cudnn.cu.cc",
 1561         "caffe2/operators/stump_func_op.cu.cc",
 1562         "caffe2/operators/summarize_op.cu.cc",
 1563         "caffe2/operators/swish_op.cu.cc",
 1564         "caffe2/operators/tan_op.cu.cc",
 1565         "caffe2/operators/tanh_op.cu.cc",
 1566         "caffe2/operators/thresholded_relu_op.cu.cc",
 1567         "caffe2/operators/tile_op.cu.cc",
 1568         "caffe2/operators/top_k.cu.cc",
 1569         "caffe2/operators/transpose_op.cu.cc",
 1570         "caffe2/operators/unique_ops.cu.cc",
 1571         "caffe2/operators/upsample_op.cu.cc",
 1572         "caffe2/operators/utility_ops.cu.cc",
 1573         "caffe2/operators/weighted_sample_op.cu.cc",
 1574         "caffe2/sgd/adadelta_op_gpu.cu.cc",
 1575         "caffe2/sgd/adagrad_op_gpu.cu.cc",
 1576         "caffe2/sgd/adam_op_gpu.cu.cc",
 1577         "caffe2/sgd/fp16_momentum_sgd_op.cu.cc",
 1578         "caffe2/sgd/fp32_momentum_sgd_op.cu.cc",
 1579         "caffe2/sgd/lars_op_gpu.cu.cc",
 1580         "caffe2/sgd/momentum_sgd_op_gpu.cu.cc",
 1581         "caffe2/sgd/rmsprop_op_gpu.cu.cc",
 1582         "caffe2/sgd/yellowfin_op_gpu.cu.cc",
 1583         "caffe2/utils/math/broadcast.cu.cc",
 1584         "caffe2/utils/math/elementwise.cu.cc",
 1585         "caffe2/utils/math/reduce.cu.cc",
 1586         "caffe2/utils/math/transpose.cu.cc",
 1587         "caffe2/utils/math_gpu.cu.cc",
 1588     ],
 1589 )
 1590 
 1591 # To achieve finer granularity and make debug easier, caffe2 is split into three libraries:
 1592 # ATen, caffe2 and caffe2_for_aten_headers. ATen lib group up source codes under
 1593 # aten/ directory and caffe2 contains most files under `caffe2/` directory. Since the
 1594 # ATen lib and the caffe2 lib would depend on each other, `caffe2_for_aten_headers` is splitted
 1595 # out from `caffe2` to avoid dependency cycle.
 1596 cc_library(
 1597     name = "caffe2_for_aten_headers",
 1598     hdrs = [
 1599         "caffe2/core/common.h",
 1600         "caffe2/core/logging.h",
 1601         "caffe2/core/types.h",
 1602         "caffe2/perfkernels/common.h",
 1603         "caffe2/perfkernels/embedding_lookup.h",
 1604         "caffe2/perfkernels/embedding_lookup_idx.h",
 1605         "caffe2/utils/fixed_divisor.h",
 1606         "caffe2/utils/cpuid.h",
 1607     ] + glob([
 1608         "caffe2/utils/threadpool/*.h",
 1609         "caffe2/proto/*.h",
 1610     ]),
 1611     copts = CAFFE2_COPTS,
 1612     visibility = ["//visibility:public"],
 1613     deps = [
 1614         ":c10_headers",
 1615         ":caffe2_protos",
 1616         ":caffe2_core_macros_h",
 1617     ],
 1618 )
 1619 
 1620 cc_library(
 1621     name = "caffe2_headers",
 1622     hdrs = glob([
 1623         "caffe2/contrib/aten/*.h",
 1624         "caffe2/contrib/gloo/*.h",
 1625         "caffe2/core/*.h",
 1626         "caffe2/core/nomnigraph/include/nomnigraph/Converters/*.h",
 1627         "caffe2/core/nomnigraph/include/nomnigraph/Generated/*.h",
 1628         "caffe2/core/nomnigraph/include/nomnigraph/Graph/*.h",
 1629         "caffe2/core/nomnigraph/include/nomnigraph/Representations/*.h",
 1630         "caffe2/core/nomnigraph/include/nomnigraph/Support/*.h",
 1631         "caffe2/core/nomnigraph/include/nomnigraph/Transformations/*.h",
 1632         "caffe2/core/nomnigraph/tests/*.h",
 1633         "caffe2/db/*.h",
 1634         "caffe2/distributed/*.h",
 1635         "caffe2/ideep/*.h",
 1636         "caffe2/ideep/operators/*.h",
 1637         "caffe2/ideep/operators/quantization/*.h",
 1638         "caffe2/ideep/utils/*.h",
 1639         "caffe2/onnx/*.h",
 1640         "caffe2/operators/*.h",
 1641         "caffe2/operators/rnn/*.h",
 1642         "caffe2/opt/*.h",
 1643         "caffe2/perfkernels/*.h",
 1644         "caffe2/predictor/*.h",
 1645         "caffe2/predictor/emulator/*.h",
 1646         "caffe2/proto/*.h",
 1647         "caffe2/quantization/server/*.h",
 1648         "caffe2/queue/*.h",
 1649         "caffe2/serialize/*.h",
 1650         "caffe2/sgd/*.h",
 1651         "caffe2/share/contrib/depthwise/*.h",
 1652         "caffe2/transforms/*.h",
 1653         "caffe2/utils/*.h",
 1654         "caffe2/utils/math/*.h",
 1655         "caffe2/utils/threadpool/*.h",
 1656         "modules/**/*.h",
 1657     ]) + if_cuda(glob([
 1658         "caffe2/**/*.cuh",
 1659         "caffe2/image/*.h",
 1660     ])),
 1661     copts = CAFFE2_COPTS,
 1662     includes = [
 1663         "caffe2/contrib/aten",
 1664         "caffe2/core/nomnigraph/include",
 1665         "third_party/miniz-2.0.8",
 1666     ],
 1667     visibility = ["//visibility:public"],
 1668     deps = [
 1669         ":caffe2_for_aten_headers",
 1670         ":caffe2_protos",
 1671     ],
 1672 )
 1673 
 1674 cc_library(
 1675     name = "caffe2_dnnlowp_avx2_ops",
 1676     srcs = [
 1677         "caffe2/quantization/server/elementwise_sum_dnnlowp_op_avx2.cc",
 1678         "caffe2/quantization/server/fully_connected_fake_lowp_op_avx2.cc",
 1679         "caffe2/quantization/server/group_norm_dnnlowp_op_avx2.cc",
 1680         "caffe2/quantization/server/norm_minimization_avx2.cc",
 1681         "caffe2/quantization/server/pool_dnnlowp_op_avx2.cc",
 1682         "caffe2/quantization/server/relu_dnnlowp_op_avx2.cc",
 1683         "caffe2/quantization/server/spatial_batch_norm_dnnlowp_op_avx2.cc",
 1684         "caffe2/quantization/server/transpose.cc",
 1685     ],
 1686     copts = CAFFE2_COPTS + [
 1687         "-mf16c",
 1688         "-mavx2",
 1689         "-mfma",
 1690         "-mxsave",
 1691     ],
 1692     visibility = ["//visibility:public"],
 1693     deps = [
 1694         ":caffe2_headers",
 1695         "@fbgemm",
 1696     ],
 1697     alwayslink = True,
 1698 )
 1699 
 1700 cc_library(
 1701     name = "caffe2",
 1702     srcs = [
 1703         "caffe2/db/create_db_op.cc",
 1704         "caffe2/db/protodb.cc",
 1705         "caffe2/share/contrib/depthwise/depthwise3x3_conv_op.cc",
 1706         ":caffe2_contrib_srcs",
 1707         ":caffe2_core_srcs",
 1708         ":caffe2_distributed_srcs",
 1709         ":caffe2_ideep_srcs",
 1710         ":caffe2_onnx_srcs",
 1711         ":caffe2_operators_srcs",
 1712         ":caffe2_opt_srcs",
 1713         ":caffe2_perfkernels_srcs",
 1714         ":caffe2_predictor_srcs",
 1715         ":caffe2_quantization_srcs",
 1716         ":caffe2_queue_srcs",
 1717         ":caffe2_serialize_srcs",
 1718         ":caffe2_sgd_srcs",
 1719         ":caffe2_transforms_srcs",
 1720         ":caffe2_utils_srcs",
 1721     ],
 1722     copts = CAFFE2_COPTS + ["-mf16c"],
 1723     linkstatic = 1,
 1724     visibility = ["//visibility:public"],
 1725     deps = [
 1726         ":caffe2_headers",
 1727         ":caffe2_dnnlowp_avx2_ops",
 1728         ":caffe2_perfkernels_avx",
 1729         ":caffe2_perfkernels_avx2",
 1730         ":caffe2_perfkernels_avx512",
 1731         ":caffe2_protos",
 1732         "//third_party/miniz-2.0.8:miniz",
 1733         "@com_google_protobuf//:protobuf",
 1734         "@eigen",
 1735         "@fbgemm//:fbgemm_src_headers",
 1736         "@foxi",
 1737         "@gloo",
 1738         "@onnx",
 1739         "@fmt",
 1740     ] + if_cuda(
 1741         [
 1742             ":caffe2_cpp_cuda",
 1743             ":aten_cuda",
 1744             "@tensorpipe//:tensorpipe_cuda",
 1745         ],
 1746         [
 1747             ":aten",
 1748             "@tensorpipe",
 1749         ],
 1750     ),
 1751     alwayslink = True,
 1752 )
 1753 
 1754 cc_library(
 1755     name = "caffe2_cpp_cuda",
 1756     srcs = [":caffe2_cuda_srcs"],
 1757     copts = CAFFE2_COPTS,
 1758     visibility = ["//visibility:public"],
 1759     deps = [
 1760         ":caffe2_cuda",
 1761         ":caffe2_headers",
 1762     ],
 1763     alwayslink = True,
 1764 )
 1765 
 1766 cu_library(
 1767     name = "caffe2_cuda",
 1768     srcs = [":caffe2_cu_srcs"],
 1769     copts = CAFFE2_COPTS + torch_cuda_half_options,
 1770     visibility = ["//visibility:public"],
 1771     deps = [
 1772         ":aten",
 1773         ":caffe2_headers",
 1774         "@cub",
 1775         "@cuda//:cublas",
 1776         "@cuda//:curand",
 1777         "@cudnn",
 1778         "@eigen",
 1779         "@gloo",
 1780         "@tensorpipe//:tensorpipe_cuda",
 1781     ],
 1782     alwayslink = True,
 1783 )
 1784 
 1785 PERF_COPTS = [
 1786     "-DHAVE_GCC_GET_CPUID",
 1787     "-DUSE_AVX",
 1788     "-DUSE_AVX2",
 1789     "-DTH_HAVE_THREAD",
 1790     "-DHAVE_AVX_CPU_DEFINITION",
 1791     "-DHAVE_AVX2_CPU_DEFINITION",
 1792     "-DENABLE_ALIAS=1",
 1793     "-DHAVE_MALLOC_USABLE_SIZE=1",
 1794     "-DHAVE_MMAP=1",
 1795     "-DHAVE_SHM_OPEN=1",
 1796     "-DHAVE_SHM_UNLINK=1",
 1797     "-DSLEEF_STATIC_LIBS=1",
 1798     "-D_FILE_OFFSET_BITS=64",
 1799     "-DUSE_FBGEMM",
 1800     "-fvisibility-inlines-hidden",
 1801     "-Wunused-parameter",
 1802     "-fno-math-errno",
 1803     "-fno-trapping-math",
 1804     "-mf16c",
 1805 ]
 1806 
 1807 PERF_HEADERS = glob([
 1808     "caffe2/perfkernels/*.h",
 1809     "caffe2/core/*.h",
 1810 ])
 1811 
 1812 cc_library(
 1813     name = "caffe2_perfkernels_avx",
 1814     srcs = glob([
 1815         "caffe2/perfkernels/*_avx.cc",
 1816     ]),
 1817     hdrs = PERF_HEADERS,
 1818     copts = PERF_COPTS + [
 1819         "-mavx",
 1820     ],
 1821     visibility = ["//visibility:public"],
 1822     deps = [
 1823         ":caffe2_headers",
 1824         ":c10",
 1825     ],
 1826     alwayslink = True,
 1827 )
 1828 
 1829 cc_library(
 1830     name = "caffe2_perfkernels_avx2",
 1831     srcs = glob([
 1832         "caffe2/perfkernels/*_avx2.cc",
 1833     ]),
 1834     hdrs = PERF_HEADERS,
 1835     copts = PERF_COPTS + [
 1836         "-mavx2",
 1837         "-mfma",
 1838         "-mavx",
 1839     ],
 1840     visibility = ["//visibility:public"],
 1841     deps = [
 1842         ":caffe2_headers",
 1843         ":c10",
 1844     ],
 1845     alwayslink = True,
 1846 )
 1847 
 1848 cc_library(
 1849     name = "caffe2_perfkernels_avx512",
 1850     srcs = [
 1851         "caffe2/perfkernels/common_avx512.cc",
 1852     ],
 1853     hdrs = PERF_HEADERS,
 1854     copts = PERF_COPTS + [
 1855         "-mavx512f",
 1856         "-mavx512dq",
 1857         "-mavx512vl",
 1858         "-mavx2",
 1859         "-mfma",
 1860         "-mavx",
 1861     ],
 1862     visibility = ["//visibility:public"],
 1863     deps = [
 1864         ":caffe2_headers",
 1865         ":c10",
 1866     ],
 1867     alwayslink = True,
 1868 )
 1869 
 1870 # torch
 1871 py_binary(
 1872     name = "gen_version_header",
 1873     srcs = ["tools/setup_helpers/gen_version_header.py"],
 1874 )
 1875 
 1876 genrule(
 1877     name = "version_h",
 1878     srcs = ["torch/csrc/api/include/torch/version.h.in", "version.txt"],
 1879     outs = ["torch/csrc/api/include/torch/version.h"],
 1880     cmd = "$(location :gen_version_header) --template-path $(location torch/csrc/api/include/torch/version.h.in) --version-path $(location version.txt) --output-path $@",
 1881     tools = [':gen_version_header']
 1882 )
 1883 
 1884 torch_cuda_headers = glob(["torch/csrc/cuda/*.h"])
 1885 cc_library(
 1886     name = "torch_headers",
 1887     hdrs = if_cuda(
 1888         torch_cuda_headers,
 1889     ) + glob(
 1890         [
 1891             "torch/*.h",
 1892             "torch/csrc/**/*.h",
 1893             "torch/lib/libshm/*.h",
 1894             "torch/lib/c10d/*.hpp",
 1895         ],
 1896         exclude = [
 1897             "torch/lib/c10d/ProcessGroupMPI.hpp",
 1898             "torch/lib/c10d/ProcessGroupNCCL.hpp",
 1899             "torch/csrc/autograd/generated/VariableType.h",
 1900             "torch/csrc/autograd/generated/RegistrationDeclarations.h",
 1901             "torch/csrc/autograd/generated/variable_factories.h",
 1902             "torch/csrc/autograd/generated/Functions.h",
 1903         ] + torch_cuda_headers,
 1904     ) + [":cpp_generated_code", ":version_h"],
 1905     includes = [
 1906         "torch/csrc",
 1907         "torch/csrc/api/include",
 1908         "torch/lib",
 1909         "torch/lib/libshm",
 1910     ],
 1911     visibility = ["//visibility:public"],
 1912     deps = [
 1913         ":aten_headers",
 1914         ":c10_headers",
 1915         ":caffe2_headers",
 1916         "@local_config_python//:python_headers",
 1917         "@onnx",
 1918     ],
 1919     alwayslink = True,
 1920 )
 1921 
 1922 TORCH_COPTS = COMMON_COPTS + [
 1923     "-Dtorch_EXPORTS",
 1924     "-DHAVE_AVX_CPU_DEFINITION",
 1925     "-DHAVE_AVX2_CPU_DEFINITION",
 1926     "-DCAFFE2_USE_GLOO",
 1927     "-fvisibility-inlines-hidden",
 1928     "-fno-math-errno ",
 1929     "-fno-trapping-math",
 1930 ]
 1931 
 1932 cc_library(
 1933     name = "torch",
 1934     srcs = if_cuda(glob(
 1935         [
 1936             "torch/csrc/cuda/*.cpp",
 1937             "torch/csrc/autograd/functions/comm.cpp",
 1938         ],
 1939         exclude = [
 1940             "torch/csrc/cuda/python_nccl.cpp",
 1941             "torch/csrc/cuda/nccl.cpp",
 1942         ],
 1943     )) + libtorch_core_sources + libtorch_distributed_sources + torch_cpp_srcs + libtorch_extra_sources + jit_core_sources + [
 1944         ":cpp_generated_code",
 1945     ],
 1946     copts = TORCH_COPTS + if_cuda(["-DUSE_CUDA=1"]),
 1947     defines = [
 1948         "CAFFE2_NIGHTLY_VERSION=20200115",
 1949     ],
 1950     visibility = ["//visibility:public"],
 1951     deps = [
 1952         ":caffe2",
 1953         ":torch_headers",
 1954     ],
 1955     alwayslink = True,
 1956 )
 1957 
 1958 cc_library(
 1959     name = "shm",
 1960     srcs = glob(["torch/lib/libshm/*.cpp"]),
 1961     deps = [
 1962         ":torch",
 1963     ],
 1964 )
 1965 
 1966 cc_library(
 1967     name = "libtorch_headers",
 1968     hdrs = glob([
 1969         "**/*.h",
 1970         "**/*.cuh",
 1971     ]) + [
 1972         ":generated_code",
 1973     ],
 1974     includes = [
 1975         ".",
 1976         "torch/csrc/api/include",
 1977         "torch/lib",
 1978         "torch/lib/libshm",
 1979     ],
 1980     visibility = ["//visibility:public"],
 1981     deps = [
 1982         ":aten_headers",
 1983         ":c10_headers",
 1984         ":caffe2_headers",
 1985     ],
 1986 )
 1987 
 1988 cc_library(
 1989     name = "torch_python",
 1990     srcs = libtorch_python_core_sources + [":python_generated_code"],
 1991     hdrs = glob([
 1992         "torch/csrc/generic/*.cpp",
 1993     ]),
 1994     deps = [
 1995         ":torch",
 1996         ":shm",
 1997     ],
 1998 )
 1999 
 2000 pybind_extension(
 2001     name = "_C",
 2002     srcs = ["torch/csrc/stub.c"],
 2003     deps = [
 2004         ":torch_python"
 2005     ],
 2006 )
 2007 
 2008 # cpp api tests
 2009 cc_library(
 2010     name = "test_support",
 2011     testonly = True,
 2012     srcs = [
 2013         "test/cpp/api/support.cpp",
 2014     ],
 2015     hdrs = [
 2016         "test/cpp/api/init_baseline.h",
 2017         "test/cpp/api/optim_baseline.h",
 2018         "test/cpp/api/support.h",
 2019         "test/cpp/common/support.h",
 2020     ],
 2021     deps = [
 2022         ":torch",
 2023         "@com_google_googletest//:gtest_main",
 2024     ],
 2025 )
 2026 
 2027 # Torch integration tests rely on a labeled data set from the MNIST database.
 2028 # http://yann.lecun.com/exdb/mnist/
 2029 
 2030 cpp_api_tests = glob(["test/cpp/api/*.cpp"])
 2031 [
 2032   cc_test(
 2033       name = paths.split_extension(paths.basename(filename))[0].replace("-","_") + "_test",
 2034     size = "medium",
 2035       srcs = [filename],
 2036       deps = [
 2037           ":test_support",
 2038           "@com_google_googletest//:gtest_main",
 2039       ],
 2040   ) for filename in cpp_api_tests
 2041 ]
 2042 
 2043 test_suite(
 2044     name = "api_tests",
 2045     tests = [
 2046         "any_test",
 2047         "autograd_test",
 2048         "dataloader_test",
 2049         "enum_test",
 2050         "expanding_array_test",
 2051         "functional_test",
 2052         "init_test",
 2053         "integration_test",
 2054         "jit_test",
 2055         "memory_test",
 2056         "misc_test",
 2057         "module_test",
 2058         "modulelist_test",
 2059         "modules_test",
 2060         "nn_utils_test",
 2061         "optim_test",
 2062         "ordered_dict_test",
 2063         "rnn_test",
 2064         "sequential_test",
 2065         "serialize_test",
 2066         "static_test",
 2067         "tensor_options_test",
 2068         "tensor_test",
 2069         "torch_include_test",
 2070     ],
 2071 )
 2072 
 2073 # dist autograd tests
 2074 cc_test(
 2075     name = "torch_dist_autograd_test",
 2076     size = "small",
 2077     srcs = ["test/cpp/dist_autograd/test_dist_autograd.cpp"],
 2078     tags = [
 2079         "exclusive",
 2080         "gpu-required",
 2081     ],
 2082     deps = [
 2083         ":torch",
 2084         "@com_google_googletest//:gtest_main",
 2085     ],
 2086 )
 2087 
 2088 # jit tests
 2089 # Because these individual unit tests require custom registering,
 2090 # it is easier to mimic the cmake build by globing together a single test.
 2091 cc_test(
 2092     name = "jit_tests",
 2093     size = "small",
 2094     srcs = glob([
 2095         "test/cpp/jit/*.cpp",
 2096         "test/cpp/jit/*.h",
 2097         "test/cpp/tensorexpr/*.cpp",
 2098         "test/cpp/tensorexpr/*.h",
 2099     ]),
 2100     linkstatic = True,
 2101     tags = [
 2102         "exclusive",
 2103         "gpu-required",
 2104     ],
 2105     deps = [
 2106         ":torch",
 2107         "@com_google_googletest//:gtest_main",
 2108     ],
 2109 )
 2110 
 2111 # all tests
 2112 test_suite(
 2113     name = "all_tests",
 2114     tests = [
 2115         "api_tests",
 2116         "c10_tests",
 2117         "jit_tests",
 2118         "torch_dist_autograd_test",
 2119     ],
 2120 )