use MSLIBS_SERVER while downloading third_party & fix
mem leak in detection_post_process
This commit is contained in:
parent
12109600fc
commit
5b17a69d35
22
build.sh
22
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
|
||||
|
|
|
@ -30,6 +30,7 @@ int DetectionPostProcessCPUKernel::Init() {
|
|||
MS_ASSERT(context_->allocator != nullptr);
|
||||
auto anchor_tensor = in_tensors_.at(2);
|
||||
DetectionPostProcessParameter *parameter = reinterpret_cast<DetectionPostProcessParameter *>(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<uint8_t *>(anchor_tensor->Data());
|
||||
auto anchor_fp32 =
|
||||
reinterpret_cast<float *>(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<float>((static_cast<int>(anchor_uint8[i]) - zp) * scale);
|
||||
}
|
||||
parameter->anchors_ = anchor_fp32;
|
||||
} else if (anchor_tensor->data_type() == kNumberTypeFloat32) {
|
||||
auto anchor_fp32 = reinterpret_cast<float *>(anchor_tensor->Data());
|
||||
for (int i = 0; i < anchor_tensor->ElementsNum(); ++i) {
|
||||
parameter->anchors_[i] = anchor_fp32[i];
|
||||
parameter->anchors_ = reinterpret_cast<float *>(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<DetectionPostProcessParameter *>(op_parameter_);
|
||||
context_->allocator->Free(parameter->anchors_);
|
||||
}
|
||||
|
||||
int DetectionPostProcessCPUKernel::ReSize() { return RET_OK; }
|
||||
|
||||
int DetectionPostProcessCPUKernel::Run() {
|
||||
|
|
|
@ -33,7 +33,7 @@ class DetectionPostProcessCPUKernel : public LiteKernel {
|
|||
: LiteKernel(parameter, inputs, outputs, ctx, primitive) {
|
||||
param_ = reinterpret_cast<DetectionPostProcessCPUKernel *>(parameter);
|
||||
}
|
||||
~DetectionPostProcessCPUKernel() override = default;
|
||||
~DetectionPostProcessCPUKernel() override;
|
||||
|
||||
int Init() override;
|
||||
int ReSize() override;
|
||||
|
|
Loading…
Reference in New Issue