Browse Source

!22008 [MS][LITE][Develop] optimize script

Merge pull request !22008 from sunsuodong/optimize_build
tags/v1.5.0-rc1
i-robot Gitee 4 years ago
parent
commit
0a9d38f8ff
7 changed files with 57 additions and 21 deletions
  1. +33
    -10
      mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/infer_register.c
  2. +1
    -1
      mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/infer_register.h
  3. +4
    -4
      mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/intrinsics/ms_simd_instructions.h
  4. +8
    -0
      mindspore/lite/build_lite.sh
  5. +0
    -3
      mindspore/lite/test/runtest.sh
  6. +11
    -1
      mindspore/lite/tools/converter/quantizer/fse_decoder.cc
  7. +0
    -2
      mindspore/lite/tools/providers/NNIE/Hi3516D/compile_nnie.sh

+ 33
- 10
mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/infer_register.c View File

@@ -15,7 +15,7 @@
*/
#include "nnacl/infer/infer_register.h"

#ifdef SUPPORT_MSVC
#ifdef _MSC_VER
#include "nnacl/infer/adam_infer.h"
#include "nnacl/infer/add_sub_grad_infer.h"
#include "nnacl/infer/addn_infer.h"
@@ -77,7 +77,6 @@
#include "nnacl/infer/matmul_infer.h"
#include "nnacl/infer/max_min_grad_infer.h"
#include "nnacl/infer/mean_infer.h"
#include "nnacl/infer/control/merge_infer.h"
#include "nnacl/infer/mfcc_infer.h"
#include "nnacl/infer/non_max_suppression_infer.h"
#include "nnacl/infer/one_hot_infer.h"
@@ -117,7 +116,6 @@
#include "nnacl/infer/stack_infer.h"
#include "nnacl/infer/strided_slice_grad_infer.h"
#include "nnacl/infer/strided_slice_infer.h"
#include "nnacl/infer/control/switch_infer.h"
#include "nnacl/infer/control/tensorlist_fromtensor_infer.h"
#include "nnacl/infer/control/tensorlist_getitem_infer.h"
#include "nnacl/infer/control/tensorlist_reserve_infer.h"
@@ -133,6 +131,15 @@
#include "nnacl/infer/unstack_infer.h"
#include "nnacl/infer/where_infer.h"
#include "nnacl/infer/while_infer.h"
#include "nnacl/infer/split_with_over_lap_infer.h"
#include "nnacl/infer/ragged_range_infer.h"
#include "nnacl/infer/glu_infer.h"
#include "nnacl/infer/control/tensor_array_read_infer.h"
#include "nnacl/infer/control/tensor_array_infer.h"
#include "nnacl/infer/control/tensor_array_write_infer.h"
#include "nnacl/infer/affine_infer.h"
#include "nnacl/infer/attention_infer.h"
#include "nnacl/infer/scatter_nd_update_infer.h"

