Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Autogen Phi Operants & Prim-Relevant] Autogen phi tensor operants, operants_base, operants_manager #50582

Merged
merged 7 commits into from Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -9,14 +9,19 @@ paddle/fluid/operators/ops_extra_info.cc
paddle/phi/api/backward/backward_api.h
paddle/phi/api/backward/sparse_bw_api.h
paddle/phi/api/include/api.h
paddle/phi/api/include/operants_base.h
paddle/phi/api/include/operants_manager.h
paddle/phi/api/include/sparse_api.h
paddle/phi/api/include/strings_api.h
paddle/phi/api/include/tensor_operants.h
paddle/phi/api/lib/api.cc
paddle/phi/api/lib/dygraph_api.*
paddle/phi/api/lib/backward_api.cc
paddle/phi/api/lib/operants_manager.cc
paddle/phi/api/lib/sparse_api.cc
paddle/phi/api/lib/strings_api.cc
paddle/phi/api/lib/sparse_bw_api.cc
paddle/phi/api/lib/tensor_operants.cc
paddle/phi/extension.h
paddle/phi/include/*
paddle/phi/infermeta/generated.*
Expand Down
39 changes: 0 additions & 39 deletions paddle/phi/api/include/operants_base.h

This file was deleted.

81 changes: 0 additions & 81 deletions paddle/phi/api/include/operants_manager.h

This file was deleted.

42 changes: 0 additions & 42 deletions paddle/phi/api/include/tensor_operants.h

This file was deleted.

56 changes: 54 additions & 2 deletions paddle/phi/api/lib/CMakeLists.txt
Expand Up @@ -97,6 +97,26 @@ set(wrapped_infermeta_header_file
set(wrapped_infermeta_source_file
${CMAKE_SOURCE_DIR}/paddle/phi/infermeta/generated.cc)

# tensor and tensor operants file
set(tensor_gen_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/yaml/generator/tensor_gen.py)
set(api_prim_yaml_file ${CMAKE_SOURCE_DIR}/paddle/fluid/prim/api/api.yaml)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set(operants_base_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/include/operants_base.h)
set(phi_tensor_operants_header_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/include/tensor_operants.h)
set(phi_tensor_operants_source_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/lib/tensor_operants.cc)
set(operants_manager_header_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/include/operants_manager.h)
set(operants_manager_source_file
${CMAKE_SOURCE_DIR}/paddle/phi/api/lib/operants_manager.cc)
set(operants_base_file_tmp ${operants_base_file}.tmp)
set(phi_tensor_operants_header_file_tmp ${phi_tensor_operants_header_file}.tmp)
set(phi_tensor_operants_source_file_tmp ${phi_tensor_operants_source_file}.tmp)
set(operants_manager_header_file_tmp ${operants_manager_header_file}.tmp)
set(operants_manager_source_file_tmp ${operants_manager_source_file}.tmp)

if(NOT PYTHONINTERP_FOUND)
find_package(PythonInterp REQUIRED)
endif()
Expand Down Expand Up @@ -216,6 +236,38 @@ add_custom_command(
${api_gen_base}
VERBATIM)

# generate tensor and tensor operants file
add_custom_command(
OUTPUT ${operants_base_file} ${phi_tensor_operants_header_file}
${phi_tensor_operants_source_file} ${operants_manager_header_file}
${operants_manager_source_file}
COMMAND ${PYTHON_EXECUTABLE} -m pip install pyyaml
COMMAND
${PYTHON_EXECUTABLE} ${tensor_gen_file} --api_yaml_path ${api_yaml_file}
${legacy_api_yaml_file} --operants_base_path ${operants_base_file_tmp}
--phi_tensor_operants_header_path ${phi_tensor_operants_header_file_tmp}
--phi_tensor_operants_source_path ${phi_tensor_operants_source_file_tmp}
--operants_manager_header_path ${operants_manager_header_file_tmp}
--operants_manager_source_path ${operants_manager_source_file_tmp}
--api_prim_yaml_path ${api_prim_yaml_file}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${operants_base_file_tmp}
${operants_base_file}
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${phi_tensor_operants_header_file_tmp}
${phi_tensor_operants_header_file}
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${phi_tensor_operants_source_file_tmp}
${phi_tensor_operants_source_file}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${operants_manager_header_file_tmp} ${operants_manager_header_file}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${operants_manager_source_file_tmp} ${operants_manager_source_file}
COMMENT
"copy_if_different ${phi_tensor_operants_header_file} ${phi_tensor_operants_source_file}"
DEPENDS ${api_yaml_file} ${legacy_api_yaml_file} ${tensor_gen_file}
${api_gen_base} ${api_gen_file}
VERBATIM)

cc_library(
op_meta_info
SRCS op_meta_info.cc
Expand Down Expand Up @@ -331,9 +383,9 @@ cc_library(

cc_library(
phi_tensor_operants
SRCS tensor_operants.cc
SRCS ${phi_tensor_operants_source_file}
DEPS phi_function_api)
cc_library(
operants_manager
SRCS operants_manager.cc
SRCS ${operants_manager_source_file}
DEPS phi_enforce)