Browse Source

add ptr checker

tags/v1.5.1
zhou_chao1993 3 years ago
parent
commit
6ab6ee4c72
4 changed files with 13 additions and 8 deletions
  1. +2
    -1
      ge/hybrid/common/tensor_value.h
  2. +8
    -4
      ge/hybrid/executor/hybrid_model_async_executor.cc
  3. +2
    -2
      ge/hybrid/executor/hybrid_model_async_executor.h
  4. +1
    -1
      tests/ut/ge/hybrid/executor/hybrid_model_async_executor_unittest.cc

+ 2
- 1
ge/hybrid/common/tensor_value.h View File

@@ -95,7 +95,8 @@ class TensorValue {
name_ = name; name_ = name;
} }
MemStorageType GetMemType() const {
Status GetMemType(MemStorageType &mem_type) const {
GE_CHECK_NOTNULL(buffer_);
return buffer_->GetMemType(); return buffer_->GetMemType();
} }




+ 8
- 4
ge/hybrid/executor/hybrid_model_async_executor.cc View File

@@ -458,7 +458,8 @@ Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &a
auto tensor = TensorAdapter::AsTensor(ge_tensor); auto tensor = TensorAdapter::AsTensor(ge_tensor);
outputs.emplace_back(std::move(tensor)); outputs.emplace_back(std::move(tensor));
} else { } else {
BuildDeviceTensor(output_tensor, ge_tensor_desc, output_size, outputs);
GE_CHK_STATUS_RET(BuildDeviceTensor(output_tensor, ge_tensor_desc, output_size, outputs),
"Build device tensor failed");
output_data->blobs.emplace_back(output_tensor.Release(), static_cast<uint32_t>(output_size), false, output_data->blobs.emplace_back(output_tensor.Release(), static_cast<uint32_t>(output_size), false,
static_cast<uint32_t>(kPlacementDevice)); static_cast<uint32_t>(kPlacementDevice));
} }
@@ -478,13 +479,15 @@ Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &a
return SUCCESS; return SUCCESS;
} }


void HybridModelAsyncExecutor::BuildDeviceTensor(TensorValue &output_tensor, GeTensorDesc &ge_tensor_desc,
int64_t output_size, std::vector<ge::Tensor> &outputs) {
Status HybridModelAsyncExecutor::BuildDeviceTensor(TensorValue &output_tensor, GeTensorDesc &ge_tensor_desc,
int64_t output_size, std::vector<ge::Tensor> &outputs) {
GELOGD("Start to build device tensor"); GELOGD("Start to build device tensor");
auto mem_type = output_tensor.GetMemType();
MemStorageType mem_type = HBM;
GE_CHK_STATUS_RET(output_tensor.GetMemType(mem_type), "[Build][DeviceTensor] Get mem type failed");
GELOGD("Mem type is %d", static_cast<uint32_t>(mem_type)); GELOGD("Mem type is %d", static_cast<uint32_t>(mem_type));
auto deleter = [=](uint8_t *device_data) { auto deleter = [=](uint8_t *device_data) {
if (device_data != nullptr) { if (device_data != nullptr) {
GELOGD("Free device addr is %p", device_data);
if (mem_type == RDMA_HBM) { if (mem_type == RDMA_HBM) {
MemManager::Instance().RdmaPoolInstance(RT_MEMORY_HBM).Free(device_data, device_id_); MemManager::Instance().RdmaPoolInstance(RT_MEMORY_HBM).Free(device_data, device_id_);
} else if (mem_type == HOST_DDR) { } else if (mem_type == HOST_DDR) {
@@ -499,6 +502,7 @@ void HybridModelAsyncExecutor::BuildDeviceTensor(TensorValue &output_tensor, GeT
auto tensor = TensorAdapter::AsTensor(ge_tensor); auto tensor = TensorAdapter::AsTensor(ge_tensor);
tensor.SetData(reinterpret_cast<uint8_t *>(output_tensor.Release()), static_cast<size_t>(output_size), deleter); tensor.SetData(reinterpret_cast<uint8_t *>(output_tensor.Release()), static_cast<size_t>(output_size), deleter);
outputs.emplace_back(std::move(tensor)); outputs.emplace_back(std::move(tensor));
return SUCCESS;
} }


Status HybridModelAsyncExecutor::Execute(const std::vector<DataBuffer> &inputs, Status HybridModelAsyncExecutor::Execute(const std::vector<DataBuffer> &inputs,


+ 2
- 2
ge/hybrid/executor/hybrid_model_async_executor.h View File

@@ -76,8 +76,8 @@ class HybridModelAsyncExecutor {
OutputData *output_data); OutputData *output_data);


Status CopyOutputs(HybridModelExecutor::ExecuteArgs &args, OutputData *output_data, std::vector<ge::Tensor> &outputs); Status CopyOutputs(HybridModelExecutor::ExecuteArgs &args, OutputData *output_data, std::vector<ge::Tensor> &outputs);
void BuildDeviceTensor(TensorValue &output_tensor, GeTensorDesc &ge_tensor_desc, int64_t output_size,
std::vector<ge::Tensor> &outputs);
Status BuildDeviceTensor(TensorValue &output_tensor, GeTensorDesc &ge_tensor_desc, int64_t output_size,
std::vector<ge::Tensor> &outputs);


Status OnComputeDone(uint32_t data_index, uint32_t result_code, std::vector<ge::Tensor> &outputs); Status OnComputeDone(uint32_t data_index, uint32_t result_code, std::vector<ge::Tensor> &outputs);




+ 1
- 1
tests/ut/ge/hybrid/executor/hybrid_model_async_executor_unittest.cc View File

@@ -82,7 +82,7 @@ TEST_F(UtestHybridModelAsyncExecutor, BuildDeviceTensor) {
GeTensorDesc ge_tensor_desc; GeTensorDesc ge_tensor_desc;
int64_t output_size = 100; int64_t output_size = 100;
std::vector<ge::Tensor> outputs; std::vector<ge::Tensor> outputs;
executor.BuildDeviceTensor(tensor, ge_tensor_desc, output_size, outputs);
auto ret = executor.BuildDeviceTensor(tensor, ge_tensor_desc, output_size, outputs);
auto size = tensor.GetSize(); auto size = tensor.GetSize();
ASSERT_EQ(size, 100); ASSERT_EQ(size, 100);
} }


Loading…
Cancel
Save