fix some bugs

This commit is contained in:
zuochuanyong 2022-09-09 11:23:36 +08:00
parent ca371e1531
commit 37b69b8737
7 changed files with 42 additions and 22 deletions

View File

@ -680,33 +680,31 @@ const std::string GetSubModuleName(SubModuleId module_id) {
}
std::string GetTimeString() {
constexpr auto BUFLEN = 80;
char buf[BUFLEN] = {'\0'};
#if defined(_WIN32) || defined(_WIN64)
time_t time_seconds = time(0);
struct tm now_time;
localtime_s(&now_time, &time_seconds);
constexpr int base_year = 1900;
(void)snprintf(buf, BUFLEN, "%d-%d-%d %d:%d:%d", now_time.tm_year + base_year, now_time.tm_mon + 1, now_time.tm_mday,
now_time.tm_hour, now_time.tm_min, now_time.tm_sec);
std::stringstream ss;
ss << now_time.tm_year + base_year << "-" << now_time.tm_mon + 1 << "-" << now_time.tm_mday << " " << now_time.tm_hour
<< ":" << now_time.tm_min << ":" << now_time.tm_sec;
return ss.str();
#else
constexpr auto BUFLEN = 80;
char buf[BUFLEN] = {'\0'};
struct timeval cur_time;
(void)gettimeofday(&cur_time, nullptr);
struct tm now;
constexpr size_t time_str_len = 19;
constexpr int width = 3;
constexpr int64_t time_convert_unit = 1000;
(void)localtime_r(&cur_time.tv_sec, &now);
(void)strftime(buf, BUFLEN, "%Y-%m-%d-%H:%M:%S", &now); // format date and time
#ifdef __APPLE__
constexpr auto fmt_str = ".%03lld.%03lld";
#else
constexpr auto fmt_str = ".%03ld.%03ld";
std::stringstream ss;
ss << "." << std::setfill('0') << std::setw(width) << cur_time.tv_usec / time_convert_unit << "." << std::setfill('0')
<< std::setw(width) << cur_time.tv_usec % time_convert_unit;
return std::string(buf) + ss.str();
#endif
(void)snprintf(buf + time_str_len, BUFLEN - time_str_len, fmt_str, cur_time.tv_usec / time_convert_unit,
cur_time.tv_usec % time_convert_unit);
#endif
return std::string(buf);
}
} // namespace mindspore

View File

@ -162,7 +162,8 @@ std::string FlagParser::Usage(const Option<std::string> &usgMsg) const {
std::string flagName = flag->second.flagName;
std::string helpInfo = flag->second.helpInfo;
// parameter line
std::string thisLine = flagName == "help" ? " --" + flagName : " --" + flagName + "=VALUE";
std::string thisLine =
(flagName == helpStr || flagName == versionStr) ? " --" + flagName : " --" + flagName + "=VALUE";
if (++i <= flags.size()) {
// add parameter help message of each line
thisLine += " " + helpInfo;

View File

@ -30,7 +30,10 @@ struct Nothing {};
class FlagParser {
public:
FlagParser() { AddFlag(&FlagParser::help, helpStr, "print usage message", ""); }
FlagParser() {
AddFlag(&FlagParser::help, helpStr, "print usage message", "");
AddFlag(&FlagParser::version, versionStr, "print version", "");
}
virtual ~FlagParser() = default;
@ -59,6 +62,7 @@ class FlagParser {
template <typename Flags, typename T>
void AddFlag(Option<T> Flags::*t, const std::string &flagName, const std::string &helpInfo);
bool help{};
bool version{};
protected:
template <typename Flags>
@ -69,6 +73,7 @@ class FlagParser {
std::string binName;
Option<std::string> usageMsg;
std::string helpStr = "help";
std::string versionStr = "version";
private:
struct FlagInfo {

View File

@ -39,12 +39,12 @@ build_option_proc_s()
{
check_on_off $OPTARG s
if [[ "X$OPTARG" == "Xon" ]]; then
if [[ $USER_ENABLE_DUMP_IR == true ]]; then
if [[ "$USER_ENABLE_DUMP_IR" == true ]]; then
echo "enable security, the dump ir is not available"
usage
exit 1
fi
if [[ $USER_ENABLE_DEBUGGER == true ]]; then
if [[ "$USER_ENABLE_DEBUGGER" == true ]]; then
echo "enable security, the debugger is not available"
usage
exit 1

View File

@ -101,7 +101,7 @@ set +e
# check format of files modified in the latest commit
while read line; do
if [ ! -e ${line} ]; then
if [ ! -e "${line}" ]; then
continue
fi
BASE_NAME=$(basename "${line}")

View File

@ -1,4 +1,20 @@
#!/bin/bash
# Copyright 2021-2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
set -e
SCRIPT_DIR=$(dirname "$0")
MS_DIR=$(realpath ${SCRIPT_DIR}/..)
@ -22,7 +38,7 @@ if [[ "$line" =~ .*\((.*)\,(.*)\).* ]]
then
CLASS_NAME=${BASH_REMATCH[2]}_${BASH_REMATCH[1]}
TID=$(${HASH_EXE} ${CLASS_NAME})
if [ ${TIDMAP[${TID}]+_} ]; then
if [ ${TIDMAP["${TID}"]+_} ]; then
echo $line
echo Same tid $TID is used by $CLASS_NAME and ${TIDMAP[${TID}]}.
exit 1

View File

@ -22,14 +22,14 @@ function android_release_package()
device=$2
pkg_name="mindspore-lite-${version}-android-${arch}"
rm -rf ${pkg_name}
[ -n "${pkg_name}" ] && rm -rf ${pkg_name}
tar -xzf ${input_path}/android_${arch}/${device}/${pkg_name}.tar.gz
# Copy java runtime to Android package
cp ${input_path}/aar/mindspore-lite-*.aar ${pkg_name}
mkdir -p ${output_path}/release/android/${device}/
tar -czf ${output_path}/release/android/${device}/${pkg_name}.tar.gz ${pkg_name}
rm -rf ${pkg_name}
[ -n "${pkg_name}" ] && rm -rf ${pkg_name}
cd ${output_path}/release/android/${device}/
sha256sum ${pkg_name}.tar.gz > ${pkg_name}.tar.gz.sha256
}
@ -90,7 +90,7 @@ echo "Usage: bash lite_release_package.sh input_path output_path"
input_path=$1
output_path=$2
version=`ls ${input_path}/android_aarch64/npu/mindspore-lite-*-*.tar.gz | awk -F'/' '{print $NF}' | cut -d"-" -f3`
version=$(ls ${input_path}/android_aarch64/npu/mindspore-lite-*-*.tar.gz | awk -F'/' '{print $NF}' | cut -d"-" -f3)
android_release_package aarch32 npu
android_release_package aarch32 cpu