提交 b4ec6c3b 编写于 作者: Y yanghongtian

fixed linking ascend library

上级 9bae4c5a
......@@ -32,37 +32,25 @@ endif()
include_directories("${ACL_INC}")
# find ascendcl library
find_library(ACL_LIB_FILE NAMES ascendcl PATHS ${ASCEND_HOME}/acllib/lib64)
if(NOT ACL_LIB_FILE)
message(FATAL_ERROR "Can not find ACL Library in ${ASCEND_HOME}/acllib/lib64")
else()
message(STATUS "Found ACL Library: ${ACL_LIB_FILE}")
add_library(acl_lib SHARED IMPORTED GLOBAL)
set_property(TARGET acl_lib PROPERTY IMPORTED_LOCATION ${ACL_LIB_FILE})
endif()
set(ACL_LIB_FILES
acl_dvpp
ascendcl
register
runtime
)
# find register library
find_library(REG_LIB_FILE NAMES register PATHS ${ASCEND_HOME}/acllib/lib64)
if(NOT REG_LIB_FILE)
message(FATAL_ERROR "Can not find REG Library in ${ASCEND_HOME}/acllib/lib64")
else()
message(STATUS "Found REG Library: ${REG_LIB_FILE}")
add_library(register_lib SHARED IMPORTED GLOBAL)
set_property(TARGET register_lib PROPERTY IMPORTED_LOCATION ${REG_LIB_FILE})
endif()
foreach (libname ${ACL_LIB_FILES})
find_library(lib_name_path_${libname} NAMES ${libname} PATHS ${ASCEND_HOME}/acllib/lib64)
if (lib_name_path_${libname})
add_library(acl_${libname} SHARED IMPORTED GLOBAL)
set_property(TARGET acl_${libname} PROPERTY IMPORTED_LOCATION ${lib_name_path_${libname}})
list(APPEND acl_libs acl_${libname})
else()
message(FATAL_ERROR "can not find library: ${libname}")
endif()
endforeach()
find_library(RT_LIB_FILE NAMES runtime PATHS ${ASCEND_HOME}/acllib/lib64)
if(NOT RT_LIB_FILE)
message(FATAL_ERROR "Can not find RT Library in ${ASCEND_HOME}/acllib/lib64")
else()
message(STATUS "Found RT Library: ${RT_LIB_FILE}")
add_library(runtime_lib SHARED IMPORTED GLOBAL)
set_property(TARGET runtime_lib PROPERTY IMPORTED_LOCATION ${RT_LIB_FILE})
endif()
set(hw_ascend_npu_runtime_libs acl_lib register_lib runtime_lib CACHE INTERNAL "ascend runtime libs")
set(hw_ascend_npu_runtime_libs ${acl_libs} CACHE INTERNAL "ascend runtime libs")
# find atc include folder and library
find_path(ATC_INC NAMES ge/ge_ir_build.h
......@@ -72,14 +60,49 @@ if (NOT ATC_INC)
endif()
include_directories("${ATC_INC}")
find_library(GRAPH_LIB_FILE graph PATHS ${ASCEND_HOME}/atc/lib64)
if (NOT GRAPH_LIB_FILE)
message(FATAL_ERROR "Can not find libgraph.so library in ${ASCEND_HOME}/atc/lib64")
else()
message(STATUS "Found Graph Library: ${GRAPH_LIB_FILE}")
add_library(graph_lib SHARED IMPORTED GLOBAL)
set_property(TARGET graph_lib PROPERTY IMPORTED_LOCATION ${GRAPH_LIB_FILE})
endif()
set(ATC_LIB_FILES
_caffe_parser
auto_tiling
c_sec
cce
cce_aicore
cce_aicpudev_online
cce_tools
drvdevdrv
drvdevmm
drvdsmi_host
drvhdc_host
fmk_caffe_parser
fmk_tensorflow_parser
ge_client
ge_common
ge_compiler
ge_executor
graph
mmpa
msprof
parser_common
register
resource
runtime
slog
te_fusion
tiling
tvm
tvm_runtime
tvm_topi
)
foreach (libname ${ATC_LIB_FILES})
find_library(lib_name_path_${libname} NAMES ${libname} PATHS ${ASCEND_HOME}/atc/lib64)
if (lib_name_path_${libname})
add_library(atc_${libname} SHARED IMPORTED GLOBAL)
set_property(TARGET atc_${libname} PROPERTY IMPORTED_LOCATION ${lib_name_path_${libname}})
list(APPEND atc_libs atc_${libname})
else()
message(FATAL_ERROR "can not find library: ${libname}")
endif()
endforeach()
# find opp include folder and library
find_path(OPP_INC NAMES all_ops.h
......@@ -89,14 +112,37 @@ if (NOT OPP_INC)
endif()
include_directories("${OPP_INC}")
find_library(OPP_LIB_FILE opsproto PATHS ${ASCEND_HOME}/opp/op_proto/built-in)
if (NOT OPP_LIB_FILE)
find_library(OPP_OPSPROTO_LIB_FILE opsproto PATHS ${ASCEND_HOME}/opp/op_proto/built-in)
if (NOT OPP_OPSPROTO_LIB_FILE)
message(FATAL_ERROR "Can not find libopsproto.so in ${ASCEND_HOME}/opp/op_proto/built-in")
else()
message(STATUS "Found OPP Library: ${OPP_LIB_FILE}")
add_library(opp_lib SHARED IMPORTED GLOBAL)
set_property(TARGET opp_lib PROPERTY IMPORTED_LOCATION ${OPP_LIB_FILE})
message(STATUS "Found OPP proto Library: ${OPP_OPSPROTO_LIB_FILE}")
add_library(opp_opsproto_lib SHARED IMPORTED GLOBAL)
set_property(TARGET opp_opsproto_lib PROPERTY IMPORTED_LOCATION ${OPP_OPSPROTO_LIB_FILE})
endif()
find_library(OPP_FUSION_AICORE ops_fusion_pass_aicore PATHS ${ASCEND_HOME}/opp/fusion_pass/built_in/)
if (NOT OPP_FUSION_AICORE)
message(FATAL_ERROR "Can not find libops_fusion_pass_aicore.so in ${ASCEND_HOME}/opp/fusion_pass/built_in/")
else()
message(STATUS "Found fusion_pass_aicore Library: ${OPP_FUSION_AICORE}")
add_library(opp_fusion_pass_aicore_lib SHARED IMPORTED GLOBAL)
set_property(TARGET opp_fusion_pass_aicore_lib PROPERTY IMPORTED_LOCATION ${OPP_FUSION_AICORE})
endif()
find_library(OPP_FUSION_VECTORCORE ops_fusion_pass_vectorcore PATHS ${ASCEND_HOME}/opp/fusion_pass/built_in/vector_core)
if (NOT OPP_FUSION_VECTORCORE)
message(FATAL_ERROR "Can not find libops_fusion_pass_vectorcore.so in ${ASCEND_HOME}/opp/fusion_pass/built_in/vector_core")
else()
message(STATUS "Found fusion_pass_vectorcore Library: ${OPP_FUSION_VECTORCORE}")
add_library(opp_fusion_pass_vectorcore_lib SHARED IMPORTED GLOBAL)
set_property(TARGET opp_fusion_pass_vectorcore_lib PROPERTY IMPORTED_LOCATION ${OPP_FUSION_VECTORCORE})
endif()
set(hw_ascend_npu_builder_libs graph_lib opp_lib CACHE INTERNAL "ascend builder libs")
set(hw_ascend_npu_builder_libs
${atc_libs}
opp_opsproto_lib
opp_fusion_pass_aicore_lib
opp_fusion_pass_vectorcore_lib
CACHE INTERNAL "ascend builder libs")
if(NOT LITE_WITH_HW_ASCEND_NPU)
return()
endif()
lite_cc_library(runtime_hw_ascend_npu SRCS runtime.cc DEPS
${hw_ascend_npu_builder_libs}
${hw_ascend_npu_runtime_libs})
lite_cc_library(target_wrapper_hw_ascend_npu SRCS target_wrapper.cc DEPS
${hw_ascend_npu_builder_libs}
${hw_ascend_npu_runtime_libs})
lite_cc_library(runtime_hw_ascend_npu SRCS runtime.cc DEPS
${hw_ascend_npu_runtime_libs}
target_wrapper_hw_ascend_npu)
lite_cc_library(device_hw_ascend_npu SRCS device.cc DEPS
${hw_ascend_npu_builder_libs}
${hw_ascend_npu_runtime_libs}
target_wrapper_hw_ascend_npu
runtime_hw_ascend_npu)
......@@ -6,5 +6,18 @@ endif()
lite_cc_library(arena_framework SRCS framework.cc DEPS program gtest)
if((NOT LITE_WITH_OPENCL) AND (LITE_WITH_X86 OR LITE_WITH_ARM))
lite_cc_test(test_arena_framework SRCS framework_test.cc DEPS arena_framework ${mlu_kernels} ${bm_kernels} ${npu_kernels} ${xpu_kernels} ${x86_kernels} ${cuda_kernels} ${fpga_kernels} ${arm_kernels} ${lite_ops} ${host_kernels})
lite_cc_test(test_arena_framework SRCS framework_test.cc DEPS
arena_framework
${mlu_kernels}
${bm_kernels}
${npu_kernels}
${xpu_kernels}
${x86_kernels}
${cuda_kernels}
${fpga_kernels}
${arm_kernels}
${lite_ops}
${host_kernels}
${hw_ascend_npu_kernels}
)
endif()
......@@ -22,7 +22,8 @@ namespace arena {
void TestCase::CreateInstruction() {
std::shared_ptr<lite::OpLite> op = nullptr;
if (place_.target == TARGET(kNPU) || place_.target == TARGET(kXPU)) {
if (place_.target == TARGET(kNPU) || place_.target == TARGET(kXPU) ||
place_.target == TARGET(kHWAscendNPU)) {
// Create a new block desc to wrap the original op desc
int sub_block_idx = 0;
auto sub_block_desc = new cpp::BlockDesc();
......
add_subdirectory(bridges)
add_kernel(subgraph_compute_hw_ascend_npu HWAscendNPU basic SRCS subgraph_compute.cc DEPS
${lite_kernel_deps} device_hw_ascend_npu subgraph_bridge_engine ${hw_ascend_npu_subgraph_bridges})
add_kernel(subgraph_compute_hw_ascend_npu HW_ASCEND_NPU basic SRCS subgraph_compute.cc DEPS
${lite_kernel_deps}
device_hw_ascend_npu
subgraph_bridge_engine
${hw_ascend_npu_subgraph_bridges}
subgraph_bridge_registry
)
......@@ -2,18 +2,24 @@ if (NOT LITE_WITH_HW_ASCEND_NPU)
return()
endif()
message(STATUS "======compile hw_ascend_npu bridges, ${hw_ascend_npu_builder_libs}")
lite_cc_library(subgraph_bridge_utility_hw_ascend_npu
SRCS utility.cc
DEPS ${hw_ascend_npu_builder_libs} tensor)
lite_cc_library(subgraph_bridge_graph_hw_ascend_npu
SRCS graph.cc
DEPS ${hw_ascend_npu_builder_libs} subgraph_bridge_utility_hw_ascend_npu)
DEPS ${hw_ascend_npu_builder_libs} subgraph_bridge_utility_hw_ascend_npu
)
set(hw_ascend_npu_subgraph_bridge_deps subgraph_bridge_registry subgraph_bridge_utility_hw_ascend_npu subgraph_bridge_graph_hw_ascend_npu)
lite_cc_library(subgraph_bridge_act_op_hw_ascend_npu SRCS act_op.cc DEPS
${hw_ascend_npu_builder_libs}
${hw_ascend_npu_subgraph_bridge_deps})
set(hw_ascend_npu_subgraph_bridges
subgraph_bridge_graph_hw_ascend_npu
subgraph_bridge_registry
subgraph_bridge_utility_hw_ascend_npu
subgraph_bridge_act_op_hw_ascend_npu
CACHE INTERNAL "hw_ascend_npu_subgraph_bridges")
lite_cc_library(subgraph_bridge_act_op_hw_ascend_npu SRCS act_op.cc DEPS ${hw_ascend_npu_subgraph_bridge_deps})
......@@ -138,10 +138,6 @@ REGISTER_SUBGRAPH_BRIDGE(
softplus,
kHWAscendNPU,
paddle::lite::subgraph::hw_ascend_npu::ActConverter<ge::op::Activation>);
REGISTER_SUBGRAPH_BRIDGE(
hard_sigmoid,
kHWAscendNPU,
paddle::lite::subgraph::hw_ascend_npu::ActConverter<ge::op::Activation>);
REGISTER_SUBGRAPH_BRIDGE(
log,
......
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
USE_SUBGRAPH_BRIDGE(sigmoid, kHWAscendNPU);
USE_SUBGRAPH_BRIDGE(relu, kHWAscendNPU);
USE_SUBGRAPH_BRIDGE(tanh, kHWAscendNPU);
/// USE_SUBGRAPH_BRIDGE(relu_clipped, kHWAscendNPU);
USE_SUBGRAPH_BRIDGE(relu6, kHWAscendNPU);
USE_SUBGRAPH_BRIDGE(leaky_relu, kHWAscendNPU);
USE_SUBGRAPH_BRIDGE(softsign, kHWAscendNPU);
/// USE_SUBGRAPH_BRIDGE(hard_sigmoid, kHWAscendNPU);
USE_SUBGRAPH_BRIDGE(log, kHWAscendNPU);
USE_SUBGRAPH_BRIDGE(sqrt, kHWAscendNPU);
USE_SUBGRAPH_BRIDGE(square, kHWAscendNPU);
// USE_SUBGRAPH_BRIDGE(batch_norm, kNPU);
// USE_SUBGRAPH_BRIDGE(less_than, kNPU);
// USE_SUBGRAPH_BRIDGE(concat, kNPU);
// USE_SUBGRAPH_BRIDGE(conv2d, kNPU);
// USE_SUBGRAPH_BRIDGE(depthwise_conv2d, kNPU);
// USE_SUBGRAPH_BRIDGE(conv2d_transpose, kNPU);
//
// USE_SUBGRAPH_BRIDGE(dropout, kNPU);
// USE_SUBGRAPH_BRIDGE(elementwise_add, kNPU);
// USE_SUBGRAPH_BRIDGE(elementwise_sub, kNPU);
// USE_SUBGRAPH_BRIDGE(elementwise_mul, kNPU);
// USE_SUBGRAPH_BRIDGE(elementwise_div, kNPU);
// USE_SUBGRAPH_BRIDGE(fusion_elementwise_add_activation, kNPU);
// USE_SUBGRAPH_BRIDGE(fusion_elementwise_sub_activation, kNPU);
// USE_SUBGRAPH_BRIDGE(fusion_elementwise_mul_activation, kNPU);
// USE_SUBGRAPH_BRIDGE(fusion_elementwise_div_activation, kNPU);
// USE_SUBGRAPH_BRIDGE(fill_constant, kNPU)
// USE_SUBGRAPH_BRIDGE(fill_constant_batch_size_like, kNPU)
//
// USE_SUBGRAPH_BRIDGE(increment, kNPU);
// USE_SUBGRAPH_BRIDGE(instance_norm, kNPU);
// USE_SUBGRAPH_BRIDGE(fc, kNPU);
// USE_SUBGRAPH_BRIDGE(bilinear_interp, kNPU);
// USE_SUBGRAPH_BRIDGE(nearest_interp, kNPU);
// USE_SUBGRAPH_BRIDGE(layer_norm, kNPU);
// USE_SUBGRAPH_BRIDGE(matmul, kNPU);
// USE_SUBGRAPH_BRIDGE(mul, kNPU);
// USE_SUBGRAPH_BRIDGE(pad2d, kNPU);
// USE_SUBGRAPH_BRIDGE(pool2d, kNPU);
// USE_SUBGRAPH_BRIDGE(reduce_mean, kNPU);
// USE_SUBGRAPH_BRIDGE(reshape, kNPU);
// USE_SUBGRAPH_BRIDGE(reshape2, kNPU);
// USE_SUBGRAPH_BRIDGE(scale, kNPU);
// USE_SUBGRAPH_BRIDGE(shuffle_channel, kNPU);
// USE_SUBGRAPH_BRIDGE(softmax, kNPU);
// USE_SUBGRAPH_BRIDGE(split, kNPU);
//// USE_SUBGRAPH_BRIDGE(top_k, kNPU);
// USE_SUBGRAPH_BRIDGE(transpose, kNPU);
// USE_SUBGRAPH_BRIDGE(transpose2, kNPU);
// USE_SUBGRAPH_BRIDGE(unsqueeze, kNPU);
// USE_SUBGRAPH_BRIDGE(unsqueeze2, kNPU);
......@@ -82,8 +82,8 @@ ge::Format CvtDataLayoutType(DataLayoutType itype) {
break;
// TODO(yanghongtian): support more data layout type
default:
LOG(FATAL) << "[HW_ASCEND_NPU] Can not convert data layout type("
<< DataLayoutToStr(itype) << ") from Lite to HW_ASCEND_NPU";
LOG(FATAL) << "[HWAscendNPU] Can not convert data layout type("
<< DataLayoutToStr(itype) << ") from Lite to HWAscendNPU";
break;
}
return otype;
......@@ -91,7 +91,7 @@ ge::Format CvtDataLayoutType(DataLayoutType itype) {
std::vector<int64_t> CvtShape(const std::vector<int64_t>& in_shape) {
CHECK(in_shape.size() <= 4 && in_shape.size() > 0)
<< "[HW_ASCEND_NPU] The size of in_shape is invalid: " << in_shape.size();
<< "[HWAscendNPU] The size of in_shape is invalid: " << in_shape.size();
// Padding the shape to 4-dimensions(NCHW)
std::vector<int64_t> out_shape(4, 1);
std::copy(in_shape.begin(),
......@@ -152,7 +152,7 @@ int CvtActMode(const std::string& act_type) {
act_mode = 9;
} else {
// TODO(yanghongtian): support more activation mode
LOG(FATAL) << "[NPU] Unsupported activation type " << act_type;
LOG(FATAL) << "[HWAscendNPU] Unsupported activation type " << act_type;
}
return act_mode;
}
......
......@@ -19,7 +19,7 @@
#include "lite/backends/hw_ascend_npu/device.h"
#include "lite/core/op_registry.h"
#include "lite/kernels/hw_ascend_npu/bridges/graph.h"
#include "lite/kernels/npu/bridges/paddle_use_bridges.h"
#include "lite/kernels/hw_ascend_npu/bridges/paddle_use_bridges.h"
namespace paddle {
namespace lite {
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册