CMakeLists.txt 3.0 KB
Newer Older
1
set(api_yaml_path
2
    "${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/api.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/legacy_api.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_api.yaml"
3 4
)
set(backward_yaml_path
5
    "${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/backward.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/legacy_backward.yaml,${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/sparse_bw_api.yaml"
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
)
set(tmp_forwards_cc_path
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/forwards/tmp_dygraph_functions.cc"
)
set(tmp_forwards_h_path
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/forwards/tmp_dygraph_functions.h"
)
set(tmp_nodes_cc_path
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/backwards/tmp_nodes.cc"
)
set(tmp_nodes_h_path
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/backwards/tmp_nodes.h"
)
set(forwards_cc_path
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/forwards/dygraph_functions.cc"
)
set(forwards_h_path
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/forwards/dygraph_functions.h"
)
set(nodes_cc_path
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/backwards/nodes.cc"
)
set(nodes_h_path
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/api/generated/eager_generated/backwards/nodes.h"
)
31
# StringTensor only needs forward api
32
set(fwd_api_yaml_path
33
    "${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/strings_api.yaml")
34

35
message("Final State Eager CodeGen")
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
add_custom_target(
  eager_final_state_codegen
  COMMAND
    "${PYTHON_EXECUTABLE}"
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/auto_code_generator/final_state_generator/eager_gen.py"
    "--api_yaml_path=${api_yaml_path}"
    "--backward_yaml_path=${backward_yaml_path}"
    "--forwards_cc_path=${tmp_forwards_cc_path}"
    "--forwards_h_path=${tmp_forwards_h_path}"
    "--nodes_cc_path=${tmp_nodes_cc_path}" "--nodes_h_path=${tmp_nodes_h_path}"
  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_forwards_cc_path}
          ${forwards_cc_path}
  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_forwards_h_path}
          ${forwards_h_path}
  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_nodes_cc_path}
          ${nodes_cc_path}
  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_nodes_h_path}
          ${nodes_h_path}
  VERBATIM)
55

56
set(tmp_python_c_output_path
57
    "${PADDLE_SOURCE_DIR}/paddle/fluid/pybind/eager_final_state_op_function.cc.tmp"
58 59
)
set(python_c_output_path
60
    "${PADDLE_SOURCE_DIR}/paddle/fluid/pybind/eager_final_state_op_function.cc")
61 62 63 64 65 66 67 68 69 70 71

add_custom_target(
  eager_final_state_python_c_codegen
  COMMAND
    "${PYTHON_EXECUTABLE}"
    "${PADDLE_SOURCE_DIR}/paddle/fluid/eager/auto_code_generator/final_state_generator/python_c_gen.py"
    "--api_yaml_path=${api_yaml_path},${fwd_api_yaml_path}"
    "--output_path=${tmp_python_c_output_path}"
  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_python_c_output_path}
          ${python_c_output_path}
  VERBATIM)