fix dynamic shape aicpu launch failed.

This commit is contained in:
linqingke 2022-03-04 16:43:15 +08:00
parent 70b5de7a71
commit 42005bd5df
5 changed files with 16 additions and 6 deletions

View File

@ -342,6 +342,15 @@ void AscendDeviceContext::CreateKernel(const std::vector<CNodePtr> &nodes) const
MS_LOG(INFO) << "Status record: end create kernel."; 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 { void AscendDeviceContext::UpdateExecOrder(const KernelGraphPtr &graph) const {
MS_EXCEPTION_IF_NULL(graph); MS_EXCEPTION_IF_NULL(graph);
std::vector<CNodePtr> new_orders; std::vector<CNodePtr> new_orders;
@ -403,6 +412,7 @@ void AscendDeviceContext::PreprocessBeforeRunGraph(const KernelGraphPtr &graph)
opt::AscendDynamicShapeConvert(graph); opt::AscendDynamicShapeConvert(graph);
AscendStreamAssign::GetInstance().AssignStream(NOT_NULL(graph)); AscendStreamAssign::GetInstance().AssignStream(NOT_NULL(graph));
AssignOutputNopNodeDeviceAddress(graph); AssignOutputNopNodeDeviceAddress(graph);
LaunchDeviceLibrary();
} else { } else {
PreprocessBeforeRunSingleOpGraph(graph); PreprocessBeforeRunSingleOpGraph(graph);
AscendStreamAssign::GetInstance().AssignStream(NOT_NULL(graph)); AscendStreamAssign::GetInstance().AssignStream(NOT_NULL(graph));
@ -711,10 +721,7 @@ void AscendDeviceContext::PreprocessBeforeRunSingleOpGraph(const KernelGraphPtr
} }
CreateKernel(atomic_nodes); CreateKernel(atomic_nodes);
LaunchDeviceLibrary();
if (!mindspore::kernel::AicpuOpKernelLoad::GetInstance().LaunchAicpuKernelSo()) {
MS_LOG(EXCEPTION) << "Cust aicpu kernel so load failed.";
}
} }
void AscendDeviceContext::UpdateDynamicShape(const CNodePtr &kernel) const {} 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 // set rt_context_ to this thread to control device
void BindDeviceToCurrentThread() const; void BindDeviceToCurrentThread() const;
// Launch device aicpu library
void LaunchDeviceLibrary() const;
private: private:
// Graph loader interface // Graph loader interface
void AllocateGraphMemory(const NotNull<KernelGraphPtr> &root_graph) const; 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++) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/hcc/bin/aarch64-target-linux-gnu-g++)
if(EXISTS ${CMAKE_C_COMPILER} AND EXISTS ${CMAKE_CXX_COMPILER}) if(EXISTS ${CMAKE_C_COMPILER} AND EXISTS ${CMAKE_CXX_COMPILER})
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependency_securec_arm.cmake) include(${CMAKE_SOURCE_DIR}/cmake/dependency_securec_arm.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf_arm.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/protobuf_arm.cmake)
set(AICPU_PROTO_SRC set(AICPU_PROTO_SRC
${CMAKE_CURRENT_SOURCE_DIR}/aicpu_op_proto/aicpu_tensor.proto ${CMAKE_CURRENT_SOURCE_DIR}/aicpu_op_proto/aicpu_tensor.proto