!6550 fix static check error

Merge pull request !6550 from yeyunpeng2020/static
This commit is contained in:
mindspore-ci-bot 2020-09-19 14:41:47 +08:00 committed by Gitee
commit 9135b2c091
5 changed files with 37 additions and 27 deletions

View File

@ -38,7 +38,7 @@ IF "%1%" == "lite" (
call :run_cmake
IF errorlevel 1 (
echo "cmake fail."
goto run_fail
call :run_fail
)
) ELSE (
call :gene_protobuf
@ -53,7 +53,7 @@ IF "%1%" == "lite" (
)
IF errorlevel 1 (
echo "build fail."
goto run_fail
call :run_fail
) ELSE (
cd %BASEPATH%/output
rd /s /q _CPack_Packages
@ -63,7 +63,7 @@ IF "%1%" == "lite" (
-G "CodeBlocks - MinGW Makefiles" ../..
IF NOT %errorlevel% == 0 (
echo "cmake fail."
goto run_fail
call :run_fail
)
IF "%1%" == "" (
@ -73,7 +73,7 @@ IF "%1%" == "lite" (
)
IF NOT %errorlevel% == 0 (
echo "build fail."
goto run_fail
call :run_fail
)
)
@ -123,5 +123,6 @@ GOTO:EOF
:run_fail
cd %BASEPATH%
set errorlevel=1
EXIT
:run_eof

View File

@ -412,7 +412,7 @@ build_flatbuffer() {
cd ${BASEPATH}
FLATC="${BASEPATH}"/third_party/flatbuffers/build/flatc
if [[ ! -f "${FLATC}" ]]; then
if [[ ${MSLIBS_SERVER} ]]; then
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
@ -441,7 +441,7 @@ build_protobuf() {
cd ${BASEPATH}
PROTOC="${BASEPATH}"/third_party/protobuf/build/bin/protoc
if [[ ! -f "${PROTOC}" ]]; then
if [[ ${MSLIBS_SERVER} ]]; then
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
@ -468,7 +468,7 @@ build_gtest() {
gene_clhpp() {
CL_SRC_DIR="${BASEPATH}/mindspore/lite/src/runtime/kernel/opencl/cl"
if [ ! -d ${CL_SRC_DIR} ]; then
if [ ! -d "${CL_SRC_DIR}" ]; then
return
fi
cd ${CL_SRC_DIR}/
@ -477,33 +477,33 @@ gene_clhpp() {
for file_path in "${CL_SRC_DIR}"/*
do
file="$(basename ${file_path})"
inc_file=`echo ${CL_SRC_DIR}/${file} | sed 's/$/.inc/'`
inc_file=$(echo ${CL_SRC_DIR}/${file} | sed 's/$/.inc/')
sed 's/^/\"/;s/$/ \\n\" \\/' ${CL_SRC_DIR}/${file} > ${inc_file}
kernel_name=`echo ${file} | sed s'/.\{3\}$//'`
kernel_name=$(echo ${file} | sed s'/.\{3\}$//')
sed -i "1i\static const char *${kernel_name}_source =\"\\n\" \\" ${inc_file}
sed -i '$a\;' ${inc_file}
done
}
gene_ocl_program() {
CL_SRC_DIR="${BASEPATH}/mindspore/lite/src/runtime/kernel/opencl/cl"
OCL_SRC_DIR="${BASEPATH}/mindspore/lite/src/runtime/kernel/opencl/cl"
SPIRV_DIR=build/spirv
rm -rf ${SPIRV_DIR}
[ -n "${SPIRV_DIR}" ] && rm -rf ${SPIRV_DIR}
mkdir -pv ${SPIRV_DIR}
if [ ! -d ${CL_SRC_DIR} ]; then
if [ ! -d "${OCL_SRC_DIR}" ]; then
return
fi
for file_path in "${CL_SRC_DIR}"/*
for file_path in "${OCL_SRC_DIR}"/*
do
file="$(basename ${file_path})"
if [ "${file##*.}" != "cl" ]; then
ocl_file="$(basename ${file_path})"
if [ "${ocl_file##*.}" != "cl" ]; then
continue
fi
clang -Xclang -finclude-default-header -cl-std=CL2.0 --target=spir64-unknown-unknown -emit-llvm \
-c -O0 -o ${SPIRV_DIR}/${file%.*}.bc ${CL_SRC_DIR}/${file}
-c -O0 -o ${SPIRV_DIR}/${ocl_file%.*}.bc ${OCL_SRC_DIR}/${ocl_file}
done
bcs=`ls ${SPIRV_DIR}/*.bc`
bcs=$(ls ${SPIRV_DIR}/*.bc)
llvm-link ${bcs} -o ${SPIRV_DIR}/program.bc
llvm-spirv -o ${SPIRV_DIR}/program.spv ${SPIRV_DIR}/program.bc
@ -539,7 +539,7 @@ build_opencv() {
fi
if [[ ! -f "${OPENCV_BIN}" ]]; then
if [[ ${MSLIBS_SERVER} ]]; then
if [[ "${MSLIBS_SERVER}" ]]; then
cd "${BASEPATH}"/third_party/
rm -rf 4.2.0.tar.gz ./opencv
wget http://${MSLIBS_SERVER}:8081/libs/opencv/4.2.0.tar.gz
@ -564,7 +564,7 @@ build_jpeg_turbo() {
fi
if [[ ! -f "${JPEG_TURBO}" ]]; then
if [[ ${MSLIBS_SERVER} ]]; then
if [[ "${MSLIBS_SERVER}" ]]; then
cd "${BASEPATH}"/third_party/
rm -rf 2.0.4.tar.gz ./libjpeg-turbo
wget http://${MSLIBS_SERVER}:8081/libs/jpeg_turbo/2.0.4.tar.gz
@ -583,7 +583,7 @@ build_jpeg_turbo() {
build_eigen() {
cd ${BASEPATH}
if [[ ${MSLIBS_SERVER} ]]; then
if [[ "${MSLIBS_SERVER}" ]]; then
cd "${BASEPATH}"/third_party/
rm -rf ./eigen-3.*.tar.gz ./eigen
wget http://${MSLIBS_SERVER}:8081/libs/eigen3/eigen-3.3.7.tar.gz
@ -617,9 +617,9 @@ build_minddata_lite_deps()
build_lite()
{
VERSION_MAJOR=`grep "const int ms_version_major =" mindspore/lite/include/version.h | tr -dc "[0-9]"`
VERSION_MINOR=`grep "const int ms_version_minor =" mindspore/lite/include/version.h | tr -dc "[0-9]"`
VERSION_REVISION=`grep "const int ms_version_revision =" mindspore/lite/include/version.h | tr -dc "[0-9]"`
VERSION_MAJOR=$(grep "const int ms_version_major =" mindspore/lite/include/version.h | tr -dc "[0-9]")
VERSION_MINOR=$(grep "const int ms_version_minor =" mindspore/lite/include/version.h | tr -dc "[0-9]")
VERSION_REVISION=$(grep "const int ms_version_revision =" mindspore/lite/include/version.h | tr -dc "[0-9]")
echo "============ Start building MindSpore Lite ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION} ============"
if [ "${ENABLE_GPU}" == "on" ] && [ "${LITE_PLATFORM}" == "arm64" ]; then
echo "start build opencl"

View File

@ -90,11 +90,12 @@ int WriteToBin(const std::string &file_path, void *data, size_t size) {
out_file.open(file_path.c_str(), std::ios::binary);
if (!out_file.good()) {
MS_LOG(ERROR) << "file is bad";
return -1;
}
if (!out_file.is_open()) {
out_file.close();
MS_LOG(ERROR) << "file open failed";
return -1;
}
out_file.write(reinterpret_cast<char *>(data), size);

View File

@ -37,6 +37,10 @@ template <typename T>
void WriteToTxt(const std::string &file_path, void *data, size_t element_size) {
std::ofstream out_file;
out_file.open(file_path, std::ios::out);
if (!out_file.is_open()) {
MS_LOG(ERROR) << "file open failed";
return;
}
auto real_data = reinterpret_cast<T *>(data);
for (size_t i = 0; i < element_size; i++) {
out_file << real_data[i] << " ";

View File

@ -38,16 +38,20 @@ Tensor::Tensor(const Tensor &tensor) {
int Tensor::CopyTensorData(const Tensor &srcTensor) {
if (srcTensor.data_ == nullptr) {
MS_LOG(ERROR) << "data of srcTensor is nullptr";
return mindspore::lite::RET_PARAM_INVALID;
return RET_PARAM_INVALID;
}
size_t data_size = this->Size();
MS_ASSERT(data_size == srcTensor.Size());
if (this->data_ == nullptr) {
if (data_size > kMaxMallocSize) {
MS_LOG(ERROR) << "Malloc size is too big while coping data, " << data_size << " bytes";
return mindspore::lite::RET_ERROR;
return RET_ERROR;
}
this->data_ = malloc(data_size);
if (this->data_ == nullptr) {
MS_LOG(ERROR) << "Malloc memory failed";
return RET_ERROR;
}
}
memcpy(this->data_, srcTensor.data_, data_size);
return 0;
@ -62,7 +66,7 @@ int Tensor::CopyTensor(const Tensor &srcTensor, bool copyData) {
auto ret = CopyTensorData(srcTensor);
if (0 != ret) {
MS_LOG(ERROR) << "CopyTensorData error";
return mindspore::lite::RET_ERROR;
return RET_ERROR;
}
}
return 0;