Skip to content

Commit 4fcf11d

Browse files
authored
Removing python headers and Win32 Python2 inits in C++ (#3011)
* Removing python headers and code for Python2 compatibility. * Restoring python3 inits.
1 parent 76ebe92 commit 4fcf11d

File tree

5 files changed

+1
-37
lines changed

5 files changed

+1
-37
lines changed

torchvision/csrc/cpu/video/Video.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include "Video.h"
32
#include <c10/util/Logging.h>
43
#include <torch/script.h>
@@ -9,22 +8,6 @@
98
using namespace std;
109
using namespace ffmpeg;
1110

12-
// If we are in a Windows environment, we need to define
13-
// initialization functions for the _custom_ops extension
14-
// #ifdef _WIN32
15-
// #if PY_MAJOR_VERSION < 3
16-
// PyMODINIT_FUNC init_video_reader(void) {
17-
// // No need to do anything.
18-
// return NULL;
19-
// }
20-
// #else
21-
// PyMODINIT_FUNC PyInit_video_reader(void) {
22-
// // No need to do anything.
23-
// return NULL;
24-
// }
25-
// #endif
26-
// #endif
27-
2811
const size_t decoderTimeoutMs = 600000;
2912
const AVPixelFormat defaultVideoPixelFormat = AV_PIX_FMT_RGB24;
3013
const AVSampleFormat defaultAudioSampleFormat = AV_SAMPLE_FMT_FLT;

torchvision/csrc/cpu/video/Video.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <vector>
77

88
#include <ATen/ATen.h>
9-
#include <Python.h>
109
#include <c10/util/Logging.h>
1110
#include <torch/script.h>
1211

torchvision/csrc/cpu/video_reader/VideoReader.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,11 @@ using namespace ffmpeg;
1212
// If we are in a Windows environment, we need to define
1313
// initialization functions for the _custom_ops extension
1414
#ifdef _WIN32
15-
#if PY_MAJOR_VERSION < 3
16-
PyMODINIT_FUNC init_video_reader(void) {
17-
// No need to do anything.
18-
return NULL;
19-
}
20-
#else
2115
PyMODINIT_FUNC PyInit_video_reader(void) {
2216
// No need to do anything.
2317
return NULL;
2418
}
2519
#endif
26-
#endif
2720

2821
namespace video_reader {
2922

torchvision/csrc/empty_tensor_op.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
// All pure C++ headers for the C++ frontend.
44
#include <torch/all.h>
5-
// Python bindings for the C++ frontend (includes Python.h).
6-
#include <torch/python.h>
75

86
class NewEmptyTensorOp : public torch::autograd::Function<NewEmptyTensorOp> {
97
public:

torchvision/csrc/vision.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,13 @@
1717
#include "nms.h"
1818

1919
// If we are in a Windows environment, we need to define
20-
// initialization functions for the _C extension
20+
// initialization functions for the _custom_ops extension
2121
#ifdef _WIN32
22-
#if PY_MAJOR_VERSION < 3
23-
PyMODINIT_FUNC init_C(void) {
24-
// No need to do anything.
25-
// extension.py will run on load
26-
return NULL;
27-
}
28-
#else
2922
PyMODINIT_FUNC PyInit__C(void) {
3023
// No need to do anything.
31-
// extension.py will run on load
3224
return NULL;
3325
}
3426
#endif
35-
#endif
3627

3728
namespace vision {
3829
int64_t cuda_version() noexcept {

0 commit comments

Comments
 (0)