Revert "Remove Caffe2 code from tool scripts (#134941)"

This reverts commit c818ecd169.

Reverted https://github.com/pytorch/pytorch/pull/134941 on behalf of https://github.com/kit1980 due to breaking internal builds - The path `caffe2/operators/hip/gather_op.cuh` does not exist ([comment](https://github.com/pytorch/pytorch/pull/134941#issuecomment-2332636624))
This commit is contained in:
PyTorch MergeBot 2024-09-05 21:12:54 +00:00
parent 9c0b03020b
commit a4cf9653ee
2 changed files with 19 additions and 0 deletions

View File

@ -64,10 +64,21 @@ if args.output_directory:
out_dir = args.output_directory
includes = [
"caffe2/operators/*",
"caffe2/sgd/*",
"caffe2/image/*",
"caffe2/transforms/*",
"caffe2/video/*",
"caffe2/distributed/*",
"caffe2/queue/*",
"caffe2/contrib/aten/*",
"binaries/*",
"caffe2/**/*_test*",
"caffe2/core/*",
"caffe2/db/*",
"caffe2/utils/*",
"caffe2/contrib/gloo/*",
"caffe2/contrib/nccl/*",
"c10/cuda/*",
"c10/cuda/test/CMakeLists.txt",
"modules/*",
@ -107,6 +118,8 @@ for new_dir in args.extra_include_dir:
includes.append(abs_new_dir)
ignores = [
"caffe2/operators/depthwise_3x3_conv_op_cudnn.cu",
"caffe2/operators/pool_op_cudnn.cu",
"*/hip/*",
# These files are compatible with both cuda and hip
"aten/src/ATen/core/*",

View File

@ -2,6 +2,7 @@ from __future__ import annotations
import os
import platform
import shutil
from glob import glob
from setuptools import distutils # type: ignore[import]
@ -86,3 +87,8 @@ def build_caffe2(
if cmake_only:
return
cmake.build(my_env)
if build_python:
caffe2_proto_dir = os.path.join(cmake.build_dir, "caffe2", "proto")
for proto_file in glob(os.path.join(caffe2_proto_dir, "*.py")):
if proto_file != os.path.join(caffe2_proto_dir, "__init__.py"):
shutil.copy(proto_file, os.path.join("caffe2", "proto"))