From 5a1f46808793a4f5c389cc903dabadf00b5da82d Mon Sep 17 00:00:00 2001 From: w30052974 Date: Thu, 9 May 2024 15:30:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=94=A8=E4=BE=8B=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BF=AE=E8=AE=A22.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: w30052974 --- frameworks/native/neural_network_core/executor.h | 2 +- .../native/neural_network_core/neural_network_core.cpp | 2 +- frameworks/native/neural_network_runtime/nnexecutor.cpp | 4 ++-- frameworks/native/neural_network_runtime/nnexecutor.h | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frameworks/native/neural_network_core/executor.h b/frameworks/native/neural_network_core/executor.h index db1b568..ba06e67 100644 --- a/frameworks/native/neural_network_core/executor.h +++ b/frameworks/native/neural_network_core/executor.h @@ -34,7 +34,7 @@ public: virtual OH_NN_ReturnCode GetInputDimRange(size_t inputIndex, size_t** minInputDims, size_t** maxInputDims, - size_t* shapeNum) = 0; + size_t* shapeNum) const = 0; virtual OH_NN_ReturnCode GetOutputShape(uint32_t outputIndex, int32_t** shape, uint32_t* shapeNum) const = 0; virtual size_t GetInputNum() const = 0; diff --git a/frameworks/native/neural_network_core/neural_network_core.cpp b/frameworks/native/neural_network_core/neural_network_core.cpp index 8a93695..b9d0882 100644 --- a/frameworks/native/neural_network_core/neural_network_core.cpp +++ b/frameworks/native/neural_network_core/neural_network_core.cpp @@ -1135,7 +1135,7 @@ NNRT_API OH_NN_ReturnCode OH_NNExecutor_GetInputDimRange(const OH_NNExecutor *ex return OH_NN_INVALID_PARAMETER; } - Executor *executorImpl = reinterpret_cast(const_cast(executor)); + const Executor *executorImpl = reinterpret_cast(executor); return executorImpl->GetInputDimRange(index, minInputDims, maxInputDims, shapeLength); } diff --git a/frameworks/native/neural_network_runtime/nnexecutor.cpp b/frameworks/native/neural_network_runtime/nnexecutor.cpp index 2e16da1..187cfd4 100644 --- a/frameworks/native/neural_network_runtime/nnexecutor.cpp +++ b/frameworks/native/neural_network_runtime/nnexecutor.cpp @@ -35,7 +35,7 @@ NNExecutor::NNExecutor(size_t backendID, std::shared_ptr device, std::sh m_inputTensorDescs(inputTensorDescs), m_outputTensorDescs(outputTensorDescs) {} -OH_NN_ReturnCode NNExecutor::GetInputDimVec() +OH_NN_ReturnCode NNExecutor::GetInputDimVec() const { std::vector> minInputDimsVec; std::vector> maxInputDimsVec; @@ -69,7 +69,7 @@ OH_NN_ReturnCode NNExecutor::GetInputDimVec() } OH_NN_ReturnCode NNExecutor::GetInputDimRange( - size_t inputIndex, size_t** minInputDims, size_t** maxInputDims, size_t* shapeNum) + size_t inputIndex, size_t** minInputDims, size_t** maxInputDims, size_t* shapeNum) const { if (minInputDims == nullptr) { LOGE("NNExecutor::GetInputDimRange failed, minInputDims is nullptr."); diff --git a/frameworks/native/neural_network_runtime/nnexecutor.h b/frameworks/native/neural_network_runtime/nnexecutor.h index 52a1309..65879fd 100644 --- a/frameworks/native/neural_network_runtime/nnexecutor.h +++ b/frameworks/native/neural_network_runtime/nnexecutor.h @@ -35,7 +35,7 @@ public: OH_NN_ReturnCode GetInputDimRange(size_t inputIndex, size_t** minInputDims, size_t** maxInputDims, - size_t* shapeNum) override; + size_t* shapeNum) const override; OH_NN_ReturnCode GetOutputShape(uint32_t outputIndex, int32_t** shape, uint32_t* shapeNum) const override; size_t GetInputNum() const override; @@ -108,8 +108,8 @@ private: std::unordered_map m_outputTensors; std::unordered_map> m_inputCreatedMem; std::unordered_map> m_outputCreatedMem; - std::vector> m_minInputDimsVec; - std::vector> m_maxInputDimsVec; + mutable std::vector> m_minInputDimsVec; + mutable std::vector> m_maxInputDimsVec; }; } // namespace NeuralNetworkRuntime } // namespace OHOS -- Gitee From 19bd16c31062833b77de38e4b44e87aec08ad793 Mon Sep 17 00:00:00 2001 From: w30052974 Date: Thu, 9 May 2024 15:43:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=94=A8=E4=BE=8B=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BF=AE=E8=AE=A22.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: w30052974 --- frameworks/native/neural_network_runtime/nnexecutor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/neural_network_runtime/nnexecutor.h b/frameworks/native/neural_network_runtime/nnexecutor.h index 65879fd..1d2c17e 100644 --- a/frameworks/native/neural_network_runtime/nnexecutor.h +++ b/frameworks/native/neural_network_runtime/nnexecutor.h @@ -71,7 +71,7 @@ public: OH_NN_ReturnCode Run(); private: - OH_NN_ReturnCode GetInputDimVec(); + OH_NN_ReturnCode GetInputDimVec() const; OH_NN_ReturnCode CheckInputDimRanges(NN_Tensor* inputTensors[], size_t inputSize); // The following APIs are compatible with older versions -- Gitee