Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
ca6a441
Add hip support for caffe2 core
Apr 26, 2018
cb41397
Add MIOPEN header/wrapper to caffe2 core
Apr 26, 2018
18858cb
Add HIP device into caffe2 PB
Apr 26, 2018
51a49c1
top level makefile change for rocm/hip
May 1, 2018
3a48b1e
makefile scaffolding for AMD/RocM/HIP
May 1, 2018
b45a633
Makefile scafodding for AMD/RocM/HIP; add makefile/utility for HIP files
May 1, 2018
cda1da6
caffe2 PB update for AMD/ROCM HIP device
May 2, 2018
8f9c63a
Add AMD/RocM/Thrust dependency
May 4, 2018
a1171f0
Merge branch 'caffe2_core_hip' of github.com:petrex/pytorch into caff…
May 4, 2018
d867613
HIP threadpool update
May 4, 2018
666173d
Fix makefile macro
May 4, 2018
4609bc6
makefile fix: duplicate test/binary name
May 4, 2018
e9bdd6a
makefile clean-up
May 9, 2018
f5496be
makefile clean-up
May 9, 2018
7653aff
add HIP operator registry
May 9, 2018
8c7da75
add utilities for hip device
May 9, 2018
3db165a
Add USE_HIP to config summary
May 10, 2018
6525317
makefile fix for BUILD_TEST
May 15, 2018
7606aa1
merge latest and fix test build
May 15, 2018
0c0aa1b
merge latest
May 15, 2018
e19f33d
Fix indentation
May 15, 2018
de710b4
code clean-up
May 15, 2018
8bfa47f
Merge branch 'master' into caffe2_core_hip
bddppq May 15, 2018
00ebc31
Merge branch 'master' into caffe2_core_hip
bddppq May 15, 2018
5b01dc0
Merge branch 'master' into caffe2_core_hip
bddppq May 16, 2018
39e7253
Merge branch 'master' into caffe2_core_hip
bddppq May 16, 2018
fdf36d5
Guard builds without HIP and use the same cmake script as PyTorch to …
bddppq May 16, 2018
613ddf8
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 16, 2018
df8ab43
Setup rocm environment variables in build.sh (ideally should be done …
bddppq May 16, 2018
540306e
setup locale
bddppq May 16, 2018
8ec58db
set HIP_PLATFORM
bddppq May 16, 2018
1697b92
Revert "set HIP_PLATFORM"
bddppq May 16, 2018
ac613b0
continue the build script environment variables mess
bddppq May 16, 2018
94e9569
HCC_AMDGPU_TARGET
bddppq May 16, 2018
213689e
Cleanup the mess, has been fixed in the lastest docker images
bddppq May 16, 2018
098313f
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 16, 2018
edb048a
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 16, 2018
09cf458
Assign protobuf field hip_gpu_id a new field number for backward comp…
bddppq May 16, 2018
5368a9c
change name to avoid conflict
bddppq May 17, 2018
f0b0184
Merge branch 'master' into caffe2_core_hip
bddppq May 17, 2018
199831d
Merge remote-tracking branch 'upstream/master' into caffe2_core_hip
May 17, 2018
69ffbed
Merge branch 'master' into caffe2_core_hip
bddppq May 18, 2018
de3437b
Merge branch 'master' into caffe2_core_hip
bddppq May 18, 2018
8469d2a
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 18, 2018
90afe3e
Fix duplicated thread pool flag
bddppq May 18, 2018
69ddbc8
Refactor cmake files to not add hip includes and libs globally
bddppq May 18, 2018
20f5870
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 18, 2018
e7a068f
Merge branch 'caffe2_core_hip' of github.com:petrex/pytorch into caff…
May 18, 2018
61846e7
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 18, 2018
868e39e
Merge branch 'master' into caffe2_core_hip
bddppq May 18, 2018
f77b1ca
Merge branch 'master' into caffe2_core_hip
bddppq May 19, 2018
bf7446a
Fix the wrong usage of environment variables detection in cmake
bddppq May 19, 2018
8fbb954
Merge branch 'master' into caffe2_core_hip
bddppq May 21, 2018
145a7c6
Merge branch 'caffe2_core_hip' of github.com:petrex/pytorch into caff…
May 21, 2018
758e5b2
Merge branch 'master' into caffe2_core_hip
bddppq May 22, 2018
50eadcf
Merge branch 'master' into caffe2_core_hip
bddppq May 22, 2018
e88cf91
Merge branch 'master' into caffe2_core_hip
bddppq May 23, 2018
f76bd00
Merge branch 'master' into caffe2_core_hip
bddppq May 23, 2018
e7a80cd
Merge branch 'caffe2_core_hip' of github.com:petrex/pytorch into caff…
May 23, 2018
6e89ad4
Add MIOPEN CNN operators
May 23, 2018
3eb604e
Revert "Add MIOPEN CNN operators"
May 23, 2018
f15e33a
Add MIOPEN pooling operator
May 29, 2018
220cccc
Add MIOPEN activation operator
May 29, 2018
cb070ad
Add MIOPEN softmax operator
May 29, 2018
b4e9250
Add MIOPEN spatial batch norm operator
May 29, 2018
1c69215
Add MIOPEN loacl response normalization operator
May 29, 2018
50545c8
Add MIOPEN conv operator
May 29, 2018
6ade231
Clean-up LRN ops
May 29, 2018
873c7a4
enable fp16 in MIOPEN pool ops
May 29, 2018
48ac0de
Enable fp16 for MIOPEN relu op
May 29, 2018
5f51577
Enable fp16 for MIOPEN spatial batch norm op
May 29, 2018
9082d09
code clean-up
May 29, 2018
1218099
revert float16 support
May 29, 2018
0c26ec3
Merge remote-tracking branch 'origin' into caffe2_ops_miopen
May 30, 2018
78de772
Create Caffe2 python binding for AMD/ROCM/HIP
May 31, 2018
99c8a57
Add op fallback for HIP operator
May 31, 2018
0525352
add hip src/test files in cmake
May 31, 2018
6d90a5b
Merge branch 'caffe2_ops_miopen' of github.com:petrex/pytorch into ca…
May 31, 2018
ec1d5af
exclude hip src/test files
May 31, 2018
81c9d7c
Merge branch 'caffe2_ops_miopen' of github.com:petrex/pytorch into ca…
May 31, 2018
b1c35b9
fix python binding for hip backend
May 31, 2018
b6217e9
fix MIOPEN pooling op workspace
May 31, 2018
76a1a7d
hack to compile miopen operators
May 31, 2018
e689f6c
Merge branch 'master' into caffe2_ops_miopen
Jun 4, 2018
dc202db
fix include path for MIOPEN ops
Jun 4, 2018
8e5fe41
Fix include path
Jun 5, 2018
650c10f
Merge remote-tracking branch 'upstream/master' into caffe2_ops_miopen
Jun 6, 2018
eba55f5
Add HIP math utilities
Jun 6, 2018
2568091
Fix path for HIP math utils
Jun 6, 2018
f9532ea
cmake fix
Jun 6, 2018
05c4f67
Cmake fix / hipcc for hip files
Jun 7, 2018
691277b
suppress hipcc warning
Jun 7, 2018
f921237
cmake fix /replcae USE_HIP with USE_ROCM
Jun 7, 2018
90d9f2e
revert LoadHIP.cmake change
Jun 7, 2018
8b2ae80
fix include for thrust/cub-hip
Jun 7, 2018
92ec194
include path fix for conversion.h
Jun 7, 2018
111a2f2
Updated with latest upstream changes
Jun 8, 2018
7a0f256
clang format fixes
Jun 8, 2018
4e2d72f
Context_hip updates
Jun 8, 2018
e61ce22
Fixed typo in rocblas handle get function
Jun 8, 2018
46cc87d
Updated hipified math utils
Jun 8, 2018
48b4275
Updated math hip test util
Jun 8, 2018
481a54c
Updated context hip test
Jun 8, 2018
d08bc08
Updated common_hip
Jun 8, 2018
0e3e6db
Updated net async dag for HIP
Jun 8, 2018
32a3bec
Added MIOPEN in operator hip test
Jun 8, 2018
6223354
Merge branch 'master' into caffe2_ops_miopen
bddppq Jun 8, 2018
8dbcda5
Merge remote-tracking branch 'origin/master' into caffe2_ops_miopen
bddppq Jun 8, 2018
ddcd19d
fix
bddppq Jun 9, 2018
f4898ff
Merge remote-tracking branch 'origin/master' into caffe2_ops_miopen
bddppq Jun 9, 2018
1eff61f
C2 dependencies clean-up
Jun 9, 2018
d1f7950
Merge remote-tracking branch 'upstream/master' into caffe2_ops_miopen
Jun 9, 2018
dfa2447
Merge remote-tracking branch 'origin/master' into caffe2_ops_miopen
bddppq Jun 11, 2018
46a09d6
fix include path for building custom protobuf
Jun 11, 2018
e1ac5e7
Merge branch 'caffe2_ops_miopen' of github.com:petrex/pytorch into ca…
Jun 11, 2018
c25b71b
Merge remote-tracking branch 'upstream/master' into caffe2_ops_miopen
Jun 11, 2018
e2adc76
Decouple miopen pool op and conv_pool_op base
Jun 12, 2018
fcc7887
Merge branch 'master' into caffe2_ops_miopen
bddppq Jun 12, 2018
7288ff6
cmake refactor
bddppq Jun 12, 2018
10b89be
Merge remote-tracking branch 'origin/master' into caffe2_ops_miopen
bddppq Jun 12, 2018
8b0e549
fix operator_hip_test
bddppq Jun 13, 2018
3afa8ad
move all hip/miopen ops files into caffe2/operators/hip
bddppq Jun 13, 2018
e6ba5ea
sanitize cmake
bddppq Jun 13, 2018
fc0f876
Merge remote-tracking branch 'origin/master' into caffe2_ops_miopen
bddppq Jun 13, 2018
84e84ca
permission issue
bddppq Jun 13, 2018
0555871
remove extra parenthesis
bddppq Jun 13, 2018
3b59fc7
remove artifact from resolving merge conflict
bddppq Jun 13, 2018
ca17e2a
cont. sanitize cmake files
bddppq Jun 13, 2018
f567ca7
fix syntax error
bddppq Jun 13, 2018
f812be9
sanitize conversion.h
bddppq Jun 13, 2018
56020cb
.
bddppq Jun 13, 2018
859356b
Revert "."
bddppq Jun 13, 2018
64661fa
clang-format
bddppq Jun 13, 2018
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
8 changes: 8 additions & 0 deletions .jenkins/caffe2/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ if [[ $BUILD_ENVIRONMENT == *cuda* ]]; then
export PATH="/usr/local/cuda/bin:$PATH"
fi
if [[ $BUILD_ENVIRONMENT == *rocm* ]]; then
# TODO: This is patching the official FindHip to properly handly
# cmake generator expression. A PR is opened in the upstream repo here:
# https://github.com/ROCm-Developer-Tools/HIP/pull/516
# remove this hack once it's merged.
if [[ -f /opt/rocm/hip/cmake/FindHIP.cmake ]]; then
sudo sed -i 's/\ -I${dir}/\ $<$<BOOL:${dir}>:-I${dir}>/' /opt/rocm/hip/cmake/FindHIP.cmake
fi

export LANG=C.UTF-8
export LC_ALL=C.UTF-8
export HCC_AMDGPU_TARGET=gfx900
Expand Down
64 changes: 39 additions & 25 deletions caffe2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,32 +250,16 @@ endif()

# ---[ Caffe2 HIP sources.
if(USE_ROCM)
HIP_INCLUDE_DIRECTORIES(${Caffe2_HIP_INCLUDES})
set_source_files_properties(${Caffe2_HIP_SRCS} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
hip_add_library(caffe2_hip ${Caffe2_HIP_SRCS})

IF(BUILD_ATEN)
# Set necessary HIPCC Flags
SET(HIP_HCC_FLAGS "-fPIC -DCUDA_HAS_FP16=1 -D__HIP_NO_HALF_OPERATORS__=1 -D__HIP_NO_HALF_CONVERSIONS__=1 -D__HIP_PLATFORM_HCC__=1 ${HIP_HCC_FLAGS}")
SET(Caffe2_HIP_CXX_FLAGS "-fPIC -DCUDA_HAS_FP16=1 -D__HIP_NO_HALF_OPERATORS__=1 -D__HIP_NO_HALF_CONVERSIONS__=1 -D__HIP_PLATFORM_HCC__=1 ${Caffe2_HIP_CXX_FLAGS}")
ENDIF()

# Since the HIP_ADD_LIBRARY is a MACRO, we need to set HIP_HCC_FLAGS prior to calling it.
# Also, Since HIP_INCLUDE_DIRECTORIES is a MACRO, we must call it before HIP_ADD_LIBRARY.
HIP_ADD_LIBRARY(caffe2_hip ${Caffe2_HIP_SRCS})

set_target_properties(caffe2_hip PROPERTIES COMPILE_FLAGS ${Caffe2_HIP_CXX_FLAGS})

target_include_directories(
caffe2_hip PRIVATE ${Caffe2_HIP_INCLUDES})
target_include_directories(
caffe2_hip INTERFACE $<INSTALL_INTERFACE:include>)
target_link_libraries(caffe2_hip PUBLIC caffe2)
target_link_libraries(caffe2_hip PUBLIC ${Caffe2_HIP_DEPENDENCY_LIBS})

IF(BUILD_ATEN)
aten_set_target_props(caffe2_hip)
ENDIF()

target_link_libraries(caffe2_hip PUBLIC caffe2)
target_link_libraries(caffe2_hip PUBLIC ${Caffe2_HIP_DEPENDENCY_LIBS})

# https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_faq.md#what-if-hip-generates-error-of-symbol-multiply-defined-only-on-amd-machine
# To avoid having to do above, keep this commented.
set_target_properties(caffe2_hip PROPERTIES LINKER_LANGUAGE HIP)
Expand All @@ -300,9 +284,6 @@ if(BUILD_CAFFE2)
if (USE_CUDA)
list(APPEND Caffe2_ALL_TEST_SRCS ${Caffe2_GPU_TEST_SRCS})
endif()
if(USE_ROCM)
list(APPEND Caffe2_ALL_TEST_SRCS ${Caffe2_HIP_TEST_SRCS})
endif()

foreach(test_src ${Caffe2_ALL_TEST_SRCS})
get_filename_component(test_name ${test_src} NAME_WE)
Expand All @@ -319,12 +300,17 @@ if(BUILD_CAFFE2)

if(USE_ROCM)
foreach(test_src ${Caffe2_HIP_TEST_SRCS})
set_source_files_properties(${test_src} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
get_filename_component(test_name ${test_src} NAME_WE)
set_target_properties(${test_name} PROPERTIES COMPILE_FLAGS ${Caffe2_HIP_CXX_FLAGS})
set_target_properties(${test_name} PROPERTIES LINKER_LANGUAGE HIP)
hip_add_executable(${test_name} "${test_src}")
target_link_libraries(${test_name} ${Caffe2_MAIN_LIBS} gtest_main)
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.0)
target_compile_features(${test_name} PRIVATE cxx_range_for)
endif()
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
if (INSTALL_TEST)
install(TARGETS ${test_name} DESTINATION test)
endif()
endforeach()
endif()

Expand Down Expand Up @@ -426,6 +412,26 @@ if(BUILD_CAFFE2)
install(TARGETS caffe2_pybind11_state_gpu DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python")
endif()

if(USE_ROCM)
set_source_files_properties(${Caffe2_HIP_PYTHON_SRCS} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
hip_add_library(caffe2_pybind11_state_hip MODULE ${Caffe2_HIP_PYTHON_SRCS})
set_target_properties(caffe2_pybind11_state_hip PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
set_target_properties(caffe2_pybind11_state_hip PROPERTIES PREFIX "")
set_target_properties(caffe2_pybind11_state_hip PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
if (APPLE)
set_target_properties(caffe2_pybind11_state_hip PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif()
set_target_properties(
caffe2_pybind11_state_hip PROPERTIES LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/caffe2/python)
target_link_libraries(
caffe2_pybind11_state_hip caffe2_library caffe2_hip_library)
if (WIN32)
target_link_libraries(caffe2_pybind11_state_hip ${PYTHON_LIBRARIES})
endif(WIN32)
install(TARGETS caffe2_pybind11_state_hip DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python")
endif()

if (MSVC AND CMAKE_GENERATOR MATCHES "Visual Studio")
# If we are building under windows, we will copy the file from
# build/caffe2/python/{Debug,Release}/caffe2_pybind11_state.pyd
Expand All @@ -445,6 +451,14 @@ if(BUILD_CAFFE2)
$<TARGET_FILE:caffe2_pybind11_state_gpu>
${CMAKE_BINARY_DIR}/caffe2/python)
endif()
if (USE_ROCM)
add_dependencies(windows_python_copy_lib caffe2_pybind11_state_hip)
add_custom_command(
TARGET windows_python_copy_lib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:caffe2_pybind11_state_hip>
${CMAKE_BINARY_DIR}/caffe2/python)
endif()
endif()

# Finally, Copy all python files to build directory
Expand Down
4 changes: 3 additions & 1 deletion caffe2/core/hip/common_hip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ namespace {
class HipRuntimeFlagFlipper
{
public:
HipRuntimeFlagFlipper() { g_caffe2_has_hip_linked = true; }
HipRuntimeFlagFlipper() {
internal::SetHipRuntimeFlag();
}
};
static HipRuntimeFlagFlipper g_flipper;
} // namespace
Expand Down
Loading