From 8e552399de8de2d554a45727844e2e19154697d3 Mon Sep 17 00:00:00 2001 From: guopeian Date: Tue, 23 Sep 2025 14:40:40 +0800 Subject: [PATCH] fix h2h --- tf_adapter_2.x/npu_device/core/npu_device.cpp | 2 +- tf_adapter_2.x/tests/stub/include/ge/ge_api.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tf_adapter_2.x/npu_device/core/npu_device.cpp b/tf_adapter_2.x/npu_device/core/npu_device.cpp index ca7c5e425..be0a990e9 100644 --- a/tf_adapter_2.x/npu_device/core/npu_device.cpp +++ b/tf_adapter_2.x/npu_device/core/npu_device.cpp @@ -936,7 +936,7 @@ void NpuDevice::TransTfInputs2GeInputs(int num_inputs, TFE_TensorHandle **inputs dims.emplace_back(dim_size); } input.SetTensorDesc(ge::TensorDesc(ge::Shape(dims), ge::FORMAT_ND, ge_type)); - input.SetData(static_cast(tensor->data()), tensor->TotalBytes()); + input.SetData(static_cast(tensor->data()), tensor->TotalBytes(), [](uint8_t *) {}); ge_inputs.emplace_back(input); DLOG() << " input " << i << " ge enum " << ge_type << " tf type " << tensorflow::DataTypeString(tensor->dtype()) << VecToString(dims); diff --git a/tf_adapter_2.x/tests/stub/include/ge/ge_api.h b/tf_adapter_2.x/tests/stub/include/ge/ge_api.h index 79347a942..23a37692d 100644 --- a/tf_adapter_2.x/tests/stub/include/ge/ge_api.h +++ b/tf_adapter_2.x/tests/stub/include/ge/ge_api.h @@ -93,6 +93,13 @@ class Tensor { return GRAPH_SUCCESS; } + graphStatus SetData(uint8_t *data, size_t size, const Tensor::DeleteFunc &deleter_func) { + data_ = std::unique_ptr(new uint8_t[2], deleter_func); + data_.reset(data); + size_ = size; + return GRAPH_SUCCESS; + } + private: TensorDesc desc_; std::unique_ptr data_; -- Gitee