Browse Source

UT for LaunchKernelCustAicpuSo

tags/v1.5.1
zhangxiaokun 3 years ago
parent
commit
a55b872fc5
2 changed files with 21 additions and 1 deletions
  1. +3
    -1
      ge/graph/load/model_manager/model_manager.cc
  2. +18
    -0
      tests/ut/ge/graph/load/model_manager_unittest.cc

+ 3
- 1
ge/graph/load/model_manager/model_manager.cc View File

@@ -1378,7 +1378,9 @@ Status ModelManager::LoadCustAicpuSo(const OpDescPtr &op_desc, const string &so_
Status ModelManager::LaunchKernelCustAicpuSo(const string &kernel_name) { Status ModelManager::LaunchKernelCustAicpuSo(const string &kernel_name) {
GELOGD("Aicpu kernel launch task in, kernel name %s.", kernel_name.c_str()); GELOGD("Aicpu kernel launch task in, kernel name %s.", kernel_name.c_str());
std::lock_guard<std::mutex> lock(cust_aicpu_mutex_); std::lock_guard<std::mutex> lock(cust_aicpu_mutex_);
if (cust_aicpu_so_.size() == 0) return SUCCESS;
if (cust_aicpu_so_.empty()) {
return SUCCESS;
}
// get current context // get current context
rtContext_t rt_cur_ctx = nullptr; rtContext_t rt_cur_ctx = nullptr;
auto rt_error = rtCtxGetCurrent(&rt_cur_ctx); auto rt_error = rtCtxGetCurrent(&rt_cur_ctx);


+ 18
- 0
tests/ut/ge/graph/load/model_manager_unittest.cc View File

@@ -438,4 +438,22 @@ TEST_F(UtestModelManagerModelManager, test_data_input_tensor) {
auto ret = mm.DataInputTensor(model_id,inputs); auto ret = mm.DataInputTensor(model_id,inputs);
EXPECT_EQ(PARAM_INVALID, ret); // HybridDavinciModel::impl_ is null. EXPECT_EQ(PARAM_INVALID, ret); // HybridDavinciModel::impl_ is null.
} }

TEST_F(UtestModelManagerModelManager, test_launch_kernel_cust_aicpu) {
ModelManager mm;

// cust_aicpu_so_ is empty.
EXPECT_EQ(mm.LaunchKernelCustAicpuSo("empty_cust_aicpu"), SUCCESS);

// deleteCustOp after Launch will deleted.
uintptr_t resource_id = 1; // for rtCtxGetCurrent stub
std::vector<char> kernel_bin(256);
auto &cust_resource_001 = mm.cust_aicpu_so_[resource_id];
auto tbe_kernel = std::shared_ptr<OpKernelBin>(new OpKernelBin("deleteCustOp", std::move(kernel_bin)));
auto &cust_opkernel_001 = cust_resource_001["deleteCustOp"] = tbe_kernel;

EXPECT_FALSE(mm.cust_aicpu_so_.empty());
EXPECT_EQ(mm.LaunchKernelCustAicpuSo("deleteCustOp"), SUCCESS);
EXPECT_TRUE(mm.cust_aicpu_so_.empty());
}
} // namespace ge } // namespace ge

Loading…
Cancel
Save