InferShape g_infer_func[PrimType_MAX * sizeof(InferShape)] = {0};
void RegAllInferFunc1() {
@@ -230,7 +237,7 @@ void RegAllInferFunc1() {
g_infer_func[PrimType_MaximumGrad] = MaxMinGradInferShape;
g_infer_func[PrimType_MaxPoolFusion] = PoolingInferShape;
g_infer_func[PrimType_MaxPoolGrad] = PoolingGradInferShape;
g_infer_func[PrimType_Merge] = MergeInferShape;
g_infer_func[PrimType_Merge] = NULL;
g_infer_func[PrimType_Mfcc] = MfccInferShape;
g_infer_func[PrimType_Minimum] = ArithmeticInferShape;
g_infer_func[PrimType_MinimumGrad] = MaxMinGradInferShape;
@@ -293,7 +300,7 @@ void RegAllInferFunc2() {
g_infer_func[PrimType_StridedSlice] = StridedSliceInferShape;
g_infer_func[PrimType_SubFusion] = ArithmeticInferShape;
g_infer_func[PrimType_SubGrad] = AddSubGradInferShape;
g_infer_func[PrimType_Switch] = SwitchInferShape;
g_infer_func[PrimType_Switch] = NULL;
g_infer_func[PrimType_TensorListFromTensor] = TensorListFromTensorInferShape;
g_infer_func[PrimType_TensorListGetItem] = TensorListGetItemInferShape;
g_infer_func[PrimType_TensorListReserve] = TensorListReserveInferShape;
@@ -334,16 +341,32 @@ void RegAllInferFunc2() {
g_infer_func[PrimType_CumSum] = CumsumInferShape;
}

typedef void RegFunc();
#pragma data_seg(".CRT$XIU")
static RegFunc *before[] = {RegAllInferFunc1, RegAllInferFunc2};
#pragma data_seg()
void RegAllInferFunc3() {
g_infer_func[PrimType_SplitWithOverlap] = SplitWithOverlapInferShape;
g_infer_func[PrimType_GenOP] = NULL;
g_infer_func[PrimType_RaggedRange] = RaggedRangeInferShape;
g_infer_func[PrimType_GLU] = GluInferShape;
g_infer_func[PrimType_TensorArray] = TensorArrayInferShape;
g_infer_func[PrimType_TensorArrayRead] = TensorArrayReadInferShape;
g_infer_func[PrimType_TensorArrayWrite] = TensorArrayWriteInferShape;
g_infer_func[PrimType_Affine] = AffineInferShape;
g_infer_func[PrimType_Attention] = AttentionInferShape;
g_infer_func[PrimType_LSTMGrad] = NULL;
g_infer_func[PrimType_ScatterNdUpdate] = ScatterNdUpdateInferShape;
}

#else
__attribute__((init_priority(101))) InferShape g_infer_func[PrimType_MAX * sizeof(InferShape)] = {0};
#endif // SUPPORT_MSVC
#endif // _MSC_VER

InferShape GetInferFunc(int prim_type) {
#ifdef _MSC_VER
if (g_infer_func[PrimType_Abs] == NULL) {
RegAllInferFunc1();
RegAllInferFunc2();
RegAllInferFunc3();
}
#endif
if (prim_type < PrimType_MAX) {
return g_infer_func[prim_type];
}


+ 1
- 1
mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/infer_register.h View File

@@ -234,7 +234,7 @@ enum PrimType {

void RegInfer(int prim_type, InferShape func);

#ifdef SUPPORT_MSVC
#ifdef _MSC_VER
#define REG_INFER(op, type, func)
#else
#define REG_INFER(op, type, func) \


+ 4
- 4
mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/intrinsics/ms_simd_instructions.h View File

@@ -147,10 +147,10 @@ static inline float32x4_t vrecp(float32x4_t v) {
#if defined(ENABLE_ARM) || defined(ENABLE_SSE)
static inline MS_FLOAT32X4 MS_SQRTFX4_F32(MS_FLOAT32X4 src) {
MS_FLOAT32X4 dst;
dst[0] = sqrtf(src[0]);
dst[1] = sqrtf(src[1]);
dst[2] = sqrtf(src[2]);
dst[3] = sqrtf(src[3]);
MS_F32X4_GETI(dst, 0) = sqrtf(MS_F32X4_GETI(src, 0));
MS_F32X4_GETI(dst, 1) = sqrtf(MS_F32X4_GETI(src, 1));
MS_F32X4_GETI(dst, 2) = sqrtf(MS_F32X4_GETI(src, 2));
MS_F32X4_GETI(dst, 3) = sqrtf(MS_F32X4_GETI(src, 3));
return dst;
}



+ 8
- 0
mindspore/lite/build_lite.sh View File

@@ -221,6 +221,14 @@ build_lite() {
else
mv ${BASEPATH}/output/tmp/*.tar.gz* ${BASEPATH}/output/
fi

if [[ "${local_lite_platform}" == "x86_64" ]]; then
mkdir -pv ${BASEPATH}/mindspore/lite/test/do_test || true
cp ${BASEPATH}/output/tmp/mindspore-lite*/tools/converter/lib/*.so* ${BASEPATH}/mindspore/lite/test/do_test || true
cp ${BASEPATH}/output/tmp/mindspore-lite*/runtime/lib/*.so* ${BASEPATH}/mindspore/lite/test/do_test || true
cp ${BASEPATH}/output/tmp/mindspore-lite*/runtime/third_party/libjpeg-turbo/lib/*.so* ${BASEPATH}/mindspore/lite/test/do_test || true
fi

[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/output/tmp/
if [[ "${MSLITE_ENABLE_NNIE}" == "on" ]]; then
compile_nnie_script=${BASEPATH}/mindspore/lite/tools/providers/NNIE/Hi3516D/compile_nnie.sh


+ 0
- 3
mindspore/lite/test/runtest.sh View File

@@ -13,9 +13,6 @@ mkdir -pv ${CUR_DIR}/do_test
cd ${CUR_DIR}/do_test
cp ${BUILD_DIR}/test/lite-test ./
cp ${BUILD_DIR}/googletest/googlemock/gtest/libgtest.so ./
tar -xzf ../../../../output/mindspore-lite-*.tar.gz --strip-components=3 --wildcards *runtime/lib/*.so* || true
tar -xzf ../../../../output/mindspore-lite-*.tar.gz --strip-components=4 --wildcards *converter/lib/*.so* || true
tar -xzf ../../../../output/mindspore-lite-*.tar.gz --strip-components=5 --wildcards *libjpeg-turbo/lib/*.so* || true
ls -l *.so*
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./



+ 11
- 1
mindspore/lite/tools/converter/quantizer/fse_decoder.cc View File

@@ -52,8 +52,18 @@ int FSEDecoder::FSECreateStatesForDecoding(const uint16_t *symbol_frequency, int
uint16_t sym = symbol_table[i];
uint16_t x = frequency[sym];
frequency[sym] += 1;

#ifdef _MSC_VER
int num = 0;
uint32_t tmp = x;
tmp |= 1;
while (!(tmp & 0x80000000)) {
num += 1;
tmp <<= 1;
}
bit_count[i] = table_log - (num ^ 31);
#else
bit_count[i] = table_log - (__builtin_clz(x) ^ 31);
#endif
new_state[i] = (x << bit_count[i]) - table_size;
}
return RET_OK;


+ 0
- 2
mindspore/lite/tools/providers/NNIE/Hi3516D/compile_nnie.sh View File

@@ -14,8 +14,6 @@ function Run_Build_x86() {
rm -rf ${nnie_code_path}/mindspore/mindspore/lite/tools/converter/nnie/third_party/ms_lite/
mkdir -p ${nnie_code_path}/mindspore/mindspore/lite/tools/converter/nnie/third_party/ms_lite/ || exit 1
cp -r ./tools/ ${nnie_code_path}/mindspore/mindspore/lite/tools/converter/nnie/third_party/ms_lite/ || exit 1
mkdir -pv ${open_source_ms_path}/mindspore/lite/test/do_test
cp ./tools/converter/lib/*.so* ${open_source_ms_path}/mindspore/lite/test/do_test

# compile nnie converter so
export MSLITE_ENABLE_NNIE=on


Loading…
Cancel
Save