change cropper name

pull/10350/head
yeyunpeng 5 years ago
parent 5d4a308aca
commit 8e7052ce74

@ -144,8 +144,8 @@ else ()
endif () endif ()
if (ENABLE_TOOLS) if (ENABLE_TOOLS)
install(TARGETS benchmark RUNTIME DESTINATION ${RUNTIME_PKG_NAME}/benchmark COMPONENT ${RUNTIME_COMPONENT_NAME}) install(TARGETS benchmark RUNTIME DESTINATION ${RUNTIME_PKG_NAME}/benchmark COMPONENT ${RUNTIME_COMPONENT_NAME})
install(TARGETS lib_cropper RUNTIME DESTINATION ${RUNTIME_PKG_NAME}/lib_cropper COMPONENT ${RUNTIME_COMPONENT_NAME}) install(TARGETS cropper RUNTIME DESTINATION ${RUNTIME_PKG_NAME}/cropper COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/lite/build/tools/lib_cropper/cropper_mapping_cpu.cfg DESTINATION ${RUNTIME_PKG_NAME}/lib_cropper COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/mindspore/lite/build/tools/cropper/cropper_mapping_cpu.cfg DESTINATION ${RUNTIME_PKG_NAME}/cropper COMPONENT ${RUNTIME_COMPONENT_NAME})
endif () endif ()
endif () endif ()

@ -237,7 +237,7 @@ if (NOT WIN32)
if (ENABLE_TOOLS) if (ENABLE_TOOLS)
if (NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64) if (NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/schema_gen) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/schema_gen)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/lib_cropper) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/cropper)
endif () endif ()
endif () endif ()
if (BUILD_TESTCASES) if (BUILD_TESTCASES)

