diff --git a/frameworks/native/executor.cpp b/frameworks/native/executor.cpp index 93670eb0f715e6640e3e06588d034638a3404135..51654043f99cd1e7fd5f89f6a8f0d2cdbb2f4cb8 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 3f9abd41a305a93f8f52f53d2d087c00aa9fd3ab..fcdcfddf8e70586ff1734da5cef1475c502187c1 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 2d551415056ce70c145def112bf31797745526af..60d6de5bf314116a12ef9b6299915a0f2c04a40e 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;