Skip to content

Commit 47c8bc9

Browse files
committed
Moving files in subfolders.
1 parent ce34258 commit 47c8bc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+44
-52
lines changed

CMakeLists.txt

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@ function(CUDA_CONVERT_FLAGS EXISTING_TARGET)
2828
endif()
2929
endfunction()
3030

31-
file(GLOB HEADERS torchvision/csrc/*.h)
32-
# Image extension
33-
file(GLOB IMAGE_HEADERS torchvision/csrc/cpu/image/*.h)
34-
file(GLOB IMAGE_SOURCES torchvision/csrc/cpu/image/*.cpp)
35-
file(GLOB OPERATOR_HEADERS torchvision/csrc/cpu/*.h)
36-
file(GLOB OPERATOR_SOURCES ${OPERATOR_HEADERS} torchvision/csrc/cpu/*.cpp ${IMAGE_HEADERS} ${IMAGE_SOURCES} ${HEADERS} torchvision/csrc/*.cpp)
37-
if(WITH_CUDA)
38-
file(GLOB OPERATOR_HEADERS ${OPERATOR_HEADERS} torchvision/csrc/cuda/*.h)
39-
file(GLOB OPERATOR_SOURCES ${OPERATOR_SOURCES} ${OPERATOR_HEADERS} torchvision/csrc/cuda/*.cu)
40-
endif()
41-
file(GLOB MODELS_HEADERS torchvision/csrc/models/*.h)
42-
file(GLOB MODELS_SOURCES torchvision/csrc/models/*.h torchvision/csrc/models/*.cpp)
43-
4431
if(MSVC)
4532
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4819")
4633
if(WITH_CUDA)
@@ -64,7 +51,17 @@ endif()
6451
include(GNUInstallDirs)
6552
include(CMakePackageConfigHelpers)
6653

67-
add_library(${PROJECT_NAME} SHARED ${MODELS_SOURCES} ${OPERATOR_SOURCES} ${IMAGE_SOURCES})
54+
set(TVCPP torchvision/csrc)
55+
list(APPEND ALLOW_LISTED ${TVCPP} ${TVCPP}/io/image ${TVCPP}/io/image/cpu ${TVCPP}/models ${TVCPP}/ops ${TVCPP}/ops/cpu)
56+
if(WITH_CUDA)
57+
list(APPEND ALLOW_LISTED ${TVCPP}/ops/cuda)
58+
endif()
59+
60+
FOREACH(DIR ${ALLOW_LISTED})
61+
file(GLOB ALL_SOURCES ${ALL_SOURCES} ${DIR}/*.*)
62+
ENDFOREACH()
63+
64+
add_library(${PROJECT_NAME} SHARED ${ALL_SOURCES})
6865
target_link_libraries(${PROJECT_NAME} PRIVATE ${TORCH_LIBRARIES} ${PNG_LIBRARY} ${JPEG_LIBRARIES} Python3::Python)
6966
set_target_properties(${PROJECT_NAME} PROPERTIES
7067
EXPORT_NAME TorchVision
@@ -95,13 +92,8 @@ install(EXPORT TorchVisionTargets
9592
NAMESPACE TorchVision::
9693
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR})
9794

98-
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
99-
install(FILES
100-
${OPERATOR_HEADERS}
101-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/cpu)
102-
if(WITH_CUDA)
103-
install(FILES
104-
${OPERATOR_HEADERS}
105-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/cuda)
106-
endif()
107-
install(FILES ${MODELS_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/models)
95+
FOREACH(INPUT_DIR ${ALLOW_LISTED})
96+
string(REPLACE "${TVCPP}" "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" OUTPUT_DIR ${INPUT_DIR})
97+
file(GLOB INPUT_FILES ${INPUT_DIR}/*.*)
98+
install(FILES ${INPUT_FILES} DESTINATION ${OUTPUT_DIR})
99+
ENDFOREACH()

setup.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ def get_extensions():
134134
this_dir = os.path.dirname(os.path.abspath(__file__))
135135
extensions_dir = os.path.join(this_dir, 'torchvision', 'csrc')
136136

137-
main_file = glob.glob(os.path.join(extensions_dir, '*.cpp'))
138-
source_cpu = glob.glob(os.path.join(extensions_dir, 'cpu', '*.cpp'))
137+
main_file = glob.glob(os.path.join(extensions_dir, '*.cpp')) + glob.glob(os.path.join(extensions_dir, 'ops',
138+
'*.cpp'))
139+
source_cpu = glob.glob(os.path.join(extensions_dir, 'ops', 'cpu', '*.cpp'))
139140

140141
is_rocm_pytorch = False
141142
if torch.__version__ >= '1.5':
@@ -146,17 +147,17 @@ def get_extensions():
146147
hipify_python.hipify(
147148
project_directory=this_dir,
148149
output_directory=this_dir,
149-
includes="torchvision/csrc/cuda/*",
150+
includes="torchvision/csrc/ops/cuda/*",
150151
show_detailed=True,
151152
is_pytorch_extension=True,
152153
)
153-
source_cuda = glob.glob(os.path.join(extensions_dir, 'hip', '*.hip'))
154+
source_cuda = glob.glob(os.path.join(extensions_dir, 'ops', 'hip', '*.hip'))
154155
# Copy over additional files
155-
for file in glob.glob(r"torchvision/csrc/cuda/*.h"):
156-
shutil.copy(file, "torchvision/csrc/hip")
156+
for file in glob.glob(r"torchvision/csrc/ops/cuda/*.h"):
157+
shutil.copy(file, "torchvision/csrc/ops/hip")
157158

158159
else:
159-
source_cuda = glob.glob(os.path.join(extensions_dir, 'cuda', '*.cu'))
160+
source_cuda = glob.glob(os.path.join(extensions_dir, 'ops', 'cuda', '*.cu'))
160161

161162
sources = main_file + source_cpu
162163
extension = CppExtension
@@ -309,8 +310,8 @@ def get_extensions():
309310
image_library += [jpeg_lib]
310311
image_include += [jpeg_include]
311312

312-
image_path = os.path.join(extensions_dir, 'cpu', 'image')
313-
image_src = glob.glob(os.path.join(image_path, '*.cpp'))
313+
image_path = os.path.join(extensions_dir, 'io', 'image')
314+
image_src = glob.glob(os.path.join(image_path, '*.cpp')) + glob.glob(os.path.join(image_path, 'cpu', '*.cpp'))
314315

315316
if png_found or jpeg_found:
316317
ext_modules.append(extension(
@@ -377,13 +378,13 @@ def get_extensions():
377378
print("ffmpeg library_dir: {}".format(ffmpeg_library_dir))
378379

379380
# TorchVision base decoder + video reader
380-
video_reader_src_dir = os.path.join(this_dir, 'torchvision', 'csrc', 'cpu', 'video_reader')
381+
video_reader_src_dir = os.path.join(this_dir, 'torchvision', 'csrc', 'io', 'video_reader')
381382
video_reader_src = glob.glob(os.path.join(video_reader_src_dir, "*.cpp"))
382-
base_decoder_src_dir = os.path.join(this_dir, 'torchvision', 'csrc', 'cpu', 'decoder')
383+
base_decoder_src_dir = os.path.join(this_dir, 'torchvision', 'csrc', 'io', 'decoder')
383384
base_decoder_src = glob.glob(
384385
os.path.join(base_decoder_src_dir, "*.cpp"))
385386
# Torchvision video API
386-
videoapi_src_dir = os.path.join(this_dir, 'torchvision', 'csrc', 'cpu', 'video')
387+
videoapi_src_dir = os.path.join(this_dir, 'torchvision', 'csrc', 'io', 'video')
387388
videoapi_src = glob.glob(os.path.join(videoapi_src_dir, "*.cpp"))
388389
# exclude tests
389390
base_decoder_src = [x for x in base_decoder_src if '_test.cpp' not in x]

test/tracing/frcnn/test_frcnn_tracing.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#include <ATen/ATen.h>
22
#include <torch/script.h>
33
#include <torch/torch.h>
4-
#include <torchvision/nms.h>
5-
#include <torchvision/roi_align.h>
4+
#include <torchvision/ops/nms.h>
65

76
#ifdef _WIN32
87
// Windows only

torchvision/csrc/cpu/image/image.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

torchvision/csrc/cpu/image/read_image_cpu.h renamed to torchvision/csrc/io/image/cpu/read_image_cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include <torch/torch.h>
4-
#include "image_read_mode.h"
4+
#include "io/image/image_read_mode.h"
55

66
C10_EXPORT torch::Tensor decode_image(
77
const torch::Tensor& data,

torchvision/csrc/cpu/image/readjpeg_cpu.h renamed to torchvision/csrc/io/image/cpu/readjpeg_cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include <torch/torch.h>
4-
#include "image_read_mode.h"
4+
#include "io/image/image_read_mode.h"
55

66
C10_EXPORT torch::Tensor decodeJPEG(
77
const torch::Tensor& data,

torchvision/csrc/cpu/image/readpng_cpu.h renamed to torchvision/csrc/io/image/cpu/readpng_cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include <torch/torch.h>
4-
#include "image_read_mode.h"
4+
#include "io/image/image_read_mode.h"
55

66
C10_EXPORT torch::Tensor decodePNG(
77
const torch::Tensor& data,

torchvision/csrc/io/image/image.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
// Comment
4+
#include <torch/script.h>
5+
#include <torch/torch.h>
6+
#include "io/image/cpu/read_image_cpu.h"
7+
#include "io/image/cpu/read_write_file_cpu.h"
8+
#include "io/image/cpu/readjpeg_cpu.h"
9+
#include "io/image/cpu/readpng_cpu.h"
10+
#include "io/image/cpu/writejpeg_cpu.h"
11+
#include "io/image/cpu/writepng_cpu.h"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)