!30840 Fix dynamic shape aicpu launch failed.

Merge pull request !30840 from linqingke/compile-aicpu
This commit is contained in:
i-robot 2022-03-08 11:49:03 +00:00 committed by Gitee
commit 40f282fe92
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 16 additions and 6 deletions

View File

@ -343,6 +343,15 @@ void AscendDeviceContext::CreateKernel(const std::vector<CNodePtr> &nodes) const
MS_LOG(INFO) << "Status record: end create kernel.";
}
void AscendDeviceContext::LaunchDeviceLibrary() const {
MS_LOG(INFO) << "Status record: start launch device library.";
auto ret = mindspore::kernel::AicpuOpKernelLoad::GetInstance().LaunchAicpuKernelSo();
if (!ret) {
MS_LOG(EXCEPTION) << "Cust aicpu kernel so load failed.";
}
MS_LOG(INFO) << "Status record: end launch device library.";
}
void AscendDeviceContext::UpdateExecOrder(const KernelGraphPtr &graph) const {
MS_EXCEPTION_IF_NULL(graph);
std::vector<CNodePtr> new_orders;
@ -404,6 +413,7 @@ void AscendDeviceContext::PreprocessBeforeRunGraph(const KernelGraphPtr &graph)
opt::AscendDynamicShapeConvert(graph);
AscendStreamAssign::GetInstance().AssignStream(NOT_NULL(graph));
AssignOutputNopNodeDeviceAddress(graph);
LaunchDeviceLibrary();
} else {
PreprocessBeforeRunSingleOpGraph(graph);
AscendStreamAssign::GetInstance().AssignStream(NOT_NULL(graph));
@ -712,10 +722,7 @@ void AscendDeviceContext::PreprocessBeforeRunSingleOpGraph(const KernelGraphPtr
}
CreateKernel(atomic_nodes);
if (!mindspore::kernel::AicpuOpKernelLoad::GetInstance().LaunchAicpuKernelSo()) {
MS_LOG(EXCEPTION) << "Cust aicpu kernel so load failed.";
}
LaunchDeviceLibrary();
}
void AscendDeviceContext::UpdateDynamicShape(const CNodePtr &kernel) const {}

View File

@ -131,6 +131,9 @@ class AscendDeviceContext : public DeviceContext {
// set rt_context_ to this thread to control device
void BindDeviceToCurrentThread() const;
// Launch device aicpu library
void LaunchDeviceLibrary() const;
private:
// Graph loader interface
void AllocateGraphMemory(const NotNull<KernelGraphPtr> &root_graph) const;

View File

@ -7,8 +7,8 @@ set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/hcc/bin/aarch64-target-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/hcc/bin/aarch64-target-linux-gnu-g++)
if(EXISTS ${CMAKE_C_COMPILER} AND EXISTS ${CMAKE_CXX_COMPILER})
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency_securec_arm.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf_arm.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/dependency_securec_arm.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/protobuf_arm.cmake)
set(AICPU_PROTO_SRC
${CMAKE_CURRENT_SOURCE_DIR}/aicpu_op_proto/aicpu_tensor.proto