未验证 提交 9af72957 编写于 作者: W wanghuancoder 提交者: GitHub

[Eager] open eager when WITH_PYTHON (#39979)

* open eager when WITH_PYTHON, test=develop

* refine, test=develop

* refine, test=develop

* add DWITH_PYTHON for gen_fluid_lib, test=develop
上级 26e2b918
...@@ -2,7 +2,7 @@ set(eager_deps phi phi_api hook_utils tensor_utils utils global_utils backward p ...@@ -2,7 +2,7 @@ set(eager_deps phi phi_api hook_utils tensor_utils utils global_utils backward p
set(fluid_deps tracer layer proto_desc operator op_registry variable_helper memcpy) set(fluid_deps tracer layer proto_desc operator op_registry variable_helper memcpy)
set(generated_deps dygraph_function dygraph_node) set(generated_deps dygraph_function dygraph_node)
if(NOT ON_INFER) if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
message("Performing Eager Dygraph Auto Code Generation") message("Performing Eager Dygraph Auto Code Generation")
add_subdirectory(auto_code_generator) add_subdirectory(auto_code_generator)
endif() endif()
......
add_subdirectory(eager_generated) add_subdirectory(eager_generated)
if(NOT ON_INFER) if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
add_subdirectory(fluid_generated) add_subdirectory(fluid_generated)
endif() endif()
cc_library(scale_node SRCS scale_node.cc DEPS global_utils phi phi_api grad_node_info) cc_library(scale_node SRCS scale_node.cc DEPS global_utils phi phi_api grad_node_info)
if(NOT ON_INFER) if(NOT (NOT WITH_PYTHON AND ON_INFER))
cc_library(final_dygraph_node SRCS nodes.cc DEPS ${eager_deps}) cc_library(final_dygraph_node SRCS nodes.cc DEPS ${eager_deps})
add_dependencies(final_dygraph_node eager_final_state_codegen) add_dependencies(final_dygraph_node eager_final_state_codegen)
endif() endif()
cc_library(eager_scale SRCS scale.cc DEPS phi_api phi autograd_meta scale_node) cc_library(eager_scale SRCS scale.cc DEPS phi_api phi autograd_meta scale_node)
if(NOT ON_INFER) if(NOT (NOT WITH_PYTHON AND ON_INFER))
cc_library(final_dygraph_function SRCS dygraph_functions.cc DEPS ${eager_deps}) cc_library(final_dygraph_function SRCS dygraph_functions.cc DEPS ${eager_deps})
add_dependencies(final_dygraph_function eager_final_state_codegen) add_dependencies(final_dygraph_function eager_final_state_codegen)
endif() endif()
add_subdirectory(data_structure_tests) add_subdirectory(data_structure_tests)
add_subdirectory(task_tests) add_subdirectory(task_tests)
if(NOT ON_INFER) if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
add_subdirectory(performance_tests) add_subdirectory(performance_tests)
endif() endif()
...@@ -6,7 +6,7 @@ cc_test(test_egr_task_hook SRCS hook_test.cc DEPS ${eager_deps} ${fluid_deps} ea ...@@ -6,7 +6,7 @@ cc_test(test_egr_task_hook SRCS hook_test.cc DEPS ${eager_deps} ${fluid_deps} ea
cc_test(test_egr_task_cross_batch SRCS cross_batch_accumulation_test.cc DEPS ${eager_deps} ${fluid_deps} eager_scale scale_node) cc_test(test_egr_task_cross_batch SRCS cross_batch_accumulation_test.cc DEPS ${eager_deps} ${fluid_deps} eager_scale scale_node)
cc_test(test_egr_task_fwd_bwd_joint SRCS fwd_bwd_joint_test.cc DEPS ${eager_deps} ${fluid_deps} eager_scale scale_node) cc_test(test_egr_task_fwd_bwd_joint SRCS fwd_bwd_joint_test.cc DEPS ${eager_deps} ${fluid_deps} eager_scale scale_node)
if(NOT ON_INFER) if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
cc_test(test_egr_task_hook_intermidiate SRCS hook_test_intermidiate.cc DEPS ${eager_deps} ${fluid_deps} ${generated_deps} dygraph_node) cc_test(test_egr_task_hook_intermidiate SRCS hook_test_intermidiate.cc DEPS ${eager_deps} ${fluid_deps} ${generated_deps} dygraph_node)
cc_test(test_egr_task_autocodegen SRCS generated_test.cc DEPS ${eager_deps} ${fluid_deps} ${generated_deps}) cc_test(test_egr_task_autocodegen SRCS generated_test.cc DEPS ${eager_deps} ${fluid_deps} ${generated_deps})
endif() endif()
...@@ -242,7 +242,7 @@ if(WITH_PYTHON) ...@@ -242,7 +242,7 @@ if(WITH_PYTHON)
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_impl_file} ${impl_file} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_impl_file} ${impl_file}
COMMENT "copy_if_different ${tmp_impl_file} to ${impl_file}" COMMENT "copy_if_different ${tmp_impl_file} to ${impl_file}"
DEPENDS ${OP_IMPL_DEPS}) DEPENDS ${OP_IMPL_DEPS})
if(NOT ON_INFER) if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
add_custom_command(OUTPUT ${eager_impl_file} add_custom_command(OUTPUT ${eager_impl_file}
COMMAND ${CMAKE_BINARY_DIR}/paddle/fluid/pybind/eager_op_function_generator_retry.bat COMMAND ${CMAKE_BINARY_DIR}/paddle/fluid/pybind/eager_op_function_generator_retry.bat
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_eager_impl_file} ${eager_impl_file} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_eager_impl_file} ${eager_impl_file}
...@@ -276,7 +276,7 @@ if(WITH_PYTHON) ...@@ -276,7 +276,7 @@ if(WITH_PYTHON)
COMMENT "copy_if_different ${tmp_impl_file} to ${impl_file}" COMMENT "copy_if_different ${tmp_impl_file} to ${impl_file}"
DEPENDS ${OP_IMPL_DEPS} DEPENDS ${OP_IMPL_DEPS}
VERBATIM) VERBATIM)
if(NOT ON_INFER) if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
add_custom_command(OUTPUT ${eager_impl_file} add_custom_command(OUTPUT ${eager_impl_file}
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:." COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:."
"${CMAKE_CURRENT_BINARY_DIR}/eager_op_function_generator" "${CMAKE_CURRENT_BINARY_DIR}/eager_op_function_generator"
...@@ -288,7 +288,7 @@ if(WITH_PYTHON) ...@@ -288,7 +288,7 @@ if(WITH_PYTHON)
endif() endif()
endif(WIN32) endif(WIN32)
add_custom_target(op_function_generator_cmd ALL DEPENDS ${impl_file}) add_custom_target(op_function_generator_cmd ALL DEPENDS ${impl_file})
if(NOT ON_INFER) if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
add_custom_target(eager_op_function_generator_cmd ALL DEPENDS ${eager_impl_file}) add_custom_target(eager_op_function_generator_cmd ALL DEPENDS ${eager_impl_file})
endif() endif()
...@@ -296,7 +296,7 @@ if(WITH_PYTHON) ...@@ -296,7 +296,7 @@ if(WITH_PYTHON)
cc_library(op_function_common SRCS op_function_common.cc DEPS ${PYBIND_DEPS}) cc_library(op_function_common SRCS op_function_common.cc DEPS ${PYBIND_DEPS})
list(APPEND PYBIND_DEPS op_function_common) list(APPEND PYBIND_DEPS op_function_common)
if(NOT ON_INFER) if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
cc_library(paddle_eager cc_library(paddle_eager
SRCS eager.cc eager_functions.cc eager_method.cc eager_properties.cc eager_utils.cc SRCS eager.cc eager_functions.cc eager_method.cc eager_properties.cc eager_utils.cc
DEPS eager_api autograd_meta backward grad_node_info phi op_function_common final_dygraph_function final_dygraph_node dygraph_function dygraph_node accumulation_node global_utils utils python) DEPS eager_api autograd_meta backward grad_node_info phi op_function_common final_dygraph_function final_dygraph_node dygraph_function dygraph_node accumulation_node global_utils utils python)
......
...@@ -79,12 +79,10 @@ limitations under the License. */ ...@@ -79,12 +79,10 @@ limitations under the License. */
#include "paddle/fluid/platform/profiler.h" #include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/pybind/cuda_streams_py.h" #include "paddle/fluid/pybind/cuda_streams_py.h"
#include "paddle/fluid/pybind/distributed_py.h" #include "paddle/fluid/pybind/distributed_py.h"
#include "paddle/phi/core/compat/convert_utils.h"
#include "paddle/phi/core/lod_utils.h"
#ifndef PADDLE_ON_INFERENCE
#include "paddle/fluid/pybind/eager.h" #include "paddle/fluid/pybind/eager.h"
#endif
#include "paddle/fluid/pybind/io.h" #include "paddle/fluid/pybind/io.h"
#include "paddle/phi/core/compat/convert_utils.h"
#include "paddle/phi/core/lod_utils.h"
#include "paddle/utils/none.h" #include "paddle/utils/none.h"
#ifdef PADDLE_WITH_ASCEND #ifdef PADDLE_WITH_ASCEND
#include "paddle/fluid/pybind/ascend_wrapper_py.h" #include "paddle/fluid/pybind/ascend_wrapper_py.h"
...@@ -529,9 +527,7 @@ PYBIND11_MODULE(core_avx, m) { ...@@ -529,9 +527,7 @@ PYBIND11_MODULE(core_avx, m) {
PYBIND11_MODULE(core_noavx, m) { PYBIND11_MODULE(core_noavx, m) {
#endif #endif
#ifndef PADDLE_ON_INFERENCE
BindEager(&m); BindEager(&m);
#endif
BindCudaStream(&m); BindCudaStream(&m);
// Not used, just make sure cpu_info.cc is linked. // Not used, just make sure cpu_info.cc is linked.
......
...@@ -2374,7 +2374,7 @@ EOF ...@@ -2374,7 +2374,7 @@ EOF
fi fi
startTime_s=`date +%s` startTime_s=`date +%s`
set +e set +e
cmake .. -DWITH_DISTRIBUTE=OFF -DON_INFER=ON -DWITH_TENSORRT=ON -DCUDA_ARCH_NAME=${CUDA_ARCH_NAME:-Auto};build_error=$? cmake .. -DWITH_DISTRIBUTE=OFF -DON_INFER=ON -DWITH_TENSORRT=ON -DCUDA_ARCH_NAME=${CUDA_ARCH_NAME:-Auto} -DWITH_PYTHON=${WITH_PYTHON:-ON};build_error=$?
# reset ccache zero stats for collect PR's actual hit rate # reset ccache zero stats for collect PR's actual hit rate
ccache -z ccache -z
...@@ -2739,7 +2739,9 @@ function main() { ...@@ -2739,7 +2739,9 @@ function main() {
test_fluid_lib test_fluid_lib
;; ;;
build_inference_lib) build_inference_lib)
python ${PADDLE_ROOT}/tools/remove_grad_op_and_kernel.py if [ "${WITH_PYTHON}" == "OFF" ] ; then
python ${PADDLE_ROOT}/tools/remove_grad_op_and_kernel.py
fi
cmake_gen ${PYTHON_ABI:-""} cmake_gen ${PYTHON_ABI:-""}
gen_fluid_lib ${parallel_number} gen_fluid_lib ${parallel_number}
;; ;;
...@@ -2790,7 +2792,9 @@ function main() { ...@@ -2790,7 +2792,9 @@ function main() {
;; ;;
test_inference) test_inference)
PADDLE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../../" && pwd )" PADDLE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../../" && pwd )"
python ${PADDLE_ROOT}/tools/remove_grad_op_and_kernel.py if [ "${WITH_PYTHON}" == "OFF" ] ; then
python ${PADDLE_ROOT}/tools/remove_grad_op_and_kernel.py
fi
gen_fluid_lib ${parallel_number} gen_fluid_lib ${parallel_number}
test_fluid_lib test_fluid_lib
#test_fluid_lib_train #test_fluid_lib_train
...@@ -2800,7 +2804,9 @@ function main() { ...@@ -2800,7 +2804,9 @@ function main() {
;; ;;
build_inference) build_inference)
PADDLE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../../" && pwd )" PADDLE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../../" && pwd )"
python ${PADDLE_ROOT}/tools/remove_grad_op_and_kernel.py if [ "${WITH_PYTHON}" == "OFF" ] ; then
python ${PADDLE_ROOT}/tools/remove_grad_op_and_kernel.py
fi
gen_fluid_lib ${parallel_number} gen_fluid_lib ${parallel_number}
;; ;;
gpu_inference) gpu_inference)
......
...@@ -116,7 +116,7 @@ foreach(TEST_OP ${MIXED_DIST_TEST_OPS}) ...@@ -116,7 +116,7 @@ foreach(TEST_OP ${MIXED_DIST_TEST_OPS})
list(REMOVE_ITEM TEST_OPS ${TEST_OP}) list(REMOVE_ITEM TEST_OPS ${TEST_OP})
endforeach() endforeach()
if(ON_INFER) if(NOT WITH_PYTHON AND ON_INFER)
LIST(REMOVE_ITEM TEST_OPS test_eager_trace_op) LIST(REMOVE_ITEM TEST_OPS test_eager_trace_op)
endif() endif()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册