!30977 fix quant strategy with value equel && fix crypto

Merge pull request !30977 from yeyunpeng2020/quant
This commit is contained in:
i-robot 2022-03-08 12:47:31 +00:00 committed by Gitee
commit e9f2e7e9a6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 11 additions and 12 deletions

View File

@ -14,6 +14,7 @@ endif()
if(BUILD_LITE)
if(PLATFORM_ARM64 AND ANDROID_NDK_TOOLCHAIN_INCLUDED)
set(openssl_USE_STATIC_LIBS OFF)
set(ANDROID_NDK_ROOT $ENV{ANDROID_NDK})
set(PATH
${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin:
@ -39,7 +40,7 @@ if(BUILD_LITE)
LIBS ssl crypto
URL ${REQ_URL}
MD5 ${MD5}
CONFIGURE_COMMAND ./Configure android-arm -D__ANDROID_API__=29 no-zlib
CONFIGURE_COMMAND ./Configure android-arm -D__ANDROID_API__=19 no-zlib
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3711.patch
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3712.patch
)
@ -49,7 +50,7 @@ if(BUILD_LITE)
LIBS ssl crypto
URL ${REQ_URL}
MD5 ${MD5}
CONFIGURE_COMMAND ./config no-zlib no-shared
CONFIGURE_COMMAND ./config no-zlib
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3711.patch
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3712.patch
)

View File

@ -34,7 +34,7 @@ option(MSLITE_ENABLE_V0 "support v0 schema" on)
option(MSLITE_ENABLE_FP16 "Whether to compile Fp16 operator" off)
option(MSLITE_ENABLE_INT8 "Whether to compile Int8 operator" on)
option(MSLITE_ENABLE_ACL "enable ACL" off)
option(MSLITE_ENABLE_MODEL_ENCRYPTION "enable model encryption, only converter support" off)
option(MSLITE_ENABLE_MODEL_ENCRYPTION "enable model encryption" off)
option(MSLITE_ENABLE_SPARSE_COMPUTE "enable sparse kernel" off)
option(MSLITE_ENABLE_RUNTIME_CONVERT "enable runtime convert" off)
option(MSLITE_ENABLE_RUNTIME_GLOG "enable runtime glog" off)
@ -127,7 +127,8 @@ if(DEFINED ENV{MSLITE_MINDDATA_IMPLEMENT})
set(MSLITE_MINDDATA_IMPLEMENT $ENV{MSLITE_MINDDATA_IMPLEMENT})
endif()
if(DEFINED ENV{MSLITE_ENABLE_MODEL_ENCRYPTION})
if((${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND PLATFORM_X86_64) OR (PLATFORM_ARM AND ANDROID_NDK_TOOLCHAIN_INCLUDED))
if((${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND PLATFORM_X86_64)
OR((PLATFORM_ARM64 OR PLATFORM_ARM32) AND ANDROID_NDK_TOOLCHAIN_INCLUDED))
set(MSLITE_ENABLE_MODEL_ENCRYPTION $ENV{MSLITE_ENABLE_MODEL_ENCRYPTION})
else()
set(MSLITE_ENABLE_MODEL_ENCRYPTION OFF)

View File

@ -217,15 +217,12 @@ double DataDistribution::CalculateScaleAndZp(float min_value, float max_value) {
}
// Inputs are both negative and positive, real_min and real_max are slightly shifted to make the floating point zero
// exactly representable. e.g. input range = [-5.1, 5.1] -> [-5.12, 5.08]
MS_ASSERT(quant_max_ - quant_min_ > 0);
auto range = encode_max_ - encode_min_;
if (max_value <= 0.0f) {
MS_LOG(INFO) << "The value is 0, so set to symmetry and the range to 0.01.";
const float zero_range = 0.01f;
range = zero_range;
symmetry_ = true;
}
// handle case where encode_min_ == encode_max_
float epsilon = 1e-5;
encode_max_ = std::max(encode_max_, encode_min_ + epsilon);
auto range = encode_max_ - encode_min_;
MS_ASSERT(quant_max_ - quant_min_ > 0);
return range / (quant_max_ - quant_min_);
}