diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index c41a9a21e92..9e49f6ecd12 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -194,6 +194,12 @@ if((MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_TESTCASES) AND ( "is configured as off, MSLITE_ENABLE_CONVERTER and MSLITE_ENABLE_TESTCASES must also be configured as off") endif() +if(((MSLITE_GPU_BACKEND STREQUAL tensorrt) OR MSLITE_ENABLE_NPU) AND ( + NOT MSLITE_DELEGATE_USE)) + message(FATAL_ERROR "If MSLITE_DELEGATE_USE use is configured as off, MSLITE_ENABLE_NPU must also be configured + as off and MSLITE_GPU_BACKEND nor can it be configured as tensorrt.") +endif() + if(MSLITE_ENABLE_FP16 AND PLATFORM_ARM32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) message(FATAL_ERROR "If you want to build fp16 in arm82_a32, \ diff --git a/mindspore/lite/src/CMakeLists.txt b/mindspore/lite/src/CMakeLists.txt index 52c95f20876..896525cc2c1 100644 --- a/mindspore/lite/src/CMakeLists.txt +++ b/mindspore/lite/src/CMakeLists.txt @@ -160,12 +160,10 @@ set(LITE_SRC ${KERNEL_REG_SRC} ) -if(MSLITE_DELEGATE_USE) - set(LITE_SRC - ${LITE_SRC} - ${CMAKE_CURRENT_SOURCE_DIR}/delegate/delegate.cc - ) -endif() +set(LITE_SRC + ${LITE_SRC} + ${CMAKE_CURRENT_SOURCE_DIR}/delegate/delegate.cc + ) if(MSLITE_GPU_BACKEND STREQUAL opencl) file(GLOB_RECURSE OPENCL_RUNTIME_SRC diff --git a/mindspore/lite/src/common/log_adapter.h b/mindspore/lite/src/common/log_adapter.h index 3caba2081b3..4e4990cf032 100644 --- a/mindspore/lite/src/common/log_adapter.h +++ b/mindspore/lite/src/common/log_adapter.h @@ -37,6 +37,10 @@ const char *const unsupport_delegate_log = "The mindspore-lite library does not support delegate. Set environment variable " "MSLITE_DELEGATE_USE to on to " "recompile it."; +const char *const unsupport_v0_log = + "The mindspore-lite library does not support v0 ms. Set environment variable " + "MSLITE_ENABLE_V0 to on to " + "recompile it. Or use a new converter tool to re transform the model"; const char *const unsupport_fp16_log = "The mindspore-lite library does not support fp16. Set environment variable " "MSLITE_ENABLE_FP16 to on to " diff --git a/mindspore/lite/src/lite_model.cc b/mindspore/lite/src/lite_model.cc index b418036bb09..e97a4dd3690 100644 --- a/mindspore/lite/src/lite_model.cc +++ b/mindspore/lite/src/lite_model.cc @@ -351,7 +351,11 @@ int LiteModel::ConstructModel() { flatbuffers::Verifier verify((const uint8_t *)this->buf, this->buf_size_); schema_version_ = VersionVerify(&verify); if (schema_version_ == SCHEMA_INVALID) { - MS_LOG(ERROR) << "The buffer is invalid and fail to create graph."; + MS_LOG(ERROR) << "The model buffer is invalid and fail to create graph."; +#ifndef ENABLE_V0 + MS_LOG(ERROR) << "Maybe this is a model transferred out using the conversion tool before 1.1.0"; + MS_LOG(ERROR) << unsupport_v0_log; +#endif return RET_ERROR; } const void *meta_graph = GetMetaGraphByVerison(); diff --git a/mindspore/lite/src/lite_session.cc b/mindspore/lite/src/lite_session.cc index 07f1a090dce..685a5276290 100644 --- a/mindspore/lite/src/lite_session.cc +++ b/mindspore/lite/src/lite_session.cc @@ -676,7 +676,13 @@ int LiteSession::Init(InnerContext *context) { return ret; } if (context->delegate != nullptr) { +#ifndef DELEGATE_CLIP delegate_ = context->delegate; +#else + MS_LOG(ERROR) << unsupport_delegate_log; + is_running_.store(false); + return RET_NOT_SUPPORT; +#endif } ms_context_ = MSContextFromContext(context); if (ms_context_ == nullptr) { @@ -684,6 +690,7 @@ int LiteSession::Init(InnerContext *context) { is_running_.store(false); return RET_NULL_PTR; } +#ifndef DELEGATE_CLIP #if SUPPORT_NPU if (delegate_ == nullptr && context_->IsNpuEnabled()) { delegate_ = std::make_shared(context_->GetNpuInfo()); @@ -704,7 +711,7 @@ int LiteSession::Init(InnerContext *context) { delegate_device_type_ = DT_GPU; } #endif -#ifndef DELEGATE_CLIP + if (delegate_ != nullptr) { auto delegate_ret = delegate_->Init(); if (delegate_ret == mindspore::kLiteNotSupport) { diff --git a/mindspore/lite/src/ops/populate/populate_register.h b/mindspore/lite/src/ops/populate/populate_register.h index 1f248395f99..15a9f6f17a6 100644 --- a/mindspore/lite/src/ops/populate/populate_register.h +++ b/mindspore/lite/src/ops/populate/populate_register.h @@ -18,12 +18,14 @@ #define MINDSPORE_LITE_SRC_OPS_POPULATE_POPULATE_REGISTER_H_ #include +#include #include "schema/model_generated.h" #include "nnacl/op_base.h" #include "src/common/common.h" #include "src/common/log_adapter.h" #include "src/common/prim_util.h" #include "src/common/version_manager.h" +#include "src/common/utils.h" namespace mindspore { namespace lite { @@ -33,6 +35,11 @@ constexpr size_t kMinShapeSizeTwo = 2; constexpr size_t kMinShapeSizeFour = 4; typedef OpParameter *(*ParameterGen)(const void *prim); +static const std::vector string_op = { + schema::PrimitiveType_CustomExtractFeatures, schema::PrimitiveType_CustomNormalize, + schema::PrimitiveType_CustomPredict, schema::PrimitiveType_HashtableLookup, + schema::PrimitiveType_LshProjection, schema::PrimitiveType_SkipGram}; + class PopulateRegistry { public: static PopulateRegistry *GetInstance(); @@ -45,8 +52,16 @@ class PopulateRegistry { ParameterGen param_creator = nullptr; auto iter = parameters_.find(GenPrimVersionKey(type, version)); if (iter == parameters_.end()) { - MS_LOG(ERROR) << "Unsupported parameter type in Create : " - << schema::EnumNamePrimitiveType(static_cast(type)); +#ifdef STRING_KERNEL_CLIP + if (lite::IsContain(string_op, static_cast(type))) { + MS_LOG(ERROR) << unsupport_string_tensor_log; + } else { +#endif + MS_LOG(ERROR) << "Unsupported parameter type in Create : " + << schema::EnumNamePrimitiveType(static_cast(type)); +#ifdef STRING_KERNEL_CLIP + } +#endif return nullptr; } param_creator = iter->second;