diff --git a/onert-micro/onert-micro/include/core/OMDataType.h b/onert-micro/onert-micro/include/core/OMDataType.h index d60fa162a9e..a6f5e06bc73 100644 --- a/onert-micro/onert-micro/include/core/OMDataType.h +++ b/onert-micro/onert-micro/include/core/OMDataType.h @@ -172,7 +172,7 @@ inline uint32_t size(OMDataType data_type) default: // TODO Support remaining data types. assert(false); - return UINT32_MAX; // Avoid compiler warning. + return 1; // Avoid compiler warning. } } diff --git a/onert-micro/onert-micro/include/execute/OMRuntimeKernel.h b/onert-micro/onert-micro/include/execute/OMRuntimeKernel.h index fcedcb4ec4c..b6f63cdaa48 100644 --- a/onert-micro/onert-micro/include/execute/OMRuntimeKernel.h +++ b/onert-micro/onert-micro/include/execute/OMRuntimeKernel.h @@ -57,8 +57,8 @@ class OMRuntimeKernel int32_t inputs_index[maxInputSize] = {-1}; int32_t outputs_index[maxOutputSize] = {-1}; - uint32_t outputs_num = -1; - uint32_t inputs_num = -1; + uint32_t outputs_num = 0; + uint32_t inputs_num = 0; const circle::Operator *first_operator = nullptr; }; diff --git a/onert-micro/onert-micro/include/pal/common/PALSpaceToDepthCommon.h b/onert-micro/onert-micro/include/pal/common/PALSpaceToDepthCommon.h index 28f31e5a031..c3e7d4def15 100644 --- a/onert-micro/onert-micro/include/pal/common/PALSpaceToDepthCommon.h +++ b/onert-micro/onert-micro/include/pal/common/PALSpaceToDepthCommon.h @@ -34,6 +34,11 @@ inline OMStatus SpaceToDepth(const int32_t block_size, const T *input_data, const core::OMRuntimeShape &unextended_output_shape, T *output_data) { + if (block_size == 0) + { + return FailedCheckCondition; + } + const core::OMRuntimeShape input_shape = core::OMRuntimeShape::extendedShape(4, unextended_input_shape); const core::OMRuntimeShape output_shape = diff --git a/onert-micro/onert-micro/src/api/onert-micro.cpp b/onert-micro/onert-micro/src/api/onert-micro.cpp index fabaeae7b37..908ba21fac2 100644 --- a/onert-micro/onert-micro/src/api/onert-micro.cpp +++ b/onert-micro/onert-micro/src/api/onert-micro.cpp @@ -194,6 +194,7 @@ NNFW_STATUS nnfw_session::loadOptimizerInfo(const circle::ModelTraining *circle_ NNFW_STATUS nnfw_session::loadLossInfo(const circle::ModelTraining *circle_model) { assert(circle_model != nullptr); + NNFW_RETURN_ERROR_IF_NULL(circle_model); const circle::LossFn circle_loss = circle_model->lossfn(); @@ -219,6 +220,7 @@ NNFW_STATUS nnfw_session::loadLossInfo(const circle::ModelTraining *circle_model NNFW_STATUS nnfw_session::loadTrainableOps(const circle::ModelTraining *circle_model, int num_ops) { assert(circle_model != nullptr); + NNFW_RETURN_ERROR_IF_NULL(circle_model); auto ops_list = circle_model->trainable_ops(); if (ops_list != nullptr) @@ -245,12 +247,22 @@ NNFW_STATUS nnfw_session::loadTrainingInfo(char *buf) continue; data = (model->buffers()->Get(metadata->buffer()))->data()->data(); } + NNFW_RETURN_ERROR_IF_NULL(data); + const circle::ModelTraining *traininfo_model = circle::GetModelTraining(static_cast(data)); _config.training_context.batch_size = traininfo_model->batch_size(); - loadOptimizerInfo(traininfo_model); - loadLossInfo(traininfo_model); - loadTrainableOps(traininfo_model, num_ops); + NNFW_STATUS status = loadOptimizerInfo(traininfo_model); + if (status != NNFW_STATUS_NO_ERROR) + return status; + + status = loadLossInfo(traininfo_model); + if (status != NNFW_STATUS_NO_ERROR) + return status; + + status = loadTrainableOps(traininfo_model, num_ops); + if (status != NNFW_STATUS_NO_ERROR) + return status; } return NNFW_STATUS_NO_ERROR; } diff --git a/onert-micro/onert-micro/src/execute/kernels/FloorDiv.cpp b/onert-micro/onert-micro/src/execute/kernels/FloorDiv.cpp index ca70d729ae2..ccff542e23e 100644 --- a/onert-micro/onert-micro/src/execute/kernels/FloorDiv.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/FloorDiv.cpp @@ -50,7 +50,9 @@ OMStatus onert_micro::execute::execute_kernel_CircleFloorDiv(const OMExecuteArgs // Check the denominator for (int i = 0; i < input_shape2.flatSize(); ++i) { - utils::checkCondition(core::utils::castInputData(input_data2)[i] != 0); + status = utils::checkCondition(core::utils::castInputData(input_data2)[i] != 0); + if (status != Ok) + return status; } // check that input and output dimensions are equal if (input_shape1 == input_shape2) diff --git a/onert-micro/onert-micro/src/optimize/pass/FindInplaceOpPass.cpp b/onert-micro/onert-micro/src/optimize/pass/FindInplaceOpPass.cpp index 9239320fba9..08d2ee7dcae 100644 --- a/onert-micro/onert-micro/src/optimize/pass/FindInplaceOpPass.cpp +++ b/onert-micro/onert-micro/src/optimize/pass/FindInplaceOpPass.cpp @@ -199,7 +199,7 @@ OMStatus checkInplaceOp(core::OMRuntimeContext &context, const circle::Operator OMStatus findInplaceOp(core::OMRuntimeStorage &storage, core::OMRuntimeContext &context, const OMConfig &configs, bool &is_changed) { - OMStatus status; + OMStatus status = Ok; const core::reader::CircleOperators *operators = context.getCircleOperators();