From f2dc81c5ecd554329da8d7f0669b21d7335b423a Mon Sep 17 00:00:00 2001 From: yuhanshi Date: Thu, 18 May 2023 11:14:44 +0800 Subject: [PATCH] Replace input tensor format by the oe from the model. Signed-off-by: yuhanshi --- frameworks/native/executor.cpp | 1 + frameworks/native/nn_tensor.cpp | 5 +++++ frameworks/native/nn_tensor.h | 1 + 3 files changed, 7 insertions(+) diff --git a/frameworks/native/executor.cpp b/frameworks/native/executor.cpp index 93670eb..5165404 100644 --- a/frameworks/native/executor.cpp +++ b/frameworks/native/executor.cpp @@ -50,6 +50,7 @@ OH_NN_ReturnCode Executor::BuildInputTensor(uint32_t index, const OH_NN_Tensor& return OH_NN_INVALID_PARAMETER; } + inputTensor->SetFormat(m_modelInputs[index]->GetFormat()); if (!m_modelInputs[index]->CompareAttribute(*inputTensor)) { LOGE("BuildInputTensor failed, input has different attributes from the one in the constructed model."); return OH_NN_INVALID_PARAMETER; diff --git a/frameworks/native/nn_tensor.cpp b/frameworks/native/nn_tensor.cpp index 3f9abd4..fcdcfdd 100644 --- a/frameworks/native/nn_tensor.cpp +++ b/frameworks/native/nn_tensor.cpp @@ -248,6 +248,11 @@ void NNTensor::SetBuffer(const void* buffer, size_t length) m_bufferLength = length; } +void NNTensor::SetFormat(OH_NN_Format format) +{ + m_format = format; +} + OH_NN_ReturnCode NNTensor::SetDimensions(const std::vector& dimensions) { size_t expectedDimensionCount = m_dimensions.size(); diff --git a/frameworks/native/nn_tensor.h b/frameworks/native/nn_tensor.h index 2d55141..60d6de5 100644 --- a/frameworks/native/nn_tensor.h +++ b/frameworks/native/nn_tensor.h @@ -47,6 +47,7 @@ public: void SetName(const std::string& name); void SetBuffer(const void* buffer, size_t length); + void SetFormat(OH_NN_Format format); OH_NN_ReturnCode SetDimensions(const std::vector& dimensions); std::string GetName() const; -- Gitee