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

[Custom OP]Remove old custom OP and reduce whl package volume #31813

Merged
merged 3 commits into from
Mar 30, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 1 addition & 36 deletions paddle/fluid/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,46 +360,11 @@ set(FLUID_FRAMEWORK_MODULES proto_desc memory lod_tensor executor data_feed_prot

cc_library(paddle_framework DEPS ${FLUID_FRAMEWORK_MODULES})

# Old custom op extension mechanism related, will be removed in 2.1.0
cc_library(paddle_framework_shared
SHARED SRCS executor.cc operator.cc
${CMAKE_CURRENT_SOURCE_DIR}/c/c_api.cc
${CMAKE_SOURCE_DIR}/paddle/fluid/imperative/layer.cc
DEPS ${FLUID_FRAMEWORK_MODULES})
get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES)
set_target_properties(paddle_framework_shared PROPERTIES OUTPUT_NAME paddle_framework)
target_link_libraries(paddle_framework_shared ${os_dependency_modules})

if (LINUX)
set(FLUID_FRAMEWORK_SHARED_LIB
${PADDLE_BINARY_DIR}/paddle/fluid/framework/libpaddle_framework.so
CACHE INTERNAL "Fluid framework lib")
endif()

if (WIN32)
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(paddle_framework_lib_path ${CMAKE_CURRENT_BINARY_DIR})
else()
set(paddle_framework_lib_path ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
endif()
set(FLUID_FRAMEWORK_IMPORT_LIB
${paddle_framework_lib_path}/paddle_framework.lib
CACHE INTERNAL "Fluid framework lib")
set(FLUID_FRAMEWORK_SHARED_LIB
${paddle_framework_lib_path}/paddle_framework.dll
CACHE INTERNAL "Fluid framework dll")
endif()

if(APPLE)
set(FLUID_FRAMEWORK_SHARED_LIB
${PADDLE_BINARY_DIR}/paddle/fluid/framework/libpaddle_framework.dylib
CACHE INTERNAL "Fluid framework lib")
endif()
if(WITH_TESTING AND TEST selected_rows_test)
set_tests_properties(selected_rows_test PROPERTIES TIMEOUT 120)
endif()

# New custom op extension mechanism related
##### 2.0 New custom op extension mechanism related #####

# if not deps `layer`, will cause: undefined symbol: _ZN6paddle10imperative7VarBase9name_set_
set(PADDLE_CUSTOM_OP_MODULES custom_tensor op_meta_info custom_operator layer)
Expand Down
53 changes: 0 additions & 53 deletions paddle/fluid/framework/c/c_api.cc

This file was deleted.

55 changes: 0 additions & 55 deletions paddle/fluid/framework/c/c_api.h

This file was deleted.

120 changes: 0 additions & 120 deletions paddle/fluid/framework/load_op_lib.h

This file was deleted.

2 changes: 0 additions & 2 deletions paddle/fluid/pybind/pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ limitations under the License. */
#include "paddle/fluid/framework/io/fs.h"
#include "paddle/fluid/framework/ir/coalesce_grad_tensor_pass.h"
#include "paddle/fluid/framework/ir/pass_builder.h"
#include "paddle/fluid/framework/load_op_lib.h"
#include "paddle/fluid/framework/lod_rank_table.h"
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/lod_tensor_array.h"
Expand Down Expand Up @@ -1753,7 +1752,6 @@ All parameter, weight, gradient are variables in Paddle.

m.def("init_gflags", framework::InitGflags);
m.def("init_glog", framework::InitGLOG);
m.def("load_op_library", framework::LoadOpLib);
m.def("load_op_meta_info_and_register_op",
framework::LoadOpMetaInfoAndRegisterOp);
m.def("init_devices", []() { framework::InitDevices(); });
Expand Down
28 changes: 0 additions & 28 deletions python/paddle/fluid/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
'is_compiled_with_cuda',
'is_compiled_with_xpu',
'Variable',
'load_op_library',
'require_version',
'device_guard',
'set_flags',
Expand Down Expand Up @@ -5757,33 +5756,6 @@ def _dygraph_place_guard(place):
_set_dygraph_tracer_expected_place(tmp_place)


def load_op_library(lib_filename):
"""
:api_attr: Static Graph

Load a dynamic library, including custom operators and kernels.
When library is loaded, ops and kernels registered in the library
will be available in PaddlePaddle main process.
Please note, the type of custom operators can't have the same type
with the existing operators in the framework.

Args:
lib_filename (str): name of dynamic library.

Returns:
list[str]: new registered custom op names.

Examples:
.. code-block:: python

import paddle.fluid as fluid
#fluid.load_op_library('custom_op.so')

"""
core.load_op_library(lib_filename)
return OpProtoHolder.instance().update_op_proto()


def switch_device(device):
global _current_device
pre_device = _current_device
Expand Down
3 changes: 2 additions & 1 deletion python/paddle/fluid/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ endforeach()
add_subdirectory(unittests)
add_subdirectory(book)

# TODO: support New Custom OP on Mac
# 2.0 New custom OP can support Windows/Linux now
# TODO: support 2.0 New Custom OP on Mac
if(NOT APPLE)
add_subdirectory(custom_op)
endif()
Expand Down
Loading