Merge pull request !3827 from hangq/mastertags/v0.7.0-beta
| @@ -444,6 +444,11 @@ build_protobuf() { | |||
| fi | |||
| } | |||
| build_gtest() { | |||
| cd ${BASEPATH} | |||
| git submodule update --init --recursive third_party/googletest | |||
| } | |||
| gene_clhpp() { | |||
| CL_SRC_DIR="${BASEPATH}/mindspore/lite/src/runtime/kernel/opencl/cl" | |||
| for sub_dir in "${CL_SRC_DIR}"/* | |||
| @@ -525,6 +530,7 @@ build_lite() | |||
| build_protobuf | |||
| fi | |||
| build_flatbuffer | |||
| build_gtest | |||
| cd "${BASEPATH}/mindspore/lite" | |||
| if [[ "${INC_BUILD}" == "off" ]]; then | |||
| @@ -583,8 +589,8 @@ build_lite() | |||
| mkdir -p ${OUTPUT_DIR}/third_party/flatbuffers | |||
| cp -r ${BASEPATH}/third_party/flatbuffers/include/ ${OUTPUT_DIR}/third_party/flatbuffers/ | |||
| cd .. | |||
| tar -cf MSLite-0.5.0-linux_x86_64.tar.gz MSLite-0.5.0-linux_x86_64/ --warning=no-file-changed | |||
| sha256sum MSLite-0.5.0-linux_x86_64.tar.gz > MSLite-0.5.0-linux_x86_64.tar.gz.256sha | |||
| tar -czf MSLite-0.5.0-linux_x86_64.tar.gz MSLite-0.5.0-linux_x86_64/ --warning=no-file-changed | |||
| sha256sum MSLite-0.5.0-linux_x86_64.tar.gz > MSLite-0.5.0-linux_x86_64.tar.gz.sha256 | |||
| rm -rf MSLite-0.5.0-linux_x86_64/ | |||
| elif [[ "$LITE_PLATFORM" == "arm64" ]]; then | |||
| OUTPUT_DIR=${BASEPATH}/output/MSLite-0.5.0-linux_arm64 | |||
| @@ -602,8 +608,8 @@ build_lite() | |||
| mkdir -p ${OUTPUT_DIR}/third_party/flatbuffers | |||
| cp -r ${BASEPATH}/third_party/flatbuffers/include/ ${OUTPUT_DIR}/third_party/flatbuffers/ | |||
| cd .. | |||
| tar -cf MSLite-0.5.0-linux_arm64.tar.gz MSLite-0.5.0-linux_arm64/ --warning=no-file-changed | |||
| sha256sum MSLite-0.5.0-linux_arm64.tar.gz > MSLite-0.5.0-linux_arm64.tar.gz.256sha | |||
| tar -czf MSLite-0.5.0-linux_arm64.tar.gz MSLite-0.5.0-linux_arm64/ --warning=no-file-changed | |||
| sha256sum MSLite-0.5.0-linux_arm64.tar.gz > MSLite-0.5.0-linux_arm64.tar.gz.sha256 | |||
| rm -rf MSLite-0.5.0-linux_arm64/ | |||
| elif [[ "$LITE_PLATFORM" == "arm32" ]]; then | |||
| OUTPUT_DIR=${BASEPATH}/output/MSLite-0.5.0-linux_arm32 | |||
| @@ -621,8 +627,8 @@ build_lite() | |||
| mkdir -p ${OUTPUT_DIR}/third_party/flatbuffers | |||
| cp -r ${BASEPATH}/third_party/flatbuffers/include/ ${OUTPUT_DIR}/third_party/flatbuffers/ | |||
| cd .. | |||
| tar -cf MSLite-0.5.0-linux_arm32.tar.gz MSLite-0.5.0-linux_arm32/ --warning=no-file-changed | |||
| sha256sum MSLite-0.5.0-linux_arm32.tar.gz > MSLite-0.5.0-linux_arm32.tar.gz.256sha | |||
| tar -czf MSLite-0.5.0-linux_arm32.tar.gz MSLite-0.5.0-linux_arm32/ --warning=no-file-changed | |||
| sha256sum MSLite-0.5.0-linux_arm32.tar.gz > MSLite-0.5.0-linux_arm32.tar.gz.sha256 | |||
| rm -rf MSLite-0.5.0-linux_arm32/ | |||
| fi | |||
| echo "---------------- mindspore lite: build success ----------------" | |||
| @@ -119,6 +119,14 @@ class Object : public Type { | |||
| const TypeId parent_type_; | |||
| }; | |||
| // | |||
| // TypeId name map | |||
| // | |||
| const std::unordered_map<TypeId, std::string> type_name_map = { | |||
| {kNumberTypeBool, "bool_"}, {kNumberTypeInt8, "int8"}, {kNumberTypeUInt8, "uint8"}, | |||
| {kNumberTypeInt16, "int16"}, {kNumberTypeInt32, "int32"}, {kNumberTypeInt64, "int64"}, | |||
| {kNumberTypeFloat16, "float16"}, {kNumberTypeFloat32, "float32"}, {kNumberTypeFloat64, "float64"}}; | |||
| std::ostream &operator<<(std::ostream &os, const TypePtrList &types); | |||
| } // namespace mindspore | |||
| @@ -83,12 +83,5 @@ enum TypeId : int { | |||
| kNumberTypeFloat64, | |||
| kNumberTypeEnd | |||
| }; | |||
| // | |||
| // TypeId name map | |||
| // | |||
| const std::unordered_map<TypeId, std::string> type_name_map = { | |||
| {kNumberTypeBool, "bool_"}, {kNumberTypeInt8, "int8"}, {kNumberTypeUInt8, "uint8"}, | |||
| {kNumberTypeInt16, "int16"}, {kNumberTypeInt32, "int32"}, {kNumberTypeInt64, "int64"}, | |||
| {kNumberTypeFloat16, "float16"}, {kNumberTypeFloat32, "float32"}, {kNumberTypeFloat64, "float64"}}; | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CORE_IR_DTYPE_TYPE_ID_H_ | |||
| @@ -119,5 +119,5 @@ if (BUILD_DEVICE) | |||
| endif() | |||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) | |||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark) | |||
| # add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test) | |||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test) | |||
| endif() | |||
| @@ -22,7 +22,11 @@ | |||
| #include "include/ms_tensor.h" | |||
| namespace mindspore::lite { | |||
| // brief Allocator defined by MindSpore Lite | |||
| // | |||
| // note List public class and interface for reference | |||
| class Allocator; | |||
| enum CpuBindMode { | |||
| MID_CPU = -1, /**< bind mid cpu first */ | |||
| HIGHER_CPU = 1, /**< bind higher cpu first */ | |||
| @@ -31,7 +35,7 @@ enum CpuBindMode { | |||
| typedef enum { DT_CPU, DT_GPU, DT_NPU } DeviceType; | |||
| // brief NPUContext defined by MindSpore predict | |||
| // brief NPUContext defined by MindSpore Lite | |||
| typedef struct { | |||
| int freq{3}; | |||
| int fmkType{0}; | |||
| @@ -40,29 +44,28 @@ typedef struct { | |||
| std::string modelName = "default"; | |||
| } NPUContext; | |||
| // brief DeviceContext defined by MindSpore predict | |||
| // brief DeviceContext defined by MindSpore Lite | |||
| typedef struct { | |||
| DeviceType type; | |||
| // DLContext primary; | |||
| NPUContext npuCtx; | |||
| } DeviceContext; | |||
| // brief Context defined by MindSpore predict | |||
| // brief Context defined by MindSpore Lite | |||
| class MS_API Context { | |||
| public: | |||
| // brief Constructor of MindSpore predict context using default value for parameters | |||
| // brief Constructor of MindSpore Lite context using default value for parameters | |||
| // | |||
| // return Instance of MindSpore predict context. | |||
| // return Instance of MindSpore Lite context. | |||
| Context(); | |||
| // brief Constructor of MindSpore predict context using input value for parameters | |||
| // brief Constructor of MindSpore Lite context using input value for parameters | |||
| // | |||
| // param[in] threadNum Define the threadNum during the runtime. | |||
| // param[in] allocator Define the allocator for malloc. | |||
| // param[in] deviceCtx Define device information during the runtime. | |||
| Context(int threadNum, std::shared_ptr<Allocator> allocator, DeviceContext deviceCtx); | |||
| // brief Destructor of MindSpore predict context | |||
| // brief Destructor of MindSpore Lite context | |||
| virtual ~Context(); | |||
| public: | |||
| @@ -73,4 +76,3 @@ class MS_API Context { | |||
| }; | |||
| } // namespace mindspore::lite | |||
| #endif // MINDSPORE_LITE_INCLUDE_CONTEXT_H_ | |||
| @@ -27,7 +27,7 @@ | |||
| #include "ir/visitor.h" | |||
| #include "ir/func_graph.h" | |||
| #include "debug/label.h" | |||
| #include "utils/label.h" | |||
| #include "utils/log_adapter.h" | |||
| #include "src/common/utils.h" | |||
| @@ -25,7 +25,7 @@ | |||
| #include "ir/func_graph.h" | |||
| #include "mindspore/core/ir/primitive.h" | |||
| #include "debug/info.h" | |||
| #include "utils/info.h" | |||
| #include "ir/anf.h" | |||
| #include "utils/convert_utils_base.h" | |||
| #include "utils/overload.h" | |||
| @@ -34,6 +34,10 @@ std::shared_ptr<ModelImpl> ModelImpl::Import(const char *model_buf, size_t size) | |||
| } | |||
| memcpy(inner_model_buf, model_buf, size); | |||
| auto model = std::make_shared<ModelImpl>(inner_model_buf, size); | |||
| if (model == nullptr) { | |||
| MS_LOG(ERROR) << "Create modelImpl failed"; | |||
| return nullptr; | |||
| } | |||
| auto ret = model->BuildOps(); | |||
| if (0 != ret) { | |||
| MS_LOG(ERROR) << "BuildOps failed"; | |||
| @@ -2,10 +2,8 @@ set(TEST_DIR ${TOP_DIR}/mindspore/lite/test) | |||
| set(LITE_DIR ${TOP_DIR}/mindspore/lite) | |||
| include_directories(${TOP_DIR}) | |||
| include_directories(${TEST_DIR}) | |||
| include_directories(${LITE_DIR}) | |||
| include_directories(${LITE_DIR}/tools) | |||
| include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/dependency_gtest.cmake) | |||
| include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/external_libs/gtest.cmake) | |||
| #include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/external_libs/gtest.cmake) | |||
| ### anf src | |||
| set(ANF_SRC | |||
| @@ -18,13 +16,6 @@ set(ANF_SRC | |||
| if(BUILD_CONVERTER) | |||
| set(ANF_SRC | |||
| ${ANF_SRC} | |||
| # core/abstract | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/abstract_function.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/analysis_context.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/param_validator.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/abstract_value.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/dshape.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/utils.cc | |||
| # core/base | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/base/base_ref.cc | |||
| # core/ir | |||
| @@ -33,7 +24,7 @@ if(BUILD_CONVERTER) | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/meta_func_graph.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/func_graph.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/graph_utils.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../ccsrc/utils/func_graph_cloner.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/func_graph_cloner.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/func_graph_extends.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/manager.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/primitive.cc | |||
| @@ -55,14 +46,21 @@ if(BUILD_CONVERTER) | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/any.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/symbolic.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/misc.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/trace_base.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/trace_info.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/label.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/info.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/utils/profile.cc | |||
| # core/abstract | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/abstract_function.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/analysis_context.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/param_validator.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/abstract_value.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/dshape.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../core/abstract/utils.cc | |||
| ## ccsrc | |||
| ${CCSRC_DIR}/debug/info.cc | |||
| ${CCSRC_DIR}/debug/trace_base.cc | |||
| ${CCSRC_DIR}/debug/trace_info.cc | |||
| ${CCSRC_DIR}/debug/label.cc | |||
| ${CCSRC_DIR}/debug/draw.cc | |||
| ${CCSRC_DIR}/pybind_api/export_flags.cc | |||
| ${CCSRC_DIR}/utils/profile.cc | |||
| ${CCSRC_DIR}/utils/context/ms_context.cc | |||
| ${CCSRC_DIR}/frontend/parallel/costmodel_context.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../src/common/graph_utils_extends.cc | |||
| @@ -247,7 +245,6 @@ set(TEST_SRC | |||
| ${TEST_DIR}/main.cc | |||
| ${TEST_DIR}/ut/src/runtime/kernel/arm/common/pack_tests.cc | |||
| ${TEST_DIR}/ut/src/infer_test.cc | |||
| # ${TEST_DIR}/device/cpu/arm/graph_test.cc | |||
| ) | |||
| if (SUPPORT_TRAIN) | |||
| @@ -279,7 +276,7 @@ endif () | |||
| add_executable(lite-test ${TEST_SRC}) | |||
| target_link_libraries(lite-test dl ${SECUREC_LIBRARY} ${GTEST_LIBRARY} mindspore::json mindspore::gtest) | |||
| target_link_libraries(lite-test dl ${SECUREC_LIBRARY} ${GTEST_LIBRARY} mindspore::json) | |||
| if (BUILD_CONVERTER) | |||
| target_link_libraries(lite-test | |||
| anf_exporter_mid | |||
| @@ -294,4 +291,3 @@ if (BUILD_CONVERTER) | |||
| mindspore::eigen | |||
| ) | |||
| endif() | |||
| @@ -0,0 +1,10 @@ | |||
| #!/usr/bin/env bash | |||
| set -e | |||
| CUR_DIR=$(cd "$(dirname $0)"; pwd) | |||
| BUILD_DIR=${CUR_DIR}/../build | |||
| mkdir -pv ${CUR_DIR}/do_test | |||
| cd ${CUR_DIR}/do_test | |||
| cp ${BUILD_DIR}/test/lite-test ./ | |||
| ./lite-test --gtest_filter="*TestHebing*" | |||
| @@ -16,7 +16,7 @@ | |||
| #include <gtest/gtest.h> | |||
| #include <string> | |||
| #include "common/common_test.h" | |||
| #include "benchmark/benchmark.h" | |||
| #include "tools/benchmark/benchmark.h" | |||
| namespace mindspore { | |||
| namespace lite { | |||
| @@ -26,19 +26,25 @@ class BenchmarkTest : public mindspore::Common { | |||
| }; | |||
| TEST_F(BenchmarkTest, TestVideo) { | |||
| const char *argv[] = {"./benchmark", "--modelPath=./models/hiai_label_and_video.ms"}; | |||
| const char *argv[] = {"./benchmark", "--modelPath=./hiai/hiai_label_and_video.ms" | |||
| "--inDataPath=./hiai/hiai_label_and_video.bin" | |||
| "--calibDataPath=./hiai/hiai_label_and_video.txt"}; | |||
| auto status = RunBenchmark(2, argv); | |||
| ASSERT_EQ(status, RET_OK); | |||
| } | |||
| TEST_F(BenchmarkTest, TestOCR_02) { | |||
| const char *argv[] = {"./benchmark", "--modelPath=./models/hiai_cv_focusShootOCRMOdel_02.ms"}; | |||
| const char *argv[] = {"./benchmark", "--modelPath=./hiai/hiai_cv_focusShootOCRMOdel_02.ms" | |||
| "--inDataPath=./hiai/hiai_cv_focusShootOCRMOdel_02.bin" | |||
| "--calibDataPath=./hiai/hiai_cv_focusShootOCRMOdel_02.txt"}; | |||
| auto status = RunBenchmark(2, argv); | |||
| ASSERT_EQ(status, RET_OK); | |||
| } | |||
| TEST_F(BenchmarkTest, TestHebing) { | |||
| const char *argv[] = {"./benchmark", "--modelPath=./models/model_hebing_3branch.ms"}; | |||
| const char *argv[] = {"./benchmark", "--modelPath=./hiai/model_hebing_3branch.ms" | |||
| "--inDataPath=./hiai/model_hebing_3branch.bin" | |||
| "--calibDataPath=./hiai/model_hebing_3branch.txt"}; | |||
| auto status = RunBenchmark(2, argv); | |||
| ASSERT_EQ(status, RET_OK); | |||
| } | |||
| @@ -15,7 +15,7 @@ | |||
| */ | |||
| #include <gtest/gtest.h> | |||
| #include <string> | |||
| #include "converter/converter.h" | |||
| #include "tools/converter/converter.h" | |||
| #include "common/common_test.h" | |||
| namespace mindspore { | |||
| @@ -26,28 +26,28 @@ class ConverterTest : public mindspore::Common { | |||
| }; | |||
| TEST_F(ConverterTest, TestLenet) { | |||
| const char *argv[] = {"./converter", "--fmk=MS", "--modelFile=./models/lenet_bin.pb", | |||
| const char *argv[] = {"./converter", "--fmk=MS", "--modelFile=./common/lenet_bin.pb", | |||
| "--outputFile=./models/lenet_bin"}; | |||
| auto status = RunConverter(4, argv); | |||
| ASSERT_EQ(status, RET_OK); | |||
| } | |||
| TEST_F(ConverterTest, TestVideo) { | |||
| const char *argv[] = {"./converter", "--fmk=TFLITE", "--modelFile=./models/hiai_label_and_video.tflite", | |||
| const char *argv[] = {"./converter", "--fmk=TFLITE", "--modelFile=./hiai/hiai_label_and_video.tflite", | |||
| "--outputFile=./models/hiai_label_and_video"}; | |||
| auto status = RunConverter(4, argv); | |||
| ASSERT_EQ(status, RET_OK); | |||
| } | |||
| TEST_F(ConverterTest, TestOCR_02) { | |||
| const char *argv[] = {"./converter", "--fmk=TFLITE", "--modelFile=./models/hiai_cv_focusShootOCRMOdel_02.tflite", | |||
| const char *argv[] = {"./converter", "--fmk=TFLITE", "--modelFile=./hiai/hiai_cv_focusShootOCRMOdel_02.tflite", | |||
| "--outputFile=./models/hiai_cv_focusShootOCRMOdel_02"}; | |||
| auto status = RunConverter(4, argv); | |||
| ASSERT_EQ(status, RET_OK); | |||
| } | |||
| TEST_F(ConverterTest, TestHebing) { | |||
| const char *argv[] = {"./converter", "--fmk=CAFFE", "--modelFile=./models/model_hebing_3branch.caffemodel", | |||
| const char *argv[] = {"./converter", "--fmk=CAFFE", "--modelFile=./hiai/model_hebing_3branch.caffemodel", | |||
| "--weightFile=./models/model_hebing_3branch.prototxt", | |||
| "--outputFile=./models/model_hebing_3branch"}; | |||
| auto status = RunConverter(5, argv); | |||
| @@ -15,7 +15,7 @@ set(ANF_SRC | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/ir/meta_func_graph.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/ir/func_graph.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/ir/graph_utils.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../ccsrc/utils/func_graph_cloner.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/ir/func_graph_cloner.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/ir/func_graph_extends.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/ir/manager.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/ir/primitive.cc | |||
| @@ -38,14 +38,14 @@ set(ANF_SRC | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/utils/symbolic.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/utils/misc.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/utils/flags.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/utils/trace_base.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/utils/trace_info.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/utils/label.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/utils/info.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../../core/utils/profile.cc | |||
| ## ccsrc | |||
| ${CCSRC_DIR}/debug/info.cc | |||
| ${CCSRC_DIR}/debug/trace_base.cc | |||
| ${CCSRC_DIR}/debug/trace_info.cc | |||
| ${CCSRC_DIR}/debug/label.cc | |||
| ${CCSRC_DIR}/debug/draw.cc | |||
| ${CCSRC_DIR}/pybind_api/export_flags.cc | |||
| ${CCSRC_DIR}/utils/profile.cc | |||
| ${CCSRC_DIR}/utils/context/ms_context.cc | |||
| ${CCSRC_DIR}/frontend/parallel/costmodel_context.cc | |||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/graph_utils_extends.cc | |||