Skip to content

Commit 50ecbfd

Browse files
larryliu0820facebook-github-bot
authored andcommitted
[PyTorch] Fix windows build for torchvision when MOBILE is defined (#4571)
Summary: Pull Request resolved: #4571 Fixing windows build for `torchvision` when `MOBILE` is defined. In `csrc/vision.cpp`, since `PyMODINIT_FUNC` depends on `Python.h` I added the same condition for `PyMODINIT_FUNC` as the one for `import <PyTorch.h>`. Reviewed By: malfet Differential Revision: D31488734 fbshipit-source-id: fd52a9ab161288d9c8bf3b9e0ab9da856a4ebadb
1 parent 228af50 commit 50ecbfd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

torchvision/csrc/vision.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
#endif
1414

1515
// If we are in a Windows environment, we need to define
16-
// initialization functions for the _custom_ops extension
17-
#ifdef _WIN32
16+
// initialization functions for the _custom_ops extension.
17+
// For PyMODINIT_FUNC to work, we need to include Python.h
18+
#if !defined(MOBILE) && defined(_WIN32)
1819
PyMODINIT_FUNC PyInit__C(void) {
1920
// No need to do anything.
2021
return NULL;
2122
}
22-
#endif
23+
#endif // !defined(MOBILE) && defined(_WIN32)
2324

2425
namespace vision {
2526
int64_t cuda_version() {

0 commit comments

Comments
 (0)