@ -126,7 +126,7 @@ bool NPUManager::IsKirinChip() {
} }
int NPUManager::AddModel(domi::ModelBufferData *model_buffer_data, const std::string &model_name, int frequency) { int NPUManager::AddModel(domi::ModelBufferData *model_buffer_data, const std::string &model_name, int frequency) {
auto model = new SubGraphModel(index_, model_name, model_buffer_data, frequency); auto model = new SubGraphModel(index_, model_name, model_buffer_data);
auto desc = std::make_shared<hiai::AiModelDescription>(model_name, frequency, 0, 0, 0); auto desc = std::make_shared<hiai::AiModelDescription>(model_name, frequency, 0, 0, 0);
model->desc_ = desc; model->desc_ = desc;
models_.insert({model_name, model}); models_.insert({model_name, model});

@ -33,7 +33,7 @@ static std::set<mindspore::schema::PrimitiveType> npu_trans_nodes = {
schema::PrimitiveType_Resize, schema::PrimitiveType_Pooling}; schema::PrimitiveType_Resize, schema::PrimitiveType_Pooling};
struct SubGraphModel { struct SubGraphModel {
public: public:
SubGraphModel(int index, std::string model_name, domi::ModelBufferData *model_buffer_data, int frequency) SubGraphModel(int index, std::string model_name, domi::ModelBufferData *model_buffer_data)
: index_(index), model_name_(std::move(model_name)), model_buffer_data_(model_buffer_data) { : index_(index), model_name_(std::move(model_name)), model_buffer_data_(model_buffer_data) {
std::cout << model_name; std::cout << model_name;
} }

@ -5,16 +5,16 @@ set(COMMON_SRC
${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/utils.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/utils.cc
) )
add_executable(lib_cropper add_executable(cropper
${CMAKE_CURRENT_SOURCE_DIR}/main.cc ${CMAKE_CURRENT_SOURCE_DIR}/main.cc
${CMAKE_CURRENT_SOURCE_DIR}/lib_cropper.cc ${CMAKE_CURRENT_SOURCE_DIR}/cropper.cc
${CMAKE_CURRENT_SOURCE_DIR}/cropper_flags.cc ${CMAKE_CURRENT_SOURCE_DIR}/cropper_flags.cc
${CMAKE_CURRENT_SOURCE_DIR}/cropper_utils.cc ${CMAKE_CURRENT_SOURCE_DIR}/cropper_utils.cc
${COMMON_SRC}) ${COMMON_SRC})
add_dependencies(lib_cropper fbs_src) add_dependencies(cropper fbs_src)
target_link_libraries(lib_cropper mindspore-lite_static) target_link_libraries(cropper mindspore-lite_static)
add_custom_command(TARGET lib_cropper POST_BUILD COMMAND add_custom_command(TARGET cropper POST_BUILD COMMAND
bash build_cropper_config.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) bash build_cropper_config.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

@ -3,7 +3,7 @@
CURRENT_PATH=$(pwd) CURRENT_PATH=$(pwd)
MINDSPORE_HOME="${CURRENT_PATH}/../../../.." MINDSPORE_HOME="${CURRENT_PATH}/../../../.."
echo "MINDSPORE_HOME path is ${MINDSPORE_HOME}" echo "MINDSPORE_HOME path is ${MINDSPORE_HOME}"
CROPPER_OUTPUT_DIR=${MINDSPORE_HOME}/mindspore/lite/build/tools/lib_cropper CROPPER_OUTPUT_DIR=${MINDSPORE_HOME}/mindspore/lite/build/tools/cropper
mkdir -p ${CROPPER_OUTPUT_DIR} mkdir -p ${CROPPER_OUTPUT_DIR}
MAPPING_OUTPUT_FILE_NAME_TMP=${CROPPER_OUTPUT_DIR}/cropper_mapping_cpu_tmp.cfg MAPPING_OUTPUT_FILE_NAME_TMP=${CROPPER_OUTPUT_DIR}/cropper_mapping_cpu_tmp.cfg
MAPPING_OUTPUT_FILE_NAME=${CROPPER_OUTPUT_DIR}/cropper_mapping_cpu.cfg MAPPING_OUTPUT_FILE_NAME=${CROPPER_OUTPUT_DIR}/cropper_mapping_cpu.cfg
@ -14,7 +14,8 @@ ops_list=()
DEFINE_STR="-DENABLE_ANDROID -DENABLE_ARM -DENABLE_ARM64 -DENABLE_NEON -DNO_DLIB -DUSE_ANDROID_LOG -DANDROID" DEFINE_STR="-DENABLE_ANDROID -DENABLE_ARM -DENABLE_ARM64 -DENABLE_NEON -DNO_DLIB -DUSE_ANDROID_LOG -DANDROID"
# get the flatbuffers path # get the flatbuffers path
if [ ${MSLIBS_CACHE_PATH} ]; then if [ ${MSLIBS_CACHE_PATH} ]; then
FLATBUFFERS_LIST=($(ls -d ${MSLIBS_CACHE_PATH}/flatbuffers_*/include)) FLATBUFFERS_LIST=()
while IFS='' read -r line; do FLATBUFFERS_LIST+=("$line"); done < <(ls -d ${MSLIBS_CACHE_PATH}/flatbuffers_*/include)
FLATBUFFERS=${FLATBUFFERS_LIST[0]} FLATBUFFERS=${FLATBUFFERS_LIST[0]}
echo "FLATBUFFERS path is ${FLATBUFFERS}" echo "FLATBUFFERS path is ${FLATBUFFERS}"
else else
@ -41,7 +42,9 @@ REMOVE_LISTS_STR=""
getDeep() { getDeep() {
map_files=$(gcc -MM ${2} ${DEFINE_STR} ${HEADER_LOCATION}) map_files=$(gcc -MM ${2} ${DEFINE_STR} ${HEADER_LOCATION})
# first is *.o second is *.cc # first is *.o second is *.cc
array_deep=($(echo ${map_files} | awk -F '\' '{for(i=3;i<=NF;i++){print $i}}' | grep -E 'src/runtime|nnacl' | egrep -v ${REMOVE_LISTS_STR})) array_deep=()
while IFS='' read -r line; do array_deep+=("$line"); done < <(echo ${map_files} | awk -F '\' '{for(i=3;i<=NF;i++){print $i}}' | grep -E 'src/runtime|nnacl' | egrep -v ${REMOVE_LISTS_STR})
# shellcheck disable=SC2068
for array_deep_file in ${array_deep[@]}; do for array_deep_file in ${array_deep[@]}; do
# only add existing files # only add existing files
if [[ -e ${array_deep_file%h*}cc ]]; then if [[ -e ${array_deep_file%h*}cc ]]; then
@ -56,10 +59,12 @@ getDeep() {
} }
getOpsFile() { getOpsFile() {
echo "start get operator mapping file $3" echo "start get operator mapping file $3"
# shellcheck disable=SC2068
for type in ${ops_list[@]}; do for type in ${ops_list[@]}; do
# get mapping # get mapping
ret=$(egrep -r -l "$1${type}," $2) ret=$(egrep -r -l "$1${type}," $2)
array=(${ret}) array=("${ret}")
# shellcheck disable=SC2068
for file in ${array[@]}; do for file in ${array[@]}; do
# delete \n # delete \n
out_file=$(echo ${file} | awk -F '/' '{print $NF}') out_file=$(echo ${file} | awk -F '/' '{print $NF}')
@ -67,7 +72,9 @@ getOpsFile() {
echo "${type},${3},${out_file}.o" >>${MAPPING_OUTPUT_FILE_NAME_TMP} echo "${type},${3},${out_file}.o" >>${MAPPING_OUTPUT_FILE_NAME_TMP}
map_files=$(gcc -MM ${file} ${DEFINE_STR} ${HEADER_LOCATION}) map_files=$(gcc -MM ${file} ${DEFINE_STR} ${HEADER_LOCATION})
# first is *.o second is *.cc # first is *.o second is *.cc
array_file=($(echo ${map_files} | awk -F '\' '{for(i=3;i<=NF;i++){print $i}}' | grep -E 'src/runtime|nnacl' | egrep -v ${REMOVE_LISTS_STR})) array_file=()
while IFS='' read -r line; do array_file+=("$line"); done < <(echo ${map_files} | awk -F '\' '{for(i=3;i<=NF;i++){print $i}}' | grep -E 'src/runtime|nnacl' | egrep -v ${REMOVE_LISTS_STR})
# shellcheck disable=SC2068
for array_file in ${array_file[@]}; do for array_file in ${array_file[@]}; do
# only add existing files # only add existing files
if [[ -e ${array_file%h*}cc ]]; then if [[ -e ${array_file%h*}cc ]]; then
@ -86,45 +93,55 @@ getOpsFile() {
} }
getCommonFile() { getCommonFile() {
echo "start get common files" echo "start get common files"
include_h=($(ls ${MINDSPORE_HOME}/mindspore/lite/include/*.h)) include_h=()
src_files_h=($(ls ${MINDSPORE_HOME}/mindspore/lite/src/*.h)) while IFS='' read -r line; do include_h+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/include/*.h)
common_files_h=($(ls ${MINDSPORE_HOME}/mindspore/lite/src/common/*.h)) src_files_h=()
runtime_files_h=($(ls ${MINDSPORE_HOME}/mindspore/lite/src/runtime/*.h)) while IFS='' read -r line; do src_files_h+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/*.h)
others_files=( common_files_h=()
${MINDSPORE_HOME}/mindspore/lite/src/populate/populate_register.h while IFS='' read -r line; do common_files_h+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/common/*.h)
${MINDSPORE_HOME}/mindspore/lite/src/ops/primitive_c.h runtime_files_h=()
${MINDSPORE_HOME}/mindspore/lite/nnacl/nnacl_utils.h while IFS='' read -r line; do runtime_files_h+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/runtime/*.h)
${MINDSPORE_HOME}/mindspore/lite/nnacl/pack.h others_files_h=(
${MINDSPORE_HOME}/mindspore/lite/src/runtime/kernel/arm/fp16/common_fp16.h "${MINDSPORE_HOME}"/mindspore/lite/src/populate/populate_register.h
"${MINDSPORE_HOME}"/mindspore/lite/src/ops/primitive_c.h
"${MINDSPORE_HOME}"/mindspore/lite/nnacl/nnacl_utils.h
"${MINDSPORE_HOME}"/mindspore/lite/nnacl/pack.h
"${MINDSPORE_HOME}"/mindspore/lite/src/runtime/kernel/arm/fp16/common_fp16.h
) )
all_files_h=(${include_h[@]} ${src_files_h[@]} ${common_files_h[@]} ${runtime_files_h[@]} ${others_files[@]}) all_files_h=("${include_h[@]}" "${src_files_h[@]}" "${common_files_h[@]}" "${runtime_files_h[@]}" "${others_files_h[@]}")
# concat regx # concat regx
REMOVE_LISTS_STR="${all_files_h[0]}" REMOVE_LISTS_STR="${all_files_h[0]}"
# shellcheck disable=SC2068
for val in ${all_files_h[@]:1}; do for val in ${all_files_h[@]:1}; do
REMOVE_LISTS_STR="$REMOVE_LISTS_STR|$val" REMOVE_LISTS_STR="$REMOVE_LISTS_STR|$val"
done done
src_files=($(ls ${MINDSPORE_HOME}/mindspore/lite/src/*.cc)) src_files=()
common_files=($(ls ${MINDSPORE_HOME}/mindspore/lite/src/common/*.cc)) while IFS='' read -r line; do src_files+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/*.cc)
runtime_files_cc=($(ls ${MINDSPORE_HOME}/mindspore/lite/src/runtime/*.cc)) common_files=()
runtime_files_c=($(ls ${MINDSPORE_HOME}/mindspore/lite/src/runtime/*.c)) while IFS='' read -r line; do common_files+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/common/*.cc)
runtime_files_cc=()
while IFS='' read -r line; do runtime_files_cc+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/runtime/*.cc)
runtime_files_c=()
while IFS='' read -r line; do runtime_files_c+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/runtime/*.c)
# sava all assembly files # sava all assembly files
assembly_files=("$(ls ${MINDSPORE_HOME}/mindspore/lite/nnacl/assembly/*/*.S)") assembly_files=()
others_files=( while IFS='' read -r line; do assembly_files+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/nnacl/assembly/*/*.S)
${MINDSPORE_HOME}/mindspore/lite/src/ops/primitive_c.cc others_files_c=(
${MINDSPORE_HOME}/mindspore/lite/nnacl/nnacl_utils.c "${MINDSPORE_HOME}"/mindspore/lite/src/ops/primitive_c.cc
${MINDSPORE_HOME}/mindspore/lite/nnacl/pack.c "${MINDSPORE_HOME}"/mindspore/lite/nnacl/nnacl_utils.c
${MINDSPORE_HOME}/mindspore/lite/src/runtime/kernel/arm/fp16/common_fp16.cc "${MINDSPORE_HOME}"/mindspore/lite/nnacl/pack.c
${MINDSPORE_HOME}/mindspore/lite/src/ops/populate/arithmetic_populate.cc "${MINDSPORE_HOME}"/mindspore/lite/src/runtime/kernel/arm/fp16/common_fp16.cc
${MINDSPORE_HOME}/mindspore/lite/src/ops/populate/arithmetic_self_populate.cc "${MINDSPORE_HOME}"/mindspore/lite/src/ops/populate/arithmetic_populate.cc
"${MINDSPORE_HOME}"/mindspore/lite/src/ops/populate/arithmetic_self_populate.cc
) )
all_files=(${src_files[@]} ${common_files[@]} ${runtime_files_cc[@]} ${runtime_files_c[@]} ${others_files[@]} ${assembly_files[@]}) all_files=("${src_files[@]}" "${common_files[@]}" "${runtime_files_cc[@]}" "${runtime_files_c[@]}" "${others_files_c[@]}" "${assembly_files[@]}")
# shellcheck disable=SC2068
for file in ${all_files[@]}; do for file in ${all_files[@]}; do
map_files=$(gcc -MM ${file} ${DEFINE_STR} ${HEADER_LOCATION}) map_files=$(gcc -MM ${file} ${DEFINE_STR} ${HEADER_LOCATION})
# first is *.o second is *.cc # first is *.o second is *.cc
# shellcheck disable=SC2207
array_runtime=($(echo ${map_files} | awk -F '\' '{for(i=3;i<=NF;i++){print $i}}' | grep -v "flatbuffers" | egrep -v ${REMOVE_LISTS_STR})) array_runtime=($(echo ${map_files} | awk -F '\' '{for(i=3;i<=NF;i++){print $i}}' | grep -v "flatbuffers" | egrep -v ${REMOVE_LISTS_STR}))
# only add existing files # only add existing files
for array_runtime_file in "${array_runtime[@]}"; do for array_runtime_file in "${array_runtime[@]}"; do
@ -136,6 +153,7 @@ getCommonFile() {
fi fi
done done
done done
# shellcheck disable=SC2068
for file in ${all_files[@]}; do for file in ${all_files[@]}; do
file=$(echo ${file} | awk -F '/' '{print $NF}') file=$(echo ${file} | awk -F '/' '{print $NF}')
echo "CommonFile,common,${file}.o" >>${MAPPING_OUTPUT_FILE_NAME_TMP} & echo "CommonFile,common,${file}.o" >>${MAPPING_OUTPUT_FILE_NAME_TMP} &
@ -146,11 +164,12 @@ getCommonFile() {
# automatically generate operator list # automatically generate operator list
generateOpsList() { generateOpsList() {
echo "start generate operator list" echo "start generate operator list"
ops=($(egrep "PrimitiveType_.* = " "${MINDSPORE_HOME}/mindspore/lite/build/schema/model_generated.h" | awk -F '_' '{print $2}' | awk -F ' ' '{print $1}')) ops=()
while IFS='' read -r line; do ops+=("$line"); done < <(egrep "PrimitiveType_.* = " "${MINDSPORE_HOME}/mindspore/lite/build/schema/model_generated.h" | awk -F '_' '{print $2}' | awk -F ' ' '{print $1}')
ops_num=$((${#ops[@]} - 3)) ops_num=$((${#ops[@]} - 3))
echo "ops nums:${ops_num}" echo "ops nums:${ops_num}"
ops_list=${ops[@]:1:$ops_num} ops_list=()
mapfile -t ops_list <<< "${ops[*]:1:$ops_num}"
} }
echo "Start getting all file associations." echo "Start getting all file associations."
generateOpsList generateOpsList

@ -16,8 +16,8 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "tools/lib_cropper/lib_cropper.h" #include "tools/cropper/cropper.h"
#include "tools/lib_cropper/cropper_utils.h" #include "tools/cropper/cropper_utils.h"
#define BUF_SIZE 1024 #define BUF_SIZE 1024
namespace mindspore { namespace mindspore {

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef MINDSPORE_LITE_TOOLS_LIB_CROPPER_LIB_CROPPER_H_ #ifndef MINDSPORE_LITE_TOOLS_CROPPER_CROPPER_H_
#define MINDSPORE_LITE_TOOLS_LIB_CROPPER_LIB_CROPPER_H_ #define MINDSPORE_LITE_TOOLS_CROPPER_CROPPER_H_
#include <set> #include <set>
#include <string> #include <string>
@ -26,7 +26,7 @@
#include "src/common/utils.h" #include "src/common/utils.h"
#include "schema/model_generated.h" #include "schema/model_generated.h"
#include "include/lite_session.h" #include "include/lite_session.h"
#include "tools/lib_cropper/cropper_flags.h" #include "tools/cropper/cropper_flags.h"
namespace mindspore::lite::cropper { namespace mindspore::lite::cropper {

@ -14,9 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "tools/lib_cropper/cropper_flags.h" #include "tools/cropper/cropper_flags.h"
#include <string> #include <string>
#include "tools/lib_cropper/cropper_utils.h" #include "tools/cropper/cropper_utils.h"
#include "src/common/file_utils.h" #include "src/common/file_utils.h"
namespace mindspore { namespace mindspore {

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef MINDSPORE_LITE_TOOLS_LIB_CROPPER_LIB_CROPPER_FLAGS_H #ifndef MINDSPORE_LITE_TOOLS_CROPPER_CROPPER_FLAGS_H
#define MINDSPORE_LITE_TOOLS_LIB_CROPPER_LIB_CROPPER_FLAGS_H #define MINDSPORE_LITE_TOOLS_CROPPER_CROPPER_FLAGS_H
#include <string> #include <string>
#include "tools/common/flag_parser.h" #include "tools/common/flag_parser.h"
@ -42,4 +42,4 @@ class CropperFlags : public virtual mindspore::lite::FlagParser {
} // namespace lite } // namespace lite
} // namespace mindspore } // namespace mindspore
#endif #endif // MINDSPORE_LITE_TOOLS_CROPPER_CROPPER_FLAGS_H

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "tools/lib_cropper/cropper_utils.h" #include "tools/cropper/cropper_utils.h"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include "src/common/log_adapter.h" #include "src/common/log_adapter.h"

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef MINDSPORE_LITE_TOOLS_LIB_CROPPER_LIB_CROPPER_UTILS_H #ifndef MINDSPORE_LITE_TOOLS_CROPPER_CROPPER_UTILS_H
#define MINDSPORE_LITE_TOOLS_LIB_CROPPER_LIB_CROPPER_UTILS_H #define MINDSPORE_LITE_TOOLS_CROPPER_CROPPER_UTILS_H
#include <string> #include <string>
namespace mindspore { namespace mindspore {
namespace lite { namespace lite {

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "tools/lib_cropper/lib_cropper.h" #include "tools/cropper/cropper.h"
#include "include/version.h" #include "include/version.h"
int main(int argc, const char **argv) { int main(int argc, const char **argv) {
Loading…
Cancel
Save