Skip to content

Commit d802137

Browse files
author
zhangkaihuo
authored
Merge branch 'develop' into FFN
2 parents 88e74f4 + 59d8b8c commit d802137

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2470
-255
lines changed

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,6 @@ if(WITH_GPU)
300300
endif()
301301
endif()
302302

303-
if(WITH_CINN)
304-
include(cinn)
305-
endif()
306-
307303
if(WITH_ROCM)
308304
include(hip)
309305
include(miopen) # set miopen libraries, must before configure

cmake/cinn.cmake renamed to cmake/external/cinn.cmake

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ add_definitions(-w)
2727
include(ExternalProject)
2828
set(CINN_SOURCE_DIR ${THIRD_PARTY_PATH}/CINN)
2929
# TODO(zhhsplendid): Modify git tag after we have release tag
30-
set(CINN_GIT_TAG 3f004bfa3ed273ecf1de8e7b946433038c79b84f)
31-
set(CINN_OPTIONAL_ARGS -DWITH_CUDA=${WITH_GPU} -DWITH_CUDNN=${WITH_GPU} -DPUBLISH_LIBS=ON)
32-
set(CINN_BUILD_COMMAND $(MAKE) cinncore -j && $(MAKE) cinnapi -j)
30+
set(CINN_GIT_TAG e422c01b7875301996a2baf67a14ba61b0e6192a)
31+
set(CINN_OPTIONAL_ARGS -DPY_VERSION=${PY_VERSION} -DWITH_CUDA=${WITH_GPU} -DWITH_CUDNN=${WITH_GPU} -DPUBLISH_LIBS=ON -DWITH_TESTING=ON)
32+
set(CINN_BUILD_COMMAND $(MAKE) cinnapi -j)
3333
ExternalProject_Add(
3434
external_cinn
3535
${EXTERNAL_PROJECT_LOG_ARGS}
3636
GIT_REPOSITORY "${GIT_URL}/PaddlePaddle/CINN.git"
3737
GIT_TAG ${CINN_GIT_TAG}
3838
PREFIX ${CINN_SOURCE_DIR}
39-
UPDATE_COMMAND ""
4039
BUILD_COMMAND ${CINN_BUILD_COMMAND}
4140
INSTALL_COMMAND ""
4241
CMAKE_ARGS ${CINN_OPTIONAL_ARGS})
@@ -52,49 +51,20 @@ message(STATUS "CINN BINARY_DIR: ${CINN_BINARY_DIR}")
5251
message(STATUS "CINN SOURCE_DIR: ${CINN_SOURCE_DIR}")
5352

5453

55-
#########################
56-
# Add CINN's dependencies
57-
#########################
54+
######################################
55+
# Add CINN's dependencies header files
56+
######################################
5857

