diff --git a/frameworks/native/neural_network_core/executor.h b/frameworks/native/neural_network_core/executor.h index db1b568130e7954de4ae4349389b34caa662ee80..ba06e675832ad5d8ca2d06df56c38189bdc475b2 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 8a93695285daf011b3507e3f7be99f123912ad0b..b9d088243a0a5b7c774dcb3af242547ae7ad2b73 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 2e16da1f0492e6b3d65077df11947dd6c013bb79..187cfd49a0c554f86da4163c7cb42bbe72d2ccb4 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 52a1309f73c650124c73e281707241e3154f63c1..1d2c17e6b7bb72e2e581cb8556cf806c6f8ef376 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; @@ -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 @@ -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