Skip to content

Commit

Permalink
Replace WITH_MKLDNN WITH_ONEDNN (PaddlePaddle#63233)
Browse files Browse the repository at this point in the history
  • Loading branch information
co63oc authored Apr 10, 2024
1 parent 0878a9b commit 2b7baef
Show file tree
Hide file tree
Showing 45 changed files with 86 additions and 79 deletions.
6 changes: 3 additions & 3 deletions cmake/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if(WITH_MKL)
add_dependencies(cinn_mklml ${MKLML_PROJECT})
add_definitions(-DCINN_WITH_MKL_CBLAS)
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_definitions(-DCINN_WITH_DNNL)
endif()

Expand Down Expand Up @@ -177,7 +177,7 @@ target_link_libraries(cinnapi ${PYTHON_LIBRARIES})
if(WITH_MKL)
target_link_libraries(cinnapi cinn_mklml)
add_dependencies(cinnapi cinn_mklml)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
target_link_libraries(cinnapi ${MKLDNN_LIB})
add_dependencies(cinnapi ${ONEDNN_PROJECT})
endif()
Expand Down Expand Up @@ -238,7 +238,7 @@ function(gen_cinncore LINKTYPE)
if(WITH_MKL)
target_link_libraries(${CINNCORE_TARGET} cinn_mklml)
add_dependencies(${CINNCORE_TARGET} cinn_mklml)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
target_link_libraries(${CINNCORE_TARGET} ${MKLDNN_LIB})
add_dependencies(${CINNCORE_TARGET} ${ONEDNN_PROJECT})
endif()
Expand Down
4 changes: 2 additions & 2 deletions cmake/external/lite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if(NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR)
set(LITE_OPTIONAL_ARGS
-DWITH_MKL=OFF
-DLITE_WITH_CUDA=OFF
-DWITH_MKLDNN=OFF
-DWITH_ONEDNN=OFF
-DLITE_WITH_X86=OFF
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON
-DLITE_WITH_PROFILE=OFF
Expand Down Expand Up @@ -141,7 +141,7 @@ if(NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR)
set(LITE_OPTIONAL_ARGS
-DWITH_MKL=ON
-DLITE_WITH_CUDA=OFF
-DWITH_MKLDNN=OFF
-DWITH_ONEDNN=OFF
-DLITE_WITH_X86=ON
-DLITE_WITH_PROFILE=OFF
-DWITH_LITE=OFF
Expand Down
2 changes: 1 addition & 1 deletion cmake/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ function(paddle_test_build TARGET_NAME)
${paddle_test_DEPS} common paddle_gtest_main_new)
add_dependencies(${TARGET_NAME} ${paddle_lib} ${paddle_test_DEPS} common
paddle_gtest_main_new)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
target_link_libraries(${TARGET_NAME} onednn)
add_dependencies(${TARGET_NAME} onednn)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/inference_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function(copy_part_of_third_party TARGET DST)
endif()
endif()

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(dst_dir "${DST}/third_party/install/onednn")
if(WIN32)
copy(
Expand Down
8 changes: 4 additions & 4 deletions cmake/operators.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function(register_onednn_kernel TARGET)
"The MKLDNN kernel file of ${TARGET} should contains at least one *.*_onednn_op.cc file"
)
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
cc_library(
${TARGET}
SRCS ${onednn_cc_srcs}
Expand Down Expand Up @@ -237,7 +237,7 @@ function(op_library TARGET)
list(APPEND miopen_cu_srcs ${MIOPEN_FILE}.cu)
endif()
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
string(REPLACE "_op" "_onednn_op" MKLDNN_FILE "${TARGET}")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/onednn/${MKLDNN_FILE}.cc)
list(APPEND onednn_cc_srcs onednn/${MKLDNN_FILE}.cc)
Expand Down Expand Up @@ -275,7 +275,7 @@ function(op_library TARGET)
list(APPEND cudnn_cu_cc_srcs ${src})
elseif(WITH_GPU AND ${src} MATCHES ".*\\.cu.cc$")
list(APPEND cu_cc_srcs ${src})
elseif(WITH_MKLDNN AND ${src} MATCHES ".*_onednn_op.cc$")
elseif(WITH_ONEDNN AND ${src} MATCHES ".*_onednn_op.cc$")
list(APPEND onednn_cc_srcs ${src})
elseif(WITH_XPU AND ${src} MATCHES ".*_op_xpu.cc$")
list(APPEND xpu_cc_srcs ${src})
Expand Down Expand Up @@ -610,7 +610,7 @@ function(op_library TARGET)
endif()

# pybind USE_OP_DEVICE_KERNEL for MKLDNN
if(WITH_MKLDNN AND ${onednn_cc_srcs_len} GREATER 0)
if(WITH_ONEDNN AND ${onednn_cc_srcs_len} GREATER 0)
# Append first implemented MKLDNN activation operator
if(${MKLDNN_FILE} STREQUAL "activation_onednn_op")
file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(softplus, MKLDNN);\n")
Expand Down
12 changes: 6 additions & 6 deletions cmake/third_party.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,19 @@ if(WIN32 OR APPLE)
endif()

set(WITH_MKLML ${WITH_MKL})
if(NOT DEFINED WITH_MKLDNN)
if(NOT DEFINED WITH_ONEDNN)
if(WITH_MKL AND AVX2_FOUND)
set(WITH_MKLDNN ON)
set(WITH_ONEDNN ON)
else()
message(STATUS "Do not have AVX2 intrinsics and disabled MKL-DNN.")
set(WITH_MKLDNN OFF)
set(WITH_ONEDNN OFF)
endif()
endif()

if(WIN32)
if(MSVC)
if(MSVC_VERSION LESS 1920)
set(WITH_MKLDNN OFF)
set(WITH_ONEDNN OFF)
endif()
endif()
endif()
Expand Down Expand Up @@ -303,7 +303,7 @@ if(WITH_CINN)
if(WITH_MKL)
add_definitions(-DCINN_WITH_MKL_CBLAS)
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_definitions(-DCINN_WITH_DNNL)
endif()
include(cmake/cinn/version.cmake)
Expand Down Expand Up @@ -362,7 +362,7 @@ elseif(${CBLAS_PROVIDER} STREQUAL EXTERN_OPENBLAS)
list(APPEND third_party_deps extern_openblas)
endif()

if(WITH_MKLDNN)
if(WITH_ONEDNN)
include(external/onednn) # download, build, install onednn
list(APPEND third_party_deps extern_onednn)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function(version version_file)
"Paddle version: ${PADDLE_VERSION}\n"
"GIT COMMIT ID: ${PADDLE_GIT_COMMIT}\n"
"WITH_MKL: ${WITH_MKL}\n"
"WITH_MKLDNN: ${WITH_MKLDNN}\n"
"WITH_ONEDNN: ${WITH_ONEDNN}\n"
"WITH_GPU: ${WITH_GPU}\n"
"WITH_ROCM: ${WITH_ROCM}\n"
"WITH_IPU: ${WITH_IPU}\n")
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/runtime/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gather_srcs(cinnapi_src SRCS host_intrinsics.cc thread_backend.cc)

if(WITH_MKL_CBLAS)
gather_srcs(cinnapi_src SRCS mkl_math.cc cblas.cc)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
gather_srcs(cinnapi_src SRCS onednn_math.cc)
endif()
endif()
Expand All @@ -15,7 +15,7 @@ if(WITH_MKL_CBLAS)
cinn_cc_test(test_mkl_math SRCS mkl_math_test.cc mkl_math.cc DEPS cinncore)
endif()

if(WITH_MKLDNN)
if(WITH_ONEDNN)
cinn_cc_test(test_onednn_math SRCS onednn_math_test.cc onednn_math.cc DEPS
cinncore)
endif()
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/distributed/index_dataset/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cc_library(
index_wrapper
SRCS index_wrapper.cc
DEPS index_dataset_proto framework_io)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
cc_library(
index_sampler
SRCS index_sampler.cc
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/eager/auto_code_generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if(WIN32)
list(APPEND EAGER_CODEGEN_DEPS ${eager_generator_path}/openblas.dll)
endif()

if(WITH_MKLDNN)
if(WITH_ONEDNN)
message("Copied mkldnn.dll for Eager AutoCodeGen")
add_custom_command(
OUTPUT ${eager_generator_path}/mkldnn.dll
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ endif()

# every source file that includes "dnnl.h" must depends on onednn
# or, the first one should depends on onednn
if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_dependencies(var_type_traits onednn)
endif()

Expand Down Expand Up @@ -275,7 +275,7 @@ cc_library(

# every source file that includes "dnnl.h" must depends on onednn
# or, the first one should depends on onednn
if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_dependencies(shape_inference onednn)
endif()

Expand Down Expand Up @@ -954,7 +954,7 @@ cc_library(
DEPS common)
target_link_libraries(type_info pir op_dialect)
add_dependencies(type_info framework_proto auto_parallel_proto xxhash)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_dependencies(type_info onednn)
endif()

Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/framework/details/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ set(op_handle_deps
selected_rows_utils
reference_count_pass_helper)

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(op_handle_deps ${op_handle_deps} onednn)
endif()

Expand Down Expand Up @@ -161,6 +161,6 @@ cc_library(
SRCS build_strategy.cc
DEPS pass_builder ${IR_PASS_DEPS})

if(WITH_MKLDNN)
if(WITH_ONEDNN)
target_link_libraries(build_strategy onednn_placement_pass)
endif()
2 changes: 1 addition & 1 deletion paddle/fluid/framework/executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ void Executor::EnableMKLDNN(const ProgramDesc& program) {
}
#else
LOG(WARNING)
<< "'MKLDNN' is not supported, Please re-compile with WITH_MKLDNN option";
<< "'MKLDNN' is not supported, Please re-compile with WITH_ONEDNN option";
#endif
}
} // namespace framework
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ cc_library(
SRCS ${framework_io_srcs}
DEPS ${framework_io_deps})

if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_dependencies(framework_io onednn)
endif()
4 changes: 2 additions & 2 deletions paddle/fluid/framework/ir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ if(WITH_GPU OR WITH_ROCM)
pass_library(embedding_eltwise_layernorm_fuse_pass inference)
endif()

if(WITH_MKLDNN)
if(WITH_ONEDNN)
pass_library(onednn_placement_pass base DEPS placement_pass_base DIR onednn)
pass_library(depthwise_conv_onednn_pass base DIR onednn)
pass_library(conv_affine_channel_onednn_fuse_pass inference DIR onednn)
Expand Down Expand Up @@ -538,7 +538,7 @@ if(NOT WIN32)
SRCS dense_multihead_matmul_to_sparse_pass_tester.cc
DEPS multihead_matmul_fuse_pass dense_multihead_matmul_to_sparse_pass)
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
cc_test(
test_depthwise_conv_onednn_pass
SRCS onednn/depthwise_conv_onednn_pass_tester.cc
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/framework/new_executor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(NOT (WITH_CINN))
${CMAKE_CURRENT_SOURCE_DIR}/instruction/cinn_jit_instruction.cc)
endif()

if(NOT WITH_MKLDNN)
if(NOT WITH_ONEDNN)
list(
REMOVE_ITEM
standalone_executor_srcs
Expand Down Expand Up @@ -54,6 +54,6 @@ cc_library(

add_dependencies(standalone_executor xxhash framework_proto)

if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_dependencies(standalone_executor onednn)
endif()
2 changes: 1 addition & 1 deletion paddle/fluid/framework/paddle2cinn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(paddle2cinn_deps
auto_schedule_proto
parallel_executor
common)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(paddle2cinn ${paddle2cinn} onednn)
endif()

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/inference/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ endif()

add_subdirectory(details)

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(mkldnn_quantizer_cfg mkldnn_quantizer_config)
set(mkldnn_quantizer_src ${CMAKE_CURRENT_SOURCE_DIR}/onednn_quantizer.cc)
cc_library(
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/memory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_subdirectory(allocation)

file(GLOB fluid_memory_srcs "*.cc")

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(ONEDNN_CTX_DEPS onednn)
else()
set(ONEDNN_CTX_DEPS)
Expand Down
15 changes: 11 additions & 4 deletions paddle/fluid/pir/dialect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ set(generated_files_pd_op
"${pir_bwd_op_source_file}"
"${pir_update_op_source_file}")

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(pir_op_onednn_yaml ${parsed_op_dir}/onednn.parsed.yaml)

set(pd_onednn_op_yaml_file
Expand Down Expand Up @@ -250,7 +250,7 @@ set(op_dialect_srcs
${api_source_file}
${PADDLE_SOURCE_DIR}/paddle/fluid/pir/transforms/shape_optimization_pass.cc)

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(op_dialect_srcs
${op_dialect_srcs} ${onednn_op_source_file} ${op_onednn_info_file}
${CMAKE_CURRENT_SOURCE_DIR}/operator/ir/manual_onednn_op.cc)
Expand All @@ -263,7 +263,14 @@ file(GLOB_RECURSE dist_dialect_srcs
# if(WITH_DISTRIBUTE) FIXME in next PR
set(op_dialect_srcs ${op_dialect_srcs} ${dist_dialect_srcs})
# endif()
set(op_dialect_deps phi common pir type_info string_helper global_utils amp)
set(op_dialect_deps
phi
common
pir
type_info
string_helper
global_utils
amp)
if(WITH_ROCM)
set(op_dialect_deps ${op_dialect_deps} global_utils)
endif()
Expand All @@ -283,7 +290,7 @@ set(op_dialect_vjp_srcs
${op_vjp_source_file}
${PADDLE_SOURCE_DIR}/paddle/fluid/primitive/base/decomp_trans.cc)

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(op_dialect_vjp_srcs
${op_dialect_vjp_srcs}
${CMAKE_CURRENT_SOURCE_DIR}/operator/ir/op_onednn_dialect.cc)
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pir/drr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ if(WITH_CINN)
set(DRR_SRCS ${DRR_SRCS} ${CINN_SOURCE_FILE})
endif()

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(onednn_dialect_name onednn_op)
set(pir_op_onednn_yaml
${PADDLE_BINARY_DIR}/paddle/fluid/pir/dialect/operator/ir/generated/onednn.parsed.yaml
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pir/transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(NOT WITH_CINN)
${CMAKE_CURRENT_SOURCE_DIR}/sub_graph_detector.cc)
endif()

if(NOT WITH_MKLDNN)
if(NOT WITH_ONEDNN)
file(GLOB_RECURSE onednn_srcs "onednn/*.cc")
list(REMOVE_ITEM transforms_srcs ${onednn_srcs})
endif()
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ cc_test(
SRCS place_test.cc
DEPS place glog phi common)

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(ONEDNN_CTX_DEPS onednn)
else()
set(ONEDNN_CTX_DEPS)
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ if(WITH_PYTHON)
list(APPEND OP_IMPL_DEPS ${op_impl_path}/openblas.dll)
list(APPEND EAGER_OP_IMPL_DEPS ${op_impl_path}/openblas.dll)
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_custom_command(
OUTPUT ${op_impl_path}/mkldnn.dll
COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_SHARED_LIB} ${op_impl_path}
Expand Down Expand Up @@ -474,7 +474,7 @@ if(WITH_PYTHON)
list(APPEND OP_IMPL_DEPS ${CMAKE_CURRENT_BINARY_DIR}/libiomp5.so)
list(APPEND EAGER_OP_IMPL_DEPS ${CMAKE_CURRENT_BINARY_DIR}/libiomp5.so)
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libdnnl.so.0
COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_SHARED_LIB}
Expand Down
Loading

0 comments on commit 2b7baef

Please sign in to comment.