Browse Source

static check

tags/v1.3.0
chenyemeng 3 years ago
parent
commit
7e6299fdab
2 changed files with 20 additions and 1 deletions
  1. +2
    -1
      ge/graph/load/model_manager/model_utils.cc
  2. +18
    -0
      tests/ut/ge/graph/load/model_utils_unittest.cc

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

@@ -384,7 +384,8 @@ Status ModelUtils::GetVarAddr(const RuntimeParam &model_param, const ConstOpDesc
switch (mem_type) {
case RT_MEMORY_RDMA_HBM:
if (offset < 0) {
GELOGE(PARAM_INVALID, "rdma var addr is invalid, addr=%p", reinterpret_cast<uint8_t *>(offset));
GELOGE(PARAM_INVALID, "rdma var addr is invalid, addr=%p",
reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(offset)));
return PARAM_INVALID;
}
var_addr = reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(offset));


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

@@ -67,4 +67,22 @@ TEST_F(UtestModelUtils, get_var_addr_rdma_hbm) {
EXPECT_EQ(reinterpret_cast<uint8_t *>(offset), var_addr);
VarManager::Instance(runtime_param.session_id)->Destory();
}

TEST_F(UtestModelUtils, get_var_addr_rdma_hbm_negative_offset) {
uint8_t test = 2;
uint8_t *pf = &test;
RuntimeParam runtime_param;
runtime_param.session_id = 0;
runtime_param.logic_var_base = 0;
runtime_param.var_base = pf;

int64_t offset = -1;
EXPECT_EQ(VarManager::Instance(runtime_param.session_id)->Init(0, 0, 0, 0), SUCCESS);
EXPECT_NE(VarManager::Instance(runtime_param.session_id)->var_resource_, nullptr);
VarManager::Instance(runtime_param.session_id)->var_resource_->var_offset_map_[offset] = RT_MEMORY_RDMA_HBM;
std::shared_ptr<OpDesc> op_desc = std::make_shared<OpDesc>("test", "test");
uint8_t *var_addr = nullptr;
EXPECT_NE(ModelUtils::GetVarAddr(runtime_param, op_desc, offset, var_addr), SUCCESS);
VarManager::Instance(runtime_param.session_id)->Destory();
}
} // namespace ge

Loading…
Cancel
Save