forked from mindspore-Ecosystem/mindspore
fix some bugs
This commit is contained in:
parent
ca371e1531
commit
37b69b8737
|
@ -680,33 +680,31 @@ const std::string GetSubModuleName(SubModuleId module_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetTimeString() {
|
std::string GetTimeString() {
|
||||||
constexpr auto BUFLEN = 80;
|
|
||||||
char buf[BUFLEN] = {'\0'};
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
time_t time_seconds = time(0);
|
time_t time_seconds = time(0);
|
||||||
struct tm now_time;
|
struct tm now_time;
|
||||||
localtime_s(&now_time, &time_seconds);
|
localtime_s(&now_time, &time_seconds);
|
||||||
constexpr int base_year = 1900;
|
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,
|
std::stringstream ss;
|
||||||
now_time.tm_hour, now_time.tm_min, now_time.tm_sec);
|
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
|
#else
|
||||||
|
constexpr auto BUFLEN = 80;
|
||||||
|
char buf[BUFLEN] = {'\0'};
|
||||||
struct timeval cur_time;
|
struct timeval cur_time;
|
||||||
(void)gettimeofday(&cur_time, nullptr);
|
(void)gettimeofday(&cur_time, nullptr);
|
||||||
|
|
||||||
struct tm now;
|
struct tm now;
|
||||||
constexpr size_t time_str_len = 19;
|
constexpr int width = 3;
|
||||||
constexpr int64_t time_convert_unit = 1000;
|
constexpr int64_t time_convert_unit = 1000;
|
||||||
(void)localtime_r(&cur_time.tv_sec, &now);
|
(void)localtime_r(&cur_time.tv_sec, &now);
|
||||||
(void)strftime(buf, BUFLEN, "%Y-%m-%d-%H:%M:%S", &now); // format date and time
|
(void)strftime(buf, BUFLEN, "%Y-%m-%d-%H:%M:%S", &now); // format date and time
|
||||||
#ifdef __APPLE__
|
std::stringstream ss;
|
||||||
constexpr auto fmt_str = ".%03lld.%03lld";
|
ss << "." << std::setfill('0') << std::setw(width) << cur_time.tv_usec / time_convert_unit << "." << std::setfill('0')
|
||||||
#else
|
<< std::setw(width) << cur_time.tv_usec % time_convert_unit;
|
||||||
constexpr auto fmt_str = ".%03ld.%03ld";
|
return std::string(buf) + ss.str();
|
||||||
#endif
|
#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
|
} // namespace mindspore
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,8 @@ std::string FlagParser::Usage(const Option<std::string> &usgMsg) const {
|
||||||
std::string flagName = flag->second.flagName;
|
std::string flagName = flag->second.flagName;
|
||||||
std::string helpInfo = flag->second.helpInfo;
|
std::string helpInfo = flag->second.helpInfo;
|
||||||
// parameter line
|
// parameter line
|
||||||
std::string thisLine = flagName == "help" ? " --" + flagName : " --" + flagName + "=VALUE";
|
std::string thisLine =
|
||||||
|
(flagName == helpStr || flagName == versionStr) ? " --" + flagName : " --" + flagName + "=VALUE";
|
||||||
if (++i <= flags.size()) {
|
if (++i <= flags.size()) {
|
||||||
// add parameter help message of each line
|
// add parameter help message of each line
|
||||||
thisLine += " " + helpInfo;
|
thisLine += " " + helpInfo;
|
||||||
|
|
|
@ -30,7 +30,10 @@ struct Nothing {};
|
||||||
|
|
||||||
class FlagParser {
|
class FlagParser {
|
||||||
public:
|
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;
|
virtual ~FlagParser() = default;
|
||||||
|
|
||||||
|
@ -59,6 +62,7 @@ class FlagParser {
|
||||||
template <typename Flags, typename T>
|
template <typename Flags, typename T>
|
||||||
void AddFlag(Option<T> Flags::*t, const std::string &flagName, const std::string &helpInfo);
|
void AddFlag(Option<T> Flags::*t, const std::string &flagName, const std::string &helpInfo);
|
||||||
bool help{};
|
bool help{};
|
||||||
|
bool version{};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template <typename Flags>
|
template <typename Flags>
|
||||||
|
@ -69,6 +73,7 @@ class FlagParser {
|
||||||
std::string binName;
|
std::string binName;
|
||||||
Option<std::string> usageMsg;
|
Option<std::string> usageMsg;
|
||||||
std::string helpStr = "help";
|
std::string helpStr = "help";
|
||||||
|
std::string versionStr = "version";
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct FlagInfo {
|
struct FlagInfo {
|
||||||
|
|
|
@ -39,12 +39,12 @@ build_option_proc_s()
|
||||||
{
|
{
|
||||||
check_on_off $OPTARG s
|
check_on_off $OPTARG s
|
||||||
if [[ "X$OPTARG" == "Xon" ]]; then
|
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"
|
echo "enable security, the dump ir is not available"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ $USER_ENABLE_DEBUGGER == true ]]; then
|
if [[ "$USER_ENABLE_DEBUGGER" == true ]]; then
|
||||||
echo "enable security, the debugger is not available"
|
echo "enable security, the debugger is not available"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -101,7 +101,7 @@ set +e
|
||||||
|
|
||||||
# check format of files modified in the latest commit
|
# check format of files modified in the latest commit
|
||||||
while read line; do
|
while read line; do
|
||||||
if [ ! -e ${line} ]; then
|
if [ ! -e "${line}" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
BASE_NAME=$(basename "${line}")
|
BASE_NAME=$(basename "${line}")
|
||||||
|
|
|
@ -1,4 +1,20 @@
|
||||||
#!/bin/bash
|
#!/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")
|
SCRIPT_DIR=$(dirname "$0")
|
||||||
MS_DIR=$(realpath ${SCRIPT_DIR}/..)
|
MS_DIR=$(realpath ${SCRIPT_DIR}/..)
|
||||||
|
@ -22,7 +38,7 @@ if [[ "$line" =~ .*\((.*)\,(.*)\).* ]]
|
||||||
then
|
then
|
||||||
CLASS_NAME=${BASH_REMATCH[2]}_${BASH_REMATCH[1]}
|
CLASS_NAME=${BASH_REMATCH[2]}_${BASH_REMATCH[1]}
|
||||||
TID=$(${HASH_EXE} ${CLASS_NAME})
|
TID=$(${HASH_EXE} ${CLASS_NAME})
|
||||||
if [ ${TIDMAP[${TID}]+_} ]; then
|
if [ ${TIDMAP["${TID}"]+_} ]; then
|
||||||
echo $line
|
echo $line
|
||||||
echo Same tid $TID is used by $CLASS_NAME and ${TIDMAP[${TID}]}.
|
echo Same tid $TID is used by $CLASS_NAME and ${TIDMAP[${TID}]}.
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -22,14 +22,14 @@ function android_release_package()
|
||||||
device=$2
|
device=$2
|
||||||
pkg_name="mindspore-lite-${version}-android-${arch}"
|
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
|
tar -xzf ${input_path}/android_${arch}/${device}/${pkg_name}.tar.gz
|
||||||
# Copy java runtime to Android package
|
# Copy java runtime to Android package
|
||||||
cp ${input_path}/aar/mindspore-lite-*.aar ${pkg_name}
|
cp ${input_path}/aar/mindspore-lite-*.aar ${pkg_name}
|
||||||
|
|
||||||
mkdir -p ${output_path}/release/android/${device}/
|
mkdir -p ${output_path}/release/android/${device}/
|
||||||
tar -czf ${output_path}/release/android/${device}/${pkg_name}.tar.gz ${pkg_name}
|
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}/
|
cd ${output_path}/release/android/${device}/
|
||||||
sha256sum ${pkg_name}.tar.gz > ${pkg_name}.tar.gz.sha256
|
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
|
input_path=$1
|
||||||
output_path=$2
|
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 npu
|
||||||
android_release_package aarch32 cpu
|
android_release_package aarch32 cpu
|
||||||
|
|
Loading…
Reference in New Issue