Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions test/tracing/frcnn/test_frcnn_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
#include <torchvision/vision.h>
#include <torchvision/ops/nms.h>

#ifdef _WIN32
// Windows only
// This is necessary until operators are automatically registered on include
static auto _nms = &vision::ops::nms;
#endif

int main() {
torch::DeviceType device_type;
Expand Down
1 change: 1 addition & 0 deletions torchvision/csrc/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#else
#ifdef _MSC_VER
#define VISION_INLINE_VARIABLE __declspec(selectany)
#define HINT_MSVC_LINKER_INCLUDE_SYMBOL
#else
#define VISION_INLINE_VARIABLE __attribute__((weak))
#endif
Expand Down
9 changes: 5 additions & 4 deletions torchvision/csrc/vision.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ namespace vision {
VISION_API int64_t cuda_version();

namespace detail {
// Dummy variable to reference a symbol from vision.cpp.
// This ensures that the torchvision library and the ops registration
// initializers are not pruned.
VISION_INLINE_VARIABLE int64_t _cuda_version = cuda_version();
extern "C" VISION_INLINE_VARIABLE auto _register_ops = &cuda_version;
#ifdef HINT_MSVC_LINKER_INCLUDE_SYMBOL
#pragma comment(linker, "/include:_register_ops")
#endif

} // namespace detail
} // namespace vision