Skip to content

Commit 3ab88c3

Browse files
t-vifacebook-github-bot
authored andcommitted
Enable TorchBind tests on ROCm (pytorch#45426)
Summary: The torchbind tests didn't work be cause somehow we missed the rename of caffe2_gpu to torch_... (hip for us) in pytorch#20774 (merged 2019-06-13, oops) and still tried to link against it. Pull Request resolved: pytorch#45426 Reviewed By: VitalyFedyunin Differential Revision: D24112439 Pulled By: walterddr fbshipit-source-id: a66a574e63714728183399c543d2dafbd6c028f7
1 parent e829d4f commit 3ab88c3

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

caffe2/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ endif()
841841
DESTINATION ${TORCH_INSTALL_INCLUDE_DIR}/torch)
842842

843843

844-
if(BUILD_TEST AND NOT USE_ROCM)
844+
if(BUILD_TEST)
845845
add_subdirectory(${TORCH_ROOT}/test/cpp/jit ${CMAKE_BINARY_DIR}/test_jit)
846846
add_subdirectory(${TORCH_ROOT}/test/cpp/tensorexpr ${CMAKE_BINARY_DIR}/test_tensorexpr)
847847
if(USE_DISTRIBUTED AND NOT WIN32)

test/cpp/jit/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ elseif(USE_ROCM)
9797
${PYTORCH_HIP_HCC_LIBRARIES}
9898
${TORCH_CUDA_LIBRARIES})
9999

100-
target_link_libraries(test_jit PRIVATE caffe2_gpu)
101-
102100
target_compile_definitions(test_jit PRIVATE USE_ROCM)
103101
endif()
104102

test/cpp/tensorexpr/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ elseif(USE_ROCM)
3636
${ROCM_HIPRTC_LIB}
3737
${PYTORCH_HIP_HCC_LIBRARIES}
3838
${TORCH_CUDA_LIBRARIES})
39-
target_link_libraries(test_tensorexpr PRIVATE caffe2_gpu)
4039
target_compile_definitions(test_tensorexpr PRIVATE USE_ROCM)
4140

4241
target_link_libraries(tutorial_tensorexpr PRIVATE
4342
${ROCM_HIPRTC_LIB}
4443
${PYTORCH_HIP_HCC_LIBRARIES}
4544
${TORCH_CUDA_LIBRARIES})
46-
target_link_libraries(tutorial_tensorexpr PRIVATE caffe2_gpu)
4745
target_compile_definitions(tutorial_tensorexpr PRIVATE USE_ROCM)
4846
endif()
4947

test/jit/test_torchbind.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@
2424

2525
class TestTorchbind(JitTestCase):
2626
def setUp(self):
27-
if TEST_WITH_ROCM or IS_SANDCASTLE or IS_WINDOWS or IS_MACOS or IS_FBCODE:
27+
if IS_SANDCASTLE or IS_WINDOWS or IS_MACOS or IS_FBCODE:
2828
raise unittest.SkipTest("non-portable load_library call used in test")
29-
torch_root = Path(__file__).resolve().parent.parent.parent
30-
p = torch_root / 'build' / 'lib' / 'libtorchbind_test.so'
29+
if TEST_WITH_ROCM:
30+
torch_root = Path(torch.__file__).resolve().parent
31+
p = torch_root / 'lib' / 'libtorchbind_test.so'
32+
else:
33+
torch_root = Path(__file__).resolve().parent.parent.parent
34+
p = torch_root / 'build' / 'lib' / 'libtorchbind_test.so'
3135
torch.ops.load_library(str(p))
3236

3337
def test_torchbind(self):

torch/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ append_filelist("libtorch_python_core_sources" TORCH_PYTHON_SRCS)
4646

4747
# NB: This has to match the condition under which the JIT test directory
4848
# is included (at the time of writing that's in caffe2/CMakeLists.txt).
49-
if(BUILD_TEST AND NOT USE_ROCM)
49+
if(BUILD_TEST)
5050
add_definitions(-DBUILDING_TESTS)
5151
list(APPEND TORCH_PYTHON_SRCS
5252
${TORCH_ROOT}/test/cpp/jit/torch_python_test.cpp

0 commit comments

Comments
 (0)