diff --git a/build.sh b/build.sh index 33dce9c28c142405ca8fce53a55b4263876f9d24..e198ed69172a2193c9f172f8fa1f182c839ed1bb 100755 --- a/build.sh +++ b/build.sh @@ -426,7 +426,15 @@ build_flatbuffer() { cd ${BASEPATH} FLATC="${BASEPATH}"/third_party/flatbuffers/build/flatc if [[ ! -f "${FLATC}" ]]; then - git submodule update --init --recursive third_party/flatbuffers + if [[ ${MSLIBS_SERVER} ]]; then + cd "${BASEPATH}"/third_party/ + rm -rf ./v1.11.0.tar.gz ./flatbuffers + wget http://${MSLIBS_SERVER}:8081/libs/flatbuffers/v1.11.0.tar.gz + tar -zxvf ./v1.11.0.tar.gz + mv ./flatbuffers-1.11.0 ./flatbuffers + else + git submodule update --init --recursive third_party/flatbuffers + fi cd ${BASEPATH}/third_party/flatbuffers rm -rf build && mkdir -pv build && cd build && cmake -DFLATBUFFERS_BUILD_SHAREDLIB=ON .. && make -j$THREAD_NUM gene_flatbuffer @@ -447,7 +455,15 @@ build_protobuf() { cd ${BASEPATH} PROTOC="${BASEPATH}"/third_party/protobuf/build/bin/protoc if [[ ! -f "${PROTOC}" ]]; then - git submodule update --init --recursive third_party/protobuf + if [[ ${MSLIBS_SERVER} ]]; then + cd "${BASEPATH}"/third_party/ + rm -rf ./v3.8.0.tar.gz ./protobuf + wget http://${MSLIBS_SERVER}:8081/libs/protobuf/v3.8.0.tar.gz + tar -zxvf ./v3.8.0.tar.gz + mv ./protobuf-3.8.0 ./protobuf + else + git submodule update --init --recursive third_party/protobuf + fi cd ${BASEPATH}/third_party/protobuf rm -rf build && mkdir -pv build && ./autogen.sh ./configure --prefix=${BASEPATH}/third_party/protobuf/build @@ -584,7 +600,7 @@ build_lite() fi build_flatbuffer build_gtest - + if [ "${COMPILE_MINDDATA_LITE}" == "lite" ] || [ "${COMPILE_MINDDATA_LITE}" == "full" ]; then build_minddata_lite_deps fi diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.cc index ce00fd3b7e91a04cd278c859777c8e5fbb8ff177..fff52c7c6ff9f08d5b01df461139c33882f5ff20 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.cc @@ -30,6 +30,7 @@ int DetectionPostProcessCPUKernel::Init() { MS_ASSERT(context_->allocator != nullptr); auto anchor_tensor = in_tensors_.at(2); DetectionPostProcessParameter *parameter = reinterpret_cast(op_parameter_); + parameter->anchors_ = nullptr; if (anchor_tensor->data_type() == kNumberTypeUInt8) { const auto quant_params = anchor_tensor->GetQuantParams(); const double scale = quant_params.at(0).scale; @@ -37,15 +38,21 @@ int DetectionPostProcessCPUKernel::Init() { auto anchor_uint8 = reinterpret_cast(anchor_tensor->Data()); auto anchor_fp32 = reinterpret_cast(context_->allocator->Malloc(anchor_tensor->ElementsNum() * sizeof(float))); + if (anchor_fp32 == nullptr) { + MS_LOG(ERROR) << "Malloc anchor failed"; + return RET_ERROR; + } for (int i = 0; i < anchor_tensor->ElementsNum(); ++i) { *(anchor_fp32 + i) = static_cast((static_cast(anchor_uint8[i]) - zp) * scale); } parameter->anchors_ = anchor_fp32; } else if (anchor_tensor->data_type() == kNumberTypeFloat32) { - auto anchor_fp32 = reinterpret_cast(anchor_tensor->Data()); - for (int i = 0; i < anchor_tensor->ElementsNum(); ++i) { - parameter->anchors_[i] = anchor_fp32[i]; + parameter->anchors_ = reinterpret_cast(context_->allocator->Malloc(anchor_tensor->Size())); + if (parameter->anchors_ == nullptr) { + MS_LOG(ERROR) << "Malloc anchor failed"; + return RET_ERROR; } + memcpy(parameter->anchors_, anchor_tensor->Data(), anchor_tensor->Size()); } else { MS_LOG(ERROR) << "unsupported anchor data type " << anchor_tensor->data_type(); return RET_ERROR; @@ -53,6 +60,11 @@ int DetectionPostProcessCPUKernel::Init() { return RET_OK; } +DetectionPostProcessCPUKernel::~DetectionPostProcessCPUKernel() { + DetectionPostProcessParameter *parameter = reinterpret_cast(op_parameter_); + context_->allocator->Free(parameter->anchors_); +} + int DetectionPostProcessCPUKernel::ReSize() { return RET_OK; } int DetectionPostProcessCPUKernel::Run() { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.h b/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.h index 88c2139e67d1a64ab2b4f07d9ae419ac2992adc1..36b990c55663c6e5366919aa548cd535fdcc7f3d 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.h +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/detection_post_process.h @@ -33,7 +33,7 @@ class DetectionPostProcessCPUKernel : public LiteKernel { : LiteKernel(parameter, inputs, outputs, ctx, primitive) { param_ = reinterpret_cast(parameter); } - ~DetectionPostProcessCPUKernel() override = default; + ~DetectionPostProcessCPUKernel() override; int Init() override; int ReSize() override;