From 521bba9c1b5acaeae49c5671fecfdb6ca131300b Mon Sep 17 00:00:00 2001 From: JingZhuangzhuang <75348594+JZZ-NOTE@users.noreply.github.com> Date: Wed, 15 Mar 2023 15:05:54 +0800 Subject: [PATCH] modify cmake rules temporarily (#51644) --- paddle/fluid/inference/CMakeLists.txt | 2 ++ .../fluid/platform/device/gpu/CMakeLists.txt | 8 ++++- tools/get_op_list.py | 30 +++++++++++++------ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/inference/CMakeLists.txt b/paddle/fluid/inference/CMakeLists.txt index de23d3e477e..b5e8450f35f 100644 --- a/paddle/fluid/inference/CMakeLists.txt +++ b/paddle/fluid/inference/CMakeLists.txt @@ -109,6 +109,8 @@ set(SHARED_INFERENCE_SRCS ${PADDLE_CUSTOM_OP_SRCS}) # shared inference library deps +list(REMOVE_ITEM fluid_modules standalone_executor + interpretercore_garbage_collector) set(SHARED_INFERENCE_DEPS ${fluid_modules} phi analysis_predictor ${utils_modules}) diff --git a/paddle/fluid/platform/device/gpu/CMakeLists.txt b/paddle/fluid/platform/device/gpu/CMakeLists.txt index dd2a7d1eb88..a6f6bc232e6 100644 --- a/paddle/fluid/platform/device/gpu/CMakeLists.txt +++ b/paddle/fluid/platform/device/gpu/CMakeLists.txt @@ -3,7 +3,13 @@ if(WITH_GPU) nv_library( gpu_info SRCS gpu_info.cc - DEPS phi_backends gflags glog enforce monitor dynload_cuda) + DEPS phi_backends + gflags + glog + enforce + monitor + dynload_cuda + malloc) nv_test(cuda_helper_test SRCS cuda_helper_test.cu) nv_test( diff --git a/tools/get_op_list.py b/tools/get_op_list.py index aa1fd4dbfb3..8d71af4a6e7 100644 --- a/tools/get_op_list.py +++ b/tools/get_op_list.py @@ -30,15 +30,20 @@ def parse_args(): '--model_dir', type=str, default="", - help='Directory of the inference models.', + help='Directory of the inference models that named with pdmodel.', + ) + parser.add_argument( + '--op_list', + type=str, + default="", + help='List of ops like "conv2d;pool2d;relu".', ) return parser.parse_args() -def get_model_ops(model_file): +def get_model_ops(model_file, ops_set): model_bytes = paddle.static.load_from_file(model_file) pg = paddle.static.deserialize_program(model_bytes) - ops_set = set() for i in range(0, pg.desc.num_blocks()): block = pg.desc.block(i) @@ -47,12 +52,12 @@ def get_model_ops(model_file): for j in range(0, size): ops_set.add(block.op(j).type()) - return ops_set - def get_model_phi_kernels(ops_set): phi_set = set() for op in ops_set: + print(op) + print(_get_phi_kernel_name(op)) phi_set.add(_get_phi_kernel_name(op)) return phi_set @@ -60,10 +65,17 @@ def get_model_phi_kernels(ops_set): if __name__ == '__main__': args = parse_args() - for root, dirs, files in os.walk(args.model_dir, topdown=True): - for name in files: - if re.match(r'.*pdmodel', name): - ops_set = get_model_ops(os.path.join(root, name)) + ops_set = set() + if args.op_list != "": + op_list = args.op_list.split(";") + for op in op_list: + ops_set.add(op) + + if args.model_dir != "": + for root, dirs, files in os.walk(args.model_dir, topdown=True): + for name in files: + if re.match(r'.*pdmodel', name): + get_model_ops(os.path.join(root, name), ops_set) phi_set = get_model_phi_kernels(ops_set) ops = ";".join(ops_set) kernels = ";".join(phi_set) -- GitLab