forked from mindspore-Ecosystem/mindspore
Migration directory
This commit is contained in:
parent
8903571af3
commit
7f1e14ff72
|
@ -6,7 +6,7 @@
|
|||
mindspore/mindspore/lite/src/ops/primitive_c.cc:mindspore::lite::PrimitiveC::Create
|
||||
mindspore/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/csv_op.cc:mindspore::dataset::CsvOp::CsvParser::InitCsvParser
|
||||
mindspore/mindspore/lite/tools/converter/graphdef_transform.cc:mindspore::lite::GraphDefTransform::Transform
|
||||
mindspore/mindspore/lite/tools/benchmark/nnie_proposal/src/proposal.cc:mindspore::proposal::Rpn
|
||||
mindspore/mindspore/lite/providers/nnie_proposal/src/proposal.cc:mindspore::proposal::Rpn
|
||||
mindspore/mindspore/core/abstract/primitive_infer_map.cc:mindspore::abstract::GetPrimitiveToEvalImplMap
|
||||
mindspore/mindspore/ccsrc/frontend/optimizer/irpass.cc:mindspore::opt::irpass::OptimizeIRPassLib::OptimizeIRPassLib
|
||||
mindspore/mindspore/ccsrc/frontend/parallel/ops_info/gather_v2_p_info.cc:mindspore::parallel::GatherV2PInfo::CheckStrategy
|
||||
|
|
|
@ -493,7 +493,7 @@ elseif(PLATFORM_ARM32)
|
|||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
if(${MSLITE_REGISTRY_DEVICE} STREQUAL "Hi3516D")
|
||||
install(FILES
|
||||
${TOP_DIR}/mindspore/lite/tools/benchmark/nnie/third_patry/${MICRO_NNIE_LIB_NAME}.so
|
||||
${TOP_DIR}/mindspore/lite/providers/nnie/third_patry/${MICRO_NNIE_LIB_NAME}.so
|
||||
DESTINATION ${PROVIDERS_LIB_DIR}/${MSLITE_REGISTRY_DEVICE}
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
|
|
|
@ -30,7 +30,7 @@ check_Hi35xx() {
|
|||
echo "error: to compile the runtime package of Hi35XX, you need to set HI35XX_SDK_PATH to declare the path of Hi35XX sdk."
|
||||
exit 1
|
||||
else
|
||||
cp -r ${HI35XX_SDK_PATH}/third_patry ${BASEPATH}/mindspore/lite/tools/benchmark/nnie/
|
||||
cp -r ${HI35XX_SDK_PATH}/third_patry ${BASEPATH}/mindspore/lite/providers/nnie
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -51,12 +51,12 @@ build_lite_x86_64_jni_and_jar() {
|
|||
export MSLITE_ENABLE_RUNTIME_CONVERT=off
|
||||
# copy x86 so
|
||||
local is_train=on
|
||||
cd ${BASEPATH}/output/tmp
|
||||
cd ${INSTALL_PREFIX}/
|
||||
local pkg_name=mindspore-lite-${VERSION_STR}-linux-x64
|
||||
|
||||
cd ${BASEPATH}/output/tmp/
|
||||
cd ${INSTALL_PREFIX}/
|
||||
rm -rf ${pkg_name}
|
||||
tar -zxf ${BASEPATH}/output/tmp/${pkg_name}.tar.gz
|
||||
tar -zxf ${INSTALL_PREFIX}/${pkg_name}.tar.gz
|
||||
rm -rf ${LITE_JAVA_PATH}/java/linux_x86/libs/ && mkdir -pv ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
rm -rf ${LITE_JAVA_PATH}/native/libs/linux_x86/ && mkdir -pv ${LITE_JAVA_PATH}/native/libs/linux_x86/
|
||||
cp ./${pkg_name}/runtime/lib/*.so* ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
|
@ -82,11 +82,11 @@ build_lite_x86_64_jni_and_jar() {
|
|||
fi
|
||||
cp ./libmindspore-lite-jni.so ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ./libmindspore-lite-jni.so ${LITE_JAVA_PATH}/native/libs/linux_x86/
|
||||
cp ./libmindspore-lite-jni.so ${BASEPATH}/output/tmp/${pkg_name}/runtime/lib/
|
||||
cp ./libmindspore-lite-jni.so ${INSTALL_PREFIX}/${pkg_name}/runtime/lib/
|
||||
if [[ "X$is_train" = "Xon" ]]; then
|
||||
cp ./libmindspore-lite-train-jni.so ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ./libmindspore-lite-train-jni.so ${LITE_JAVA_PATH}/native/libs/linux_x86/
|
||||
cp ./libmindspore-lite-train-jni.so ${BASEPATH}/output/tmp/${pkg_name}/runtime/lib/
|
||||
cp ./libmindspore-lite-train-jni.so ${INSTALL_PREFIX}/${pkg_name}/runtime/lib/
|
||||
fi
|
||||
|
||||
cd ${LITE_JAVA_PATH}/java
|
||||
|
@ -110,7 +110,7 @@ build_lite_x86_64_jni_and_jar() {
|
|||
${gradle_command} build -p ${LITE_JAVA_PATH}/java/fl_client
|
||||
${gradle_command} clearJar -p ${LITE_JAVA_PATH}/java/fl_client
|
||||
${gradle_command} flReleaseJarX86 --rerun-tasks -p ${LITE_JAVA_PATH}/java/fl_client
|
||||
cp ${LITE_JAVA_PATH}/java/fl_client/build/libs/jarX86/mindspore-lite-java-flclient.jar ${BASEPATH}/output/tmp/${pkg_name}/runtime/lib/
|
||||
cp ${LITE_JAVA_PATH}/java/fl_client/build/libs/jarX86/mindspore-lite-java-flclient.jar ${INSTALL_PREFIX}/${pkg_name}/runtime/lib/
|
||||
rm -rf ${LITE_JAVA_PATH}/java/fl_client/.gradle ${LITE_JAVA_PATH}/java/fl_client/src/main/java/mindspore
|
||||
fi
|
||||
|
||||
|
@ -126,10 +126,10 @@ build_lite_x86_64_jni_and_jar() {
|
|||
${gradle_command} releaseJar -p ${LITE_JAVA_PATH}/ -x test
|
||||
fi
|
||||
fi
|
||||
cp ${LITE_JAVA_PATH}/build/lib/jar/*.jar ${BASEPATH}/output/tmp/${pkg_name}/runtime/lib/
|
||||
cp ${LITE_JAVA_PATH}/build/lib/jar/*.jar ${INSTALL_PREFIX}/${pkg_name}/runtime/lib/
|
||||
|
||||
# package
|
||||
cd ${BASEPATH}/output/tmp
|
||||
cd ${INSTALL_PREFIX}
|
||||
rm -rf ${pkg_name}.tar.gz ${pkg_name}.tar.gz.sha256
|
||||
tar czf ${pkg_name}.tar.gz ${pkg_name}
|
||||
sha256sum ${pkg_name}.tar.gz > ${pkg_name}.tar.gz.sha256
|
||||
|
@ -156,7 +156,7 @@ build_lite() {
|
|||
cd ${BASEPATH}/mindspore/lite/build
|
||||
write_commit_file
|
||||
|
||||
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp"
|
||||
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}"
|
||||
|
||||
if [[ "$(uname)" == "Darwin" && "${local_lite_platform}" != "x86_64" ]]; then
|
||||
LITE_CMAKE_ARGS=`echo $LITE_CMAKE_ARGS | sed 's/-DCMAKE_BUILD_TYPE=Debug/-DCMAKE_BUILD_TYPE=Release/g'`
|
||||
|
@ -289,7 +289,7 @@ build_lite() {
|
|||
fi
|
||||
if [[ "X$MSLITE_ENABLE_TOOLS" != "XOFF" ]]; then
|
||||
LITE_CMAKE_ARGS=`echo $LITE_CMAKE_ARGS | sed 's/-DMSLITE_COMPILE_TWICE=ON/-DMSLITE_COMPILE_TWICE=OFF/g'`
|
||||
cp -r ${BASEPATH}/output/tmp/mindspore*/runtime ${BASEPATH}/mindspore/lite/tools/benchmark
|
||||
cp -r ${INSTALL_PREFIX}/mindspore*/runtime ${BASEPATH}/mindspore/lite/providers
|
||||
echo "cmake ${LITE_CMAKE_ARGS} ${BASEPATH}/mindspore/lite"
|
||||
cmake ${LITE_CMAKE_ARGS} "${BASEPATH}/mindspore/lite"
|
||||
cmake --build "${BASEPATH}/mindspore/lite/build" --target benchmark -j$THREAD_NUM
|
||||
|
@ -327,23 +327,23 @@ build_lite() {
|
|||
sha256sum ${pkg_name}.tar.gz > ${pkg_name}.tar.gz.sha256
|
||||
rm -r mindspore-lite.framework
|
||||
else
|
||||
mv ${BASEPATH}/output/tmp/*.tar.gz* ${BASEPATH}/output/
|
||||
mv ${INSTALL_PREFIX}/*.tar.gz* ${BASEPATH}/output/
|
||||
fi
|
||||
|
||||
if [[ "${local_lite_platform}" == "x86_64" ]]; then
|
||||
if [[ "${MSLITE_ENABLE_TESTCASES}" == "ON" || "${MSLITE_ENABLE_TESTCASES}" == "on" ]]; then
|
||||
mkdir -pv ${BASEPATH}/mindspore/lite/test/do_test || true
|
||||
if [[ ! "${MSLITE_ENABLE_CONVERTER}" || "${MSLITE_ENABLE_CONVERTER}" == "ON" || "${MSLITE_ENABLE_CONVERTER}" == "on" ]]; then
|
||||
cp ${BASEPATH}/output/tmp/mindspore-lite*/tools/converter/lib/*.so* ${BASEPATH}/mindspore/lite/test/do_test || true
|
||||
cp ${INSTALL_PREFIX}/mindspore-lite*/tools/converter/lib/*.so* ${BASEPATH}/mindspore/lite/test/do_test || true
|
||||
fi
|
||||
cp ${BASEPATH}/output/tmp/mindspore-lite*/runtime/lib/*.so* ${BASEPATH}/mindspore/lite/test/do_test || true
|
||||
cp ${INSTALL_PREFIX}/mindspore-lite*/runtime/lib/*.so* ${BASEPATH}/mindspore/lite/test/do_test || true
|
||||
if [[ ! "${MSLITE_ENABLE_TRAIN}" || "${MSLITE_ENABLE_TRAIN}" == "ON" || "${MSLITE_ENABLE_TRAIN}" == "on" ]]; then
|
||||
cp ${BASEPATH}/output/tmp/mindspore-lite*/runtime/third_party/libjpeg-turbo/lib/*.so* ${BASEPATH}/mindspore/lite/test/do_test || true
|
||||
cp ${INSTALL_PREFIX}/mindspore-lite*/runtime/third_party/libjpeg-turbo/lib/*.so* ${BASEPATH}/mindspore/lite/test/do_test || true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/output/tmp/
|
||||
rm -rf ${INSTALL_PREFIX:?}/
|
||||
if [[ "X$MSLITE_REGISTRY_DEVICE" != "X" ]] && [[ "${MSLITE_REGISTRY_DEVICE}" != "SD3403" ]]; then
|
||||
local compile_nnie_script=${BASEPATH}/mindspore/lite/tools/providers/NNIE/Hi3516D/compile_nnie.sh
|
||||
cd ${BASEPATH}/../
|
||||
|
@ -520,6 +520,7 @@ update_submodule()
|
|||
git submodule update --init metadef
|
||||
}
|
||||
|
||||
INSTALL_PREFIX=${BASEPATH}/output/tmp
|
||||
LITE_JAVA_PATH=${BASEPATH}/mindspore/lite/java
|
||||
if [[ "${MSLITE_ENABLE_ACL}" == "on" ]]; then
|
||||
update_submodule
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
approvers:
|
||||
- jpc_chenjianping
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(DPICO_Custom)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../../../cmake/utils.cmake)
|
||||
include(${TOP_DIR}/cmake/utils.cmake)
|
||||
|
||||
if(DEFINED ENV{HISI_SDK_PATH})
|
||||
set(SD3403_SDK_PATH $ENV{HISI_SDK_PATH}/sd3403_sdk/dpico_acl_adapter/3403_sdk)
|
||||
|
@ -11,9 +11,9 @@ endif()
|
|||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${SD3403_SDK_PATH})
|
||||
include_directories(${SD3403_SDK_PATH}/include)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/runtime)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/runtime/include)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/runtime/include/third_party)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../runtime)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../runtime/include)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../runtime/include/third_party)
|
||||
link_directories(${SD3403_SDK_PATH}/lib)
|
||||
|
||||
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src COMMON_SRC)
|
|
@ -25,13 +25,3 @@ add_library(mslite_nnie SHARED
|
|||
${COMMON_SRC3})
|
||||
target_link_libraries(mslite_nnie ${MSLITE_NNIE_LINK_LIB} securec)
|
||||
|
||||
if(DEFINED HIMIX_STRIP)
|
||||
set(NDK_STRIP ${HIMIX_STRIP})
|
||||
else()
|
||||
set(NDK_STRIP "arm-himix200-linux-strip")
|
||||
endif()
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
||||
add_custom_command(TARGET mslite_nnie POST_BUILD COMMAND ${NDK_STRIP}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libmslite_nnie.so)
|
||||
endif()
|
|
@ -37,15 +37,19 @@ bool CustomCPUKernel::roi_used_ = false;
|
|||
int CustomCPUKernel::Prepare() {
|
||||
if (!load_model_) {
|
||||
Flags flags;
|
||||
flags.Init();
|
||||
if (flags.Init(*this) != RET_OK) {
|
||||
LOGE("Nnie config init fail.");
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
if (nnie::NNIEManager::GetInstance()->CfgInit(flags.max_roi_num_, flags.time_step_, flags.core_ids_) != RET_OK) {
|
||||
LOGE("Nnie init cfg fail");
|
||||
LOGE("Nnie init cfg fail.");
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
if (nnie::NNIEManager::GetInstance()->Init(reinterpret_cast<char *>(inputs_[inputs_.size() - 1].MutableData()),
|
||||
static_cast<int>(inputs_[inputs_.size() - 1].ElementNum()), inputs_)) {
|
||||
LOGI("Load WK Model Fail");
|
||||
LOGI("Load WK Model Fail.");
|
||||
return RET_OK;
|
||||
}
|
||||
load_model_ = true;
|
||||
|
@ -74,12 +78,12 @@ int CustomCPUKernel::Execute() {
|
|||
run_seg_ = seg_id_;
|
||||
|
||||
if (nnie::NNIEManager::GetInstance()->FillData(&inputs_, run_seg_) != RET_OK) {
|
||||
LOGE("Fail Fill Data");
|
||||
LOGE("Fail Fill Data.");
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
if (nnie::NNIEManager::GetInstance()->Run(&outputs_, run_seg_, outputs_shapes_) != RET_OK) {
|
||||
LOGE("Fail WK Run");
|
||||
LOGE("Fail WK Run.");
|
||||
return RET_ERROR;
|
||||
}
|
||||
run_seg_++;
|
||||
|
@ -100,7 +104,7 @@ bool GetCustomAttr(char *buf, int buf_size, const mindspore::schema::Custom *op,
|
|||
auto output_info = op->attr()->Get(i)->data();
|
||||
attr_size = static_cast<int>(output_info->size());
|
||||
if (attr_size >= buf_size) {
|
||||
LOGE("attr size too big");
|
||||
LOGE("attr size too big.");
|
||||
return false;
|
||||
}
|
||||
for (int j = 0; j < attr_size; j++) {
|
||||
|
@ -118,13 +122,13 @@ std::shared_ptr<mindspore::kernel::Kernel> CustomCreateKernel(const std::vector<
|
|||
const mindspore::schema::Primitive *primitive,
|
||||
const mindspore::Context *ctx) {
|
||||
if (primitive->value_type() != mindspore::schema::PrimitiveType_Custom) {
|
||||
LOGE("Primitive type is not PrimitiveType_Custom");
|
||||
LOGE("Primitive type is not PrimitiveType_Custom.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto op = primitive->value_as_Custom();
|
||||
if (op->attr()->size() < 1) {
|
||||
LOGE("There are at least 1 attribute of Custom");
|
||||
LOGE("There are at least 1 attribute of Custom.");
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
* Copyright 2021 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.
|
||||
*/
|
||||
#include "src/nnie_cfg_parser.h"
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "include/errorcode.h"
|
||||
#include "src/nnie_manager.h"
|
||||
#include "src/nnie_print.h"
|
||||
|
||||
using mindspore::lite::RET_ERROR;
|
||||
using mindspore::lite::RET_OK;
|
||||
namespace mindspore {
|
||||
namespace nnie {
|
||||
namespace {
|
||||
constexpr auto kTimeStep = "TimeStep";
|
||||
constexpr auto kMazRoiNum = "MaxROINum";
|
||||
constexpr auto kCoreIds = "CoreIds";
|
||||
constexpr auto DELIM = ",";
|
||||
constexpr int MAX_CORE_ID = 7;
|
||||
} // namespace
|
||||
bool IsValidUnsignedNum(const std::string &num_str) {
|
||||
return !num_str.empty() && std::all_of(num_str.begin(), num_str.end(), ::isdigit);
|
||||
}
|
||||
|
||||
void PrintInvalidChar(const std::string &key, const std::string &dat) {
|
||||
auto message = key + " configuration contains invalid characters: \'" + dat + "\'";
|
||||
LOGE(message.c_str());
|
||||
}
|
||||
|
||||
int Flags::Init(const kernel::Kernel &kernel) {
|
||||
auto nnie_arg = kernel.GetConfig("nnie");
|
||||
if (nnie_arg.find(kTimeStep) != nnie_arg.end()) {
|
||||
if (IsValidUnsignedNum(nnie_arg.at(kTimeStep)) == true) {
|
||||
this->time_step_ = stoi(nnie_arg.at(kTimeStep));
|
||||
} else {
|
||||
PrintInvalidChar(kTimeStep, nnie_arg.at(kTimeStep));
|
||||
return RET_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (nnie_arg.find(kMazRoiNum) != nnie_arg.end()) {
|
||||
if (IsValidUnsignedNum(nnie_arg.at(kMazRoiNum)) == true) {
|
||||
this->max_roi_num_ = stoi(nnie_arg.at(kMazRoiNum));
|
||||
} else {
|
||||
PrintInvalidChar(kMazRoiNum, nnie_arg.at(kMazRoiNum));
|
||||
return RET_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (nnie_arg.find(kCoreIds) != nnie_arg.end()) {
|
||||
auto ids = nnie_arg.at(kCoreIds);
|
||||
if (!ids.empty() && std::all_of(ids.begin(), ids.end(), [](char val) { return ::isdigit(val) || val == ','; })) {
|
||||
size_t index = 0;
|
||||
std::vector<int> core_ids;
|
||||
while (!ids.empty()) {
|
||||
core_ids.push_back(std::stoi(ids, &index));
|
||||
if (index < ids.length()) {
|
||||
ids = ids.substr(index + 1);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->core_ids_ = core_ids;
|
||||
} else {
|
||||
PrintInvalidChar(kCoreIds, ids);
|
||||
return RET_ERROR;
|
||||
}
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
} // namespace nnie
|
||||
} // namespace mindspore
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef MINDSPORE_LITE_TOOLS_BENCHMARK_NNIE_NNIE_CFG_PARSER_H_
|
||||
#define MINDSPORE_LITE_TOOLS_BENCHMARK_NNIE_NNIE_CFG_PARSER_H_
|
||||
#include <vector>
|
||||
#include "include/api/kernel.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace nnie {
|
||||
|
@ -32,7 +33,7 @@ class Flags {
|
|||
public:
|
||||
Flags() = default;
|
||||
~Flags() = default;
|
||||
void Init();
|
||||
int Init(const kernel::Kernel &kernel);
|
||||
|
||||
public:
|
||||
int time_step_{1};
|
|
@ -31,6 +31,16 @@ int NNIEManager::CfgInit(int max_roi_num, int step, const std::vector<int> &core
|
|||
nnie_cfg_.cfg_.max_roi_num_ = max_roi_num;
|
||||
|
||||
nnie_cfg_.cfg_.step_ = step;
|
||||
if (core_id.size() == 1) {
|
||||
for (size_t i = 0; i < SVP_NNIE_MAX_NET_SEG_NUM; i++) {
|
||||
if (core_id[0] < SVP_NNIE_ID_BUTT) {
|
||||
nnie_cfg_.cfg_.nnie_core_id_[i] = (SVP_NNIE_ID_E)core_id[0];
|
||||
} else {
|
||||
LOGE("nnie core num toobig.\n");
|
||||
return RET_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < SVP_NNIE_MAX_NET_SEG_NUM && i < core_id.size(); i++) {
|
||||
if (core_id[i] < SVP_NNIE_ID_BUTT) {
|
||||
nnie_cfg_.cfg_.nnie_core_id_[i] = (SVP_NNIE_ID_E)core_id[i];
|
|
@ -9,14 +9,3 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src COMMON_SRC3)
|
|||
|
||||
add_library(mslite_proposal SHARED ${COMMON_SRC3})
|
||||
target_link_libraries(mslite_proposal ${LINK_LOCAT_LIB})
|
||||
|
||||
if(DEFINED HIMIX_STRIP)
|
||||
set(NDK_STRIP ${HIMIX_STRIP})
|
||||
else()
|
||||
set(NDK_STRIP "arm-himix200-linux-strip")
|
||||
endif()
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
||||
add_custom_command(TARGET mslite_proposal POST_BUILD COMMAND ${NDK_STRIP}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libmslite_proposal.so)
|
||||
endif()
|
|
@ -17,6 +17,7 @@
|
|||
#include "src/proposal_fp32.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include "schema/model_generated.h"
|
||||
#include "include/registry/register_kernel.h"
|
||||
#include "include/errorcode.h"
|
||||
|
@ -27,9 +28,19 @@ using mindspore::schema::PrimitiveType_Custom;
|
|||
constexpr int kMaxSize = 1024;
|
||||
constexpr int kNumInput2 = 2;
|
||||
constexpr int kDecimal = 10;
|
||||
constexpr auto kMazRoiNum = "MaxROINum";
|
||||
|
||||
namespace mindspore {
|
||||
namespace proposal {
|
||||
bool IsValidUnsignedNum(const std::string &num_str) {
|
||||
return !num_str.empty() && std::all_of(num_str.begin(), num_str.end(), ::isdigit);
|
||||
}
|
||||
|
||||
void PrintInvalidChar(const std::string &key, const std::string &dat) {
|
||||
auto message = key + " configuration contains invalid characters: \'" + dat + "\'";
|
||||
LOGE(message.c_str());
|
||||
}
|
||||
|
||||
int ProposalCPUKernel::Prepare() {
|
||||
if (inputs_.size() < kNumInput2) {
|
||||
LOGE("inputs tensor num error.");
|
||||
|
@ -74,18 +85,14 @@ int ProposalCPUKernel::Prepare() {
|
|||
outputs_[0].SetTensorName("proposal");
|
||||
|
||||
int max_roi_num_int = 300;
|
||||
auto *max_roi_num = std::getenv("MAX_ROI_NUM");
|
||||
if (max_roi_num != nullptr) {
|
||||
auto iter =
|
||||
std::find_if(max_roi_num, max_roi_num + strlen(max_roi_num), [](char val) { return val < '0' || val > '9'; });
|
||||
if (iter != max_roi_num) {
|
||||
*iter = '\0';
|
||||
max_roi_num_int = atoi(max_roi_num);
|
||||
auto nnie_arg = GetConfig("nnie");
|
||||
if (nnie_arg.find(kMazRoiNum) != nnie_arg.end()) {
|
||||
if (IsValidUnsignedNum(nnie_arg.at(kMazRoiNum)) == true) {
|
||||
max_roi_num_int = stoi(nnie_arg.at(kMazRoiNum));
|
||||
} else {
|
||||
LOGW("MAX_ROI_NUM ENV is invalid, now set to default value %d", max_roi_num_int);
|
||||
PrintInvalidChar(kMazRoiNum, nnie_arg.at(kMazRoiNum));
|
||||
return RET_ERROR;
|
||||
}
|
||||
} else {
|
||||
LOGW("MAX_ROI_NUM ENV is not set, now set to default value %d", max_roi_num_int);
|
||||
}
|
||||
|
||||
return ProposalInit(&proposal_param_, inputs_, max_roi_num_int, image_height_, image_weight_);
|
|
@ -39,11 +39,13 @@ function Run_Hi3516() {
|
|||
else
|
||||
input_files=${basepath}/../input_output/input/${model_name}.ms.bin
|
||||
fi
|
||||
export TIME_STEP=${env_time_step}
|
||||
export MAX_ROI_NUM=${env_max_roi_num}
|
||||
NNIE_CONFIG_FILE=nnie_config_tmp.txt
|
||||
echo [nnie] > ${NNIE_CONFIG_FILE}
|
||||
echo TimeStep=${env_time_step} >> ${NNIE_CONFIG_FILE}
|
||||
echo MaxROINum=${env_max_roi_num} >> ${NNIE_CONFIG_FILE}
|
||||
|
||||
echo './benchmark --modelFile='${basepath}'/'${model_name}'.ms --inDataFile='${input_files}' --inputShapes='${input_shapes}' --benchmarkDataFile='${basepath}'/../input_output/output/'${model_name}'.ms.out --accuracyThreshold='${accuracy_limit} >> "${run_hi3516_log_file}"
|
||||
./benchmark --modelFile=${basepath}/${model_name}.ms --inDataFile=${input_files} --inputShapes=${input_shapes} --benchmarkDataFile=${basepath}/../input_output/output/${model_name}.ms.out --accuracyThreshold=${accuracy_limit} >> "${run_hi3516_log_file}"
|
||||
echo './benchmark --modelFile='${basepath}'/'${model_name}'.ms --inDataFile='${input_files}' --inputShapes='${input_shapes}' --benchmarkDataFile='${basepath}'/../input_output/output/'${model_name}'.ms.out --accuracyThreshold='${accuracy_limit}' --configFile='${NNIE_CONFIG_FILE} >> "${run_hi3516_log_file}"
|
||||
./benchmark --modelFile=${basepath}/${model_name}.ms --inDataFile=${input_files} --inputShapes=${input_shapes} --benchmarkDataFile=${basepath}/../input_output/output/${model_name}.ms.out --accuracyThreshold=${accuracy_limit} --configFile=${NNIE_CONFIG_FILE}>> "${run_hi3516_log_file}"
|
||||
if [ $? = 0 ]; then
|
||||
run_result='hi3516: '${model_name}' pass'; echo ${run_result} >> ${run_benchmark_result_file}
|
||||
else
|
||||
|
|
|
@ -2,23 +2,24 @@ cmake_minimum_required(VERSION 3.12)
|
|||
project(Lite_benchmark)
|
||||
|
||||
set(BENCHMARK_LINK_LIB mindspore-lite)
|
||||
set(PROVIDERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../providers)
|
||||
if(TARGET_HIMIX)
|
||||
add_subdirectory(nnie)
|
||||
add_subdirectory(nnie_proposal)
|
||||
add_subdirectory(${PROVIDERS_DIR}/nnie nnie)
|
||||
add_subdirectory(${PROVIDERS_DIR}/nnie_proposal nnie_proposal)
|
||||
set(CMAKE_SKIP_BUILD_RPATH on)
|
||||
set(BENCHMARK_LINK_LIB ${BENCHMARK_LINK_LIB} pthread
|
||||
mslite_proposal mslite_nnie dl nnie mpi VoiceEngine upvqe dnvqe securec)
|
||||
if(${MSLITE_REGISTRY_DEVICE} STREQUAL "Hi3516D")
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/nnie/third_patry/hi3516_sdk)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/nnie/third_patry/hi3516_sdk/lib)
|
||||
include_directories(${PROVIDERS_DIR}/nnie/third_patry/hi3516_sdk)
|
||||
link_directories(${PROVIDERS_DIR}/nnie/third_patry/hi3516_sdk/lib)
|
||||
set(BENCHMARK_LINK_LIB ${BENCHMARK_LINK_LIB} mindspore::json)
|
||||
elseif(${MSLITE_REGISTRY_DEVICE} STREQUAL "Hi3519A")
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/nnie/third_patry/hi3519_sdk)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/nnie/third_patry/hi3519_sdk/lib)
|
||||
include_directories(${PROVIDERS_DIR}/nnie/third_patry/hi3519_sdk)
|
||||
link_directories(${PROVIDERS_DIR}/nnie/third_patry/hi3519_sdk/lib)
|
||||
set(BENCHMARK_LINK_LIB ${BENCHMARK_LINK_LIB} mindspore::json)
|
||||
elseif(${MSLITE_REGISTRY_DEVICE} STREQUAL "Hi3559A")
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/nnie/third_patry/hi3559_sdk)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/nnie/third_patry/hi3559_sdk/lib)
|
||||
include_directories(${PROVIDERS_DIR}/nnie/third_patry/hi3559_sdk)
|
||||
link_directories(${PROVIDERS_DIR}/nnie/third_patry/hi3559_sdk/lib)
|
||||
add_compile_definitions(BENCHMARK_CLIP_JSON)
|
||||
endif()
|
||||
elseif(TARGET_MIX210)
|
||||
|
@ -26,7 +27,7 @@ elseif(TARGET_MIX210)
|
|||
set(BENCHMARK_LINK_LIB ${BENCHMARK_LINK_LIB} mindspore::json pthread
|
||||
dpico_acl_adapter svp_acl dl securec protobuf-c stdc++)
|
||||
if(${MSLITE_REGISTRY_DEVICE} STREQUAL "SD3403")
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dpico)
|
||||
add_subdirectory(${PROVIDERS_DIR}/dpico dpico)
|
||||
message("SD3403_SDK_PATH:${SD3403_SDK_PATH}.")
|
||||
include_directories(${SD3403_SDK_PATH}/include)
|
||||
include_directories(${SD3403_SDK_PATH})
|
||||
|
@ -58,10 +59,6 @@ endif()
|
|||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../lite)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../core)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/runtime)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/runtime/include)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/runtime/include/third_party)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/runtime/lib)
|
||||
|
||||
if(MSLITE_ENABLE_SHARING_MEM_WITH_OPENGL)
|
||||
list(APPEND opengl_lib EGL GLESv3)
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
/**
|
||||
* Copyright 2021 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.
|
||||
*/
|
||||
#include "src/nnie_cfg_parser.h"
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "include/errorcode.h"
|
||||
#include "src/nnie_manager.h"
|
||||
#include "src/nnie_print.h"
|
||||
|
||||
using mindspore::lite::RET_ERROR;
|
||||
using mindspore::lite::RET_OK;
|
||||
namespace mindspore {
|
||||
namespace nnie {
|
||||
namespace {
|
||||
constexpr auto ENV_TIME_STEP = "TIME_STEP";
|
||||
constexpr auto ENV_MAX_ROI_NUM = "MAX_ROI_NUM";
|
||||
constexpr auto ENV_CORE_IDS = "CORE_IDS";
|
||||
constexpr auto DELIM = ",";
|
||||
constexpr int MAX_CORE_ID = 7;
|
||||
} // namespace
|
||||
void Flags::Init() {
|
||||
auto *time_step = std::getenv(ENV_TIME_STEP);
|
||||
if (time_step != nullptr) {
|
||||
auto iter = std::find_if(time_step, time_step + strlen(time_step), [](char val) { return val < '0' || val > '9'; });
|
||||
if (iter != time_step) {
|
||||
*iter = '\0';
|
||||
this->time_step_ = atoi(time_step);
|
||||
} else {
|
||||
LOGE("TIME_STEP ENV is invalid, now set to default value %d", this->time_step_);
|
||||
}
|
||||
} else {
|
||||
LOGW("TIME_STEP ENV is not set, now set to default value %d", this->time_step_);
|
||||
}
|
||||
auto *max_roi_num = std::getenv(ENV_MAX_ROI_NUM);
|
||||
if (max_roi_num != nullptr) {
|
||||
auto iter =
|
||||
std::find_if(max_roi_num, max_roi_num + strlen(max_roi_num), [](char val) { return val < '0' || val > '9'; });
|
||||
if (iter != max_roi_num) {
|
||||
*iter = '\0';
|
||||
this->max_roi_num_ = atoi(max_roi_num);
|
||||
} else {
|
||||
LOGW("MAX_ROI_NUM ENV is invalid, now set to default value %d", this->max_roi_num_);
|
||||
}
|
||||
} else {
|
||||
LOGW("MAX_ROI_NUM ENV is not set, now set to default value %d", this->max_roi_num_);
|
||||
}
|
||||
auto ids = std::getenv(ENV_CORE_IDS);
|
||||
if (ids != nullptr) {
|
||||
auto iter = std::find_if(ids, ids + strlen(ids), [](char val) { return (val < '0' || val > '9') && val != ','; });
|
||||
std::vector<int> core_ids;
|
||||
if (iter != ids) {
|
||||
*iter = '\0';
|
||||
char *saveptr;
|
||||
char *p = strtok_r(ids, DELIM, &saveptr);
|
||||
while (p != nullptr) {
|
||||
int id = atoi(p);
|
||||
p = strtok_r(NULL, DELIM, &saveptr);
|
||||
if (id > MAX_CORE_ID || id < 0) {
|
||||
LOGE("id is out of range");
|
||||
continue;
|
||||
}
|
||||
if (std::find(core_ids.begin(), core_ids.end(), id) != core_ids.end()) {
|
||||
continue;
|
||||
}
|
||||
core_ids.push_back(id);
|
||||
}
|
||||
}
|
||||
if (!core_ids.empty()) {
|
||||
this->core_ids_ = core_ids;
|
||||
} else {
|
||||
std::string message =
|
||||
"CORE_IDS ENV is invalid, now set to default value {" + std::to_string(this->core_ids_.front()) + "}";
|
||||
LOGW(message.c_str());
|
||||
}
|
||||
} else {
|
||||
std::string message =
|
||||
"CORE_IDS ENV is not set, now set to default value {" + std::to_string(this->core_ids_.front()) + "}";
|
||||
LOGW(message.c_str());
|
||||
}
|
||||
}
|
||||
} // namespace nnie
|
||||
} // namespace mindspore
|
|
@ -42,9 +42,7 @@ int RunBenchmark(int argc, const char **argv) {
|
|||
std::cerr << flags.Usage() << std::endl;
|
||||
return RET_OK;
|
||||
}
|
||||
#ifdef SUPPORT_NNIE
|
||||
BenchmarkBase *benchmark = new (std::nothrow) Benchmark(&flags);
|
||||
#else
|
||||
|
||||
auto api_type = std::getenv("MSLITE_API_TYPE");
|
||||
if (api_type != nullptr) {
|
||||
MS_LOG(INFO) << "MSLITE_API_TYPE = " << api_type;
|
||||
|
@ -61,7 +59,6 @@ int RunBenchmark(int argc, const char **argv) {
|
|||
BENCHMARK_LOG_ERROR("Invalid MSLITE_API_TYPE, (OLD/NEW/C, default:OLD)");
|
||||
return RET_ERROR;
|
||||
}
|
||||
#endif
|
||||
if (benchmark == nullptr) {
|
||||
BENCHMARK_LOG_ERROR("new benchmark failed ");
|
||||
return RET_ERROR;
|
||||
|
|
Loading…
Reference in New Issue