5958
# Add absl
60-
set(ABSL_LIB_NAMES
61-
hash
62-
wyhash
63-
city
64-
strings
65-
throw_delegate
66-
bad_any_cast_impl
67-
bad_optional_access
68-
bad_variant_access
69-
raw_hash_set
70-
)
71-
set(ABSL_LIB_DIR "${CINN_BINARY_DIR}/dist/third_party/absl/lib")
7259
set(ABSL_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/third_party/absl/include")
73-
add_library(absl STATIC IMPORTED GLOBAL)
74-
set_target_properties(absl PROPERTIES IMPORTED_LOCATION ${ABSL_LIB_DIR}/libabsl_base.a)
75-
foreach(lib_name ${ABSL_LIB_NAMES})
76-
target_link_libraries(absl INTERFACE ${ABSL_LIB_DIR}/libabsl_${lib_name}.a)
77-
endforeach()
7860
include_directories(${ABSL_INCLUDE_DIR})
7961

8062
# Add isl
81-
set(ISL_LIB_DIR "${CINN_BINARY_DIR}/dist/third_party/isl/lib")
8263
set(ISL_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/third_party/isl/include")
83-
add_library(isl STATIC IMPORTED GLOBAL)
84-
set_target_properties(isl PROPERTIES IMPORTED_LOCATION ${ISL_LIB_DIR}/libisl.a)
8564
include_directories(${ISL_INCLUDE_DIR})
8665

8766
# Add LLVM
88-
set(LLVM_LIB_NAMES
89-
ExecutionEngine
90-
)
91-
set(LLVM_LIB_DIR "${CINN_BINARY_DIR}/dist/third_party/llvm/lib")
9267
set(LLVM_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/third_party/llvm/include")
93-
add_library(llvm STATIC IMPORTED GLOBAL)
94-
set_target_properties(llvm PROPERTIES IMPORTED_LOCATION ${LLVM_LIB_DIR}/libLLVMCore.a)
95-
foreach(lib_name ${LLVM_LIB_NAMES})
96-
target_link_libraries(llvm INTERFACE ${LLVM_LIB_DIR}/libLLVM${lib_name}.a)
97-
endforeach()
9868
include_directories(${LLVM_INCLUDE_DIR})
9969

10070
######################################################
@@ -108,5 +78,5 @@ set(CINN_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/cinn/include")
10878
add_library(cinn SHARED IMPORTED GLOBAL)
10979
set_target_properties(cinn PROPERTIES IMPORTED_LOCATION "${CINN_LIB_LOCATION}/${CINN_LIB_NAME}")
11080
include_directories(${CINN_INCLUDE_DIR})
111-
add_dependencies(cinn external_cinn absl isl llvm glog gflag)
81+
add_dependencies(cinn external_cinn)
11282

cmake/external/xpu.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ELSE ()
3535
ENDIF()
3636

3737
SET(XPU_BASE_URL_WITHOUT_DATE "https://baidu-kunlun-product.cdn.bcebos.com/KL-SDK/klsdk-dev")
38-
SET(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/20210921")
38+
SET(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/20211020")
3939
SET(XPU_XRE_URL "${XPU_BASE_URL}/${XPU_XRE_DIR_NAME}.tar.gz" CACHE STRING "" FORCE)
4040
SET(XPU_XDNN_URL "${XPU_BASE_URL}/${XPU_XDNN_DIR_NAME}.tar.gz" CACHE STRING "" FORCE)
4141
SET(XPU_XCCL_URL "${XPU_BASE_URL_WITHOUT_DATE}/20210623/${XPU_XCCL_DIR_NAME}.tar.gz" CACHE STRING "" FORCE)

cmake/operators.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function(op_library TARGET)
299299
file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${TARGET}, CUDNN);\n")
300300
endif()
301301

302-
if (WITH_XPU AND ${xpu_cc_srcs_len} GREATER 0)
302+
if (WITH_XPU AND ${pybind_flag} EQUAL 0 AND ${xpu_cc_srcs_len} GREATER 0)
303303
file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${TARGET}, XPU);\n")
304304
endif()
305305

cmake/third_party.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ if (WITH_LITE)
360360
include(external/lite)
361361
endif (WITH_LITE)
362362

363+
if (WITH_CINN)
364+
message(STATUS "Compile Paddle with CINN.")
365+
include(external/cinn)
366+
add_definitions(-DPADDLE_WITH_CINN)
367+
endif (WITH_CINN)
368+
363369
if (WITH_CRYPTO)
364370
include(external/cryptopp) # download, build, install cryptopp
365371
list(APPEND third_party_deps extern_cryptopp)

paddle/fluid/framework/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ add_subdirectory(details)
2626
add_subdirectory(fleet)
2727
add_subdirectory(io)
2828
add_subdirectory(new_executor)
29-
add_subdirectory(paddle2cinn)
29+
if (WITH_CINN)
30+
add_subdirectory(paddle2cinn)
31+
endif()
3032
#ddim lib
3133
proto_library(framework_proto SRCS framework.proto)
3234
proto_library(pass_desc_proto SRCS pass_desc.proto DEPS framework_proto)
@@ -353,7 +355,7 @@ target_link_libraries(executor while_op_helper executor_gc_helper recurrent_op_h
353355
cc_library(parallel_executor SRCS parallel_executor.cc DEPS
354356
threaded_ssa_graph_executor scope_buffered_ssa_graph_executor parallel_ssa_graph_executor async_ssa_graph_executor
355357
graph build_strategy bind_threaded_ssa_graph_executor collective_helper
356-
fast_threaded_ssa_graph_executor variable_helper cinn_runner)
358+
fast_threaded_ssa_graph_executor variable_helper)
357359

358360
cc_library(executor_cache SRCS executor_cache.cc DEPS parallel_executor)
359361
if(WITH_PSCORE)

paddle/fluid/framework/details/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ set(IR_PASS_DEPS graph_viz_pass multi_devices_graph_pass
139139
coalesce_grad_tensor_pass fuse_all_reduce_op_pass backward_optimizer_op_deps_pass
140140
fuse_adam_op_pass fuse_sgd_op_pass fuse_momentum_op_pass
141141
sync_batch_norm_pass runtime_context_cache_pass graph_to_program_pass
142-
fix_op_run_order_pass build_cinn_pass)
142+
fix_op_run_order_pass)
143+
144+
if (WITH_CINN)
145+
set(IR_PASS_DEPS ${IR_PASS_DEPS} build_cinn_pass)
146+
endif()
147+
143148
if(NOT APPLE AND NOT WIN32 AND (WITH_GPU OR WITH_ROCM))
144149
set(IR_PASS_DEPS ${IR_PASS_DEPS} fusion_group_pass)
145150
endif()

paddle/fluid/framework/details/build_strategy.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ limitations under the License. */
2020
#include "paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.h"
2121

2222
DECLARE_bool(convert_all_blocks);
23-
DECLARE_bool(use_cinn);
2423
DECLARE_bool(use_mkldnn);
24+
#ifdef PADDLE_WITH_CINN
25+
DECLARE_bool(use_cinn);
26+
#endif
2527

2628
namespace paddle {
2729
namespace framework {
@@ -72,10 +74,13 @@ class ParallelExecutorPassBuilder : public ir::PassBuilder {
7274
// Note: This pass is used to check whether the multi_device_graph is right.
7375
AppendPass("multi_devices_check_pass");
7476

75-
// Note: This pass is used to enable cinn.
77+
#ifdef PADDLE_WITH_CINN
7678
if (FLAGS_use_cinn) {
79+
// Note: This pass is used to enable cinn.
7780
AppendPass("build_cinn_pass");
7881
}
82+
#endif
83+
7984
SetCollectiveContext();
8085
}
8186

@@ -486,7 +491,9 @@ USE_PASS(fuse_momentum_op_pass);
486491
USE_PASS(fuse_all_reduce_op_pass);
487492
USE_PASS(runtime_context_cache_pass);
488493
USE_PASS(add_reader_dependency_pass);
494+
#ifdef PADDLE_WITH_CINN
489495
USE_PASS(build_cinn_pass);
496+
#endif
490497
#ifdef PADDLE_WITH_MKLDNN
491498
USE_PASS(mkldnn_placement_pass);
492499
#endif

paddle/fluid/framework/ir/cinn_lib_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ limitations under the License. */
2424
#include <cuda_runtime.h>
2525
#endif
2626

27+
#include "cinn/cinn.h"
2728
#include "cinn/common/target.h"
2829
#include "cinn/frontend/net_builder.h"
2930
#include "cinn/frontend/syntax.h"

paddle/fluid/framework/new_executor/event_count.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@
5050
#include <cstdlib>
5151
#include <mutex>
5252
#include <vector>
53-
#include "paddle/fluid/framework/new_executor/workqueue_utils.h"
5453

5554
namespace paddle {
5655
namespace framework {
5756

57+
void* AlignedMalloc(size_t size, size_t alignment);
58+
void AlignedFree(void* memory_ptr);
59+
5860
class EventCount {
5961
public:
6062
class Waiter;

0 commit comments

Comments
 (0)