forked from mindspore-Ecosystem/mindspore
!48595 [MS]{Lite][Task] add custom op project
Merge pull request !48595 from 刘力力/master_develop_merge
This commit is contained in:
commit
f7a1f70128
|
@ -81,6 +81,7 @@
|
||||||
"mindspore/mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_utils.cc" "knownConditionTrueFalse"
|
"mindspore/mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_utils.cc" "knownConditionTrueFalse"
|
||||||
"mindspore/mindspore/lite/tools/kernel_builder/ascend/tbe_dsl/sample/op_proto/add_dsl.cc" "syntaxError"
|
"mindspore/mindspore/lite/tools/kernel_builder/ascend/tbe_dsl/sample/op_proto/add_dsl.cc" "syntaxError"
|
||||||
"mindspore/mindspore/lite/tools/kernel_builder/ascend/tbe_tik/sample/op_proto/matmul_tik.cc" "syntaxError"
|
"mindspore/mindspore/lite/tools/kernel_builder/ascend/tbe_tik/sample/op_proto/matmul_tik.cc" "syntaxError"
|
||||||
|
"mindspore/mindspore/lite/tools/kernel_builder/ascend_new/op_proto/" "syntaxError"
|
||||||
|
|
||||||
# AICPU migration
|
# AICPU migration
|
||||||
"mindspore/mindspore/ccsrc/plugin/device/ascend/kernel/aicpu/aicpu_ops/cpu_kernel/ms_kernel/" "constVariable"
|
"mindspore/mindspore/ccsrc/plugin/device/ascend/kernel/aicpu/aicpu_ops/cpu_kernel/ms_kernel/" "constVariable"
|
||||||
|
|
|
@ -105,6 +105,8 @@
|
||||||
"mindspore/mindspore/lite/tools/kernel_builder/ascend/aicpu/sample/" "build/include"
|
"mindspore/mindspore/lite/tools/kernel_builder/ascend/aicpu/sample/" "build/include"
|
||||||
"mindspore/mindspore/lite/tools/kernel_builder/ascend/tbe_dsl/sample/" "build/include"
|
"mindspore/mindspore/lite/tools/kernel_builder/ascend/tbe_dsl/sample/" "build/include"
|
||||||
"mindspore/mindspore/lite/tools/kernel_builder/ascend/tbe_tik/sample/" "build/include"
|
"mindspore/mindspore/lite/tools/kernel_builder/ascend/tbe_tik/sample/" "build/include"
|
||||||
|
"mindspore/mindspore/lite/tools/kernel_builder/ascend_new/op_proto/" "build/include"
|
||||||
|
"mindspore/mindspore/lite/tools/kernel_builder/ascend_new/cpukernel/impl/" "build/include"
|
||||||
|
|
||||||
# AICPU migration
|
# AICPU migration
|
||||||
"mindspore/mindspore/ccsrc/plugin/device/ascend/kernel/aicpu/aicpu_ops/cpu_kernel/" "build/include_subdir"
|
"mindspore/mindspore/ccsrc/plugin/device/ascend/kernel/aicpu/aicpu_ops/cpu_kernel/" "build/include_subdir"
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -O2 -Wall -s")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -O0 -g -Wall")
|
||||||
|
set(CAMKE_SKIP_RPATH TRUE)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack -pie")
|
||||||
|
add_compile_options(
|
||||||
|
-fstack-protector-all
|
||||||
|
-D_FORTIFY_SOURCE=2 -O2
|
||||||
|
)
|
||||||
|
cmake_minimum_required(VERSION 3.5.1)
|
||||||
|
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
|
||||||
|
message(STATUS "CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
message(STATUS "CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
|
project(opp)
|
||||||
|
|
||||||
|
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/cmake/config.cmake)
|
||||||
|
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/config.cmake)
|
||||||
|
else()
|
||||||
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake)
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(COMMAND rm -rf ./makepkg)
|
||||||
|
|
||||||
|
message(STATUS "OP_COMMON_INC=${OP_COMMON_INC}")
|
||||||
|
# add sub compile directory
|
||||||
|
# open this when aicpu env is ok
|
||||||
|
#if(EXISTS "${CMAKE_SOURCE_DIR}/cpukernel")
|
||||||
|
# add_subdirectory(cpukernel)
|
||||||
|
#endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/framework")
|
||||||
|
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/framework/mindspore")
|
||||||
|
add_subdirectory(framework)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/op_proto")
|
||||||
|
add_subdirectory(op_proto)
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/op_tiling")
|
||||||
|
add_subdirectory(op_tiling)
|
||||||
|
endif()
|
||||||
|
if(EXISTS "${CMAKE_SOURCE_DIR}/tbe")
|
||||||
|
add_subdirectory(tbe)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
if(NOT "x$ENV{ADD_TESTCASE}" STREQUAL "x")
|
||||||
|
# add testcases subdirectory
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/testcases")
|
||||||
|
add_subdirectory(testcases)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "operation system is ${CMAKE_HOST_SYSTEM_NAME}")
|
||||||
|
|
||||||
|
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/op_proto")
|
||||||
|
set(ALL_MODULES ${OP_PROTO_TARGET})
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/op_tiling")
|
||||||
|
set(ALL_MODULES ${ALL_MODULES} ${OP_TILING_TARGET})
|
||||||
|
endif()
|
||||||
|
#if(EXISTS "${CMAKE_SOURCE_DIR}/cpukernel/CMakeLists.txt")
|
||||||
|
# set(ALL_MODULES ${ALL_MODULES} ${AICPU_KERNEL_TARGET})
|
||||||
|
# set(ALL_MODULES ${ALL_MODULES} ${AICPU_CONFIG_JSON_TARGET})
|
||||||
|
#endif()
|
||||||
|
message(STATUS "AICPU_CONFIG_INFO_FLAG=${AICPU_CONFIG_INFO_FLAG}")
|
||||||
|
|
||||||
|
if(EXISTS "${CMAKE_SOURCE_DIR}/tbe/CMakeLists.txt")
|
||||||
|
set(ALL_MODULES ${ALL_MODULES} config_json)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/framework/caffe_plugin")
|
||||||
|
set(ALL_MODULES ${ALL_MODULES} ${CAFFE_PLUGIN_TARGET})
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/framework/tf_plugin")
|
||||||
|
set(ALL_MODULES ${ALL_MODULES} ${TF_PLUGIN_TARGET})
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/framework/tf_scope_fusion_pass")
|
||||||
|
set(ALL_MODULES ${ALL_MODULES} ${TF_SCOPE_FUSION_PASS_TARGET})
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/framework/onnx_plugin")
|
||||||
|
set(ALL_MODULES ${ALL_MODULES} ${ONNX_PLUGIN_TARGET})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "ALL_MODULES=${ALL_MODULES}")
|
||||||
|
add_custom_target(${RUN_TARGET} ALL DEPENDS ${ALL_MODULES})
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${RUN_TARGET}
|
||||||
|
PRE_BUILD
|
||||||
|
COMMAND mkdir -p ./makepkg/packages/${PROJECT_DIR}/fusion_rules/
|
||||||
|
COMMAND mkdir -p ./makepkg/packages/${PROJECT_DIR}/op_impl/ai_core/tbe/mslite_impl
|
||||||
|
COMMAND mkdir -p ./makepkg/packages/${PROJECT_DIR}/op_impl/vector_core/tbe/mslite_impl
|
||||||
|
COMMAND mkdir -p ./makepkg/packages/${PROJECT_DIR}/op_impl/cpu/aicpu_kernel/impl
|
||||||
|
COMMAND bash ${CMAKE_SOURCE_DIR}/cmake/util/gen_impl_and_mrege_json.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
|
||||||
|
COMMAND cp ${CMAKE_SOURCE_DIR}/scripts/* ./makepkg/
|
||||||
|
)
|
||||||
|
|
||||||
|
if(EXISTS ${CMAKE_SOURCE_DIR}/custom.proto)
|
||||||
|
add_custom_command(TARGET ${RUN_TARGET}
|
||||||
|
PRE_BUILD
|
||||||
|
COMMAND cp ${CMAKE_SOURCE_DIR}/custom.proto ./makepkg/packages
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${RUN_TARGET}
|
||||||
|
PRE_BUILD
|
||||||
|
COMMAND chmod u+x ./makepkg/*.sh
|
||||||
|
COMMAND ${CMAKE_SOURCE_DIR}/cmake/util/makeself/makeself.sh
|
||||||
|
--gzip --complevel 4 --nomd5 --sha256
|
||||||
|
./makepkg ${RUN_TARGET} "version:1.0" ./install.sh
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,195 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
###### Environment variable settings, need to set according to your own device ######
|
||||||
|
|
||||||
|
# ASCEND_OPP_PATH: The installation path of the OPP package, where "/usr/local/Ascend/opp" is the
|
||||||
|
# default installation path. If user defines the installation path, please modify it.
|
||||||
|
# Uncomment and modify it when you specified installation path of OPP.
|
||||||
|
# export ASCEND_OPP_PATH=/usr/local/Ascend/opp
|
||||||
|
|
||||||
|
# ASCEND_AICPU_PATH: The installation path of the AICPU package, where "/usr/local/Ascend" is the
|
||||||
|
# default installation path. If user defines the installation path, please modify it.
|
||||||
|
# Uncomment and modify it when you specified installation path of AICPU.
|
||||||
|
# export ASCEND_AICPU_PATH=/usr/local/Ascend
|
||||||
|
|
||||||
|
# ASCEND_TENSOR_COMPILER_INCLUDE: The path of the header file of the Compiler package, where "/usr/local/Ascend/compiler/include" is the
|
||||||
|
# default installation path. If user defines the installation path, please modify it.
|
||||||
|
# Uncomment and modify it when you specified installation path of Compiler.
|
||||||
|
# export ASCEND_TENSOR_COMPILER_INCLUDE=/usr/local/Ascend/compiler/include
|
||||||
|
|
||||||
|
# TOOLCHAIN_DIR: The path of the cross compilation tool, where "/usr/local/Ascend/toolkit/toolchain/hcc" is the
|
||||||
|
# default installation path. If user defines the installation path, please modify it.
|
||||||
|
# Uncomment and modify it when you specified installation path of toolkit.
|
||||||
|
# export TOOLCHAIN_DIR=/usr/local/Ascend/toolkit/toolchain/hcc
|
||||||
|
|
||||||
|
# AICPU_KERNEL_TARGET: The name of the custom operator kernels library, which "cust_aicpu_kernels" is the
|
||||||
|
# default installation name. If user defines the installation name, please modify it.
|
||||||
|
# Uncomment and modify it when you specified the installation name of custom operator kernels library.
|
||||||
|
export AICPU_KERNEL_TARGET=cust_aicpu_kernels
|
||||||
|
|
||||||
|
# The SYSTEM_INFO flag is the name of the form of the operator package generated by the compiler, which can be customized by the user, E.g:
|
||||||
|
# a. If the operating system version is CentOS and the architecture is aarch64, it can be set to centos_aarch64, and the operator package name generated by compilation is custom_opp_centos_aarch64.run.
|
||||||
|
# b. If the operating system version is CentOS and the architecture is x86_64, it can be set to centos_x86_64, and the name of the operator package generated by compilation is custom_opp_centos_x86_64.run.
|
||||||
|
# c. If the SYSTEM_INFO environment variable is not set, the default value is used: ubuntu_x86_64, and the operator package name generated by compilation is custom_opp_ubuntu_x86_64.run.
|
||||||
|
# Uncomment and modify it when you need to specify os and architecture.
|
||||||
|
# export SYSTEM_INFO=centos_x86_64
|
||||||
|
|
||||||
|
# The version of soc.
|
||||||
|
# export AICPU_SOC_VERSION=Ascend910
|
||||||
|
|
||||||
|
###### The following logic can be used without modification ######
|
||||||
|
|
||||||
|
# Indicates the name of the supplier to which the operator belongs. This field can be customized.
|
||||||
|
vendor_name=mslite
|
||||||
|
if [[ "$vendor_name" = "" ]] || [[ ! "$vendor_name" ]]; then
|
||||||
|
vendor_name=mslite
|
||||||
|
fi
|
||||||
|
export OPP_CUSTOM_VENDOR=$vendor_name
|
||||||
|
|
||||||
|
# parse input parameters
|
||||||
|
clean=n
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
-h | --help)
|
||||||
|
echo " --help show the help info of using this shell"
|
||||||
|
echo " --kernel_so_name=* so name of aicpu custom operators "
|
||||||
|
echo " --toolchain_dir=* specify cross compile toolchain directory"
|
||||||
|
echo " clean clean compile result directory"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--so_name=*)
|
||||||
|
so_name=`echo ${1} | cut -d"=" -f2`
|
||||||
|
length=${#so_name}
|
||||||
|
aicpu_target_name=${so_name:3:($length - 6)}
|
||||||
|
export AICPU_KERNEL_TARGET=$aicpu_target_name
|
||||||
|
echo "aicpu_target_name=${aicpu_target_name}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
clean)
|
||||||
|
clean=y
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--toolchain_dir=*)
|
||||||
|
tool_dir=`echo ${1} | cut -d"=" -f2`
|
||||||
|
export TOOLCHAIN_DIR=$tool_dir
|
||||||
|
echo "specified TOOLCHAIN_DIR=$TOOLCHAIN_DIR"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
echo " --help show the help info of using this shell"
|
||||||
|
echo " --toolchain_dir=* specify cross compile toolchain directory"
|
||||||
|
echo " --so_name=* so name of aicpu custom operators generated by compilation"
|
||||||
|
echo " clean clean compile result directory"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# The following logic can be used without modification ######
|
||||||
|
log() {
|
||||||
|
cur_date=`date +"%Y-%m-%d %H:%M:%S"`
|
||||||
|
echo "[$cur_date] "$1
|
||||||
|
}
|
||||||
|
|
||||||
|
project_path=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
# clean compile result
|
||||||
|
if [ "x$clean" == "xy" ] 2>/dev/null; then
|
||||||
|
rm -rf $project_path/caffe.proto 2>/dev/null
|
||||||
|
rm -rf $project_path/caffe.proto.origin 2>/dev/null
|
||||||
|
rm -rf $project_path/build_out 2>/dev/null
|
||||||
|
rm -rf $project_path/framework/caffe_plugin/proto/caffe 2>/dev/null
|
||||||
|
log "[INFO] Clean successfully."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
#vendor_name output script/install.sh
|
||||||
|
vendor_name_output() {
|
||||||
|
scripts_file=$PWD/$1
|
||||||
|
found_vendor_name_field=$(grep -e "vendor_name=" "$scripts_file")
|
||||||
|
found_vendor_name=$(grep -e "vendor_name=" "$scripts_file" | cut --only-delimited -d"=" -f2-)
|
||||||
|
if [[ $found_vendor_name_field = "" ]]; then
|
||||||
|
sed -i "1 a vendor_name=$vendor_name" $scripts_file
|
||||||
|
elif [ $found_vendor_name_field != "" ] && [ $found_vendor_name != $vendor_name ]; then
|
||||||
|
sed -i "s/$found_vendor_name_field/vendor_name=$vendor_name/g" $scripts_file
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
vendor_name_output scripts/install.sh
|
||||||
|
vendor_name_output scripts/upgrade.sh
|
||||||
|
|
||||||
|
if [ ! "x$AICPU_SOC_VERSION" = "xLMIX" ];then
|
||||||
|
# if specified cross compile toolchain directory is not exist, log error and exit
|
||||||
|
if [[ ! -z "$TOOLCHAIN_DIR" ]] && [[ ! -d "$TOOLCHAIN_DIR" ]];then
|
||||||
|
log "[ERROR] Specified cross compile toolchain directory is not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set aicpu kernel implement compiler target, default to be custom_cpu_kernels
|
||||||
|
if [[ -z "${aicpu_target_name}" ]] && [[ -z "${AICPU_KERNEL_TARGET}" ]]; then
|
||||||
|
log "[INFO] no so_name is specified, use default compile target: libcust_aicpu_kernels.so!"
|
||||||
|
aicpu_target_name="cust_aicpu_kernels"
|
||||||
|
export AICPU_KERNEL_TARGET=$aicpu_target_name
|
||||||
|
#exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod -R 755 $project_path/cmake/util/
|
||||||
|
mkdir -p $project_path/build_out
|
||||||
|
|
||||||
|
###### Environment variable settings, need to set according to your own device ######
|
||||||
|
|
||||||
|
# ASCEND_TENSOR_COMPILER_INCLUDE: The path of the header file of the Compiler package, where "/usr/local/Ascend/compiler/include" is the
|
||||||
|
# default installation path. If user defines the installation path, please modify it.
|
||||||
|
# Uncomment and modify it when you specified installation path of Compiler.
|
||||||
|
if [[ -z "${ASCEND_TENSOR_COMPILER_INCLUDE}" ]]; then
|
||||||
|
if [[ -d "/usr/local/Ascend/compiler/include" ]];then
|
||||||
|
export ASCEND_TENSOR_COMPILER_INCLUDE=/usr/local/Ascend/compiler/include
|
||||||
|
else
|
||||||
|
log "[ERROR] ENV ASCEND_TENSOR_COMPILER_INCLUDE is not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ ! -d "${ASCEND_TENSOR_COMPILER_INCLUDE}" ]];then
|
||||||
|
log "[ERROR] ENV ASCEND_TENSOR_COMPILER_INCLUDE=${ASCEND_TENSOR_COMPILER_INCLUDE} dir is not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# STEP 1, Check plugin files and proto files
|
||||||
|
# Check for caffe_plugin files, If there is no plugin file, do not compile caffe proto.
|
||||||
|
caffe_plugin_cpp_files_num=$(ls $project_path/framework/caffe_plugin/*.cc 2> /dev/null | wc -l)
|
||||||
|
if [[ "$caffe_plugin_cpp_files_num" == 0 ]];then
|
||||||
|
log "[INFO] No caffe plugin files."
|
||||||
|
fi # endif compile caffe proto
|
||||||
|
|
||||||
|
# STEP 2, CMake and make
|
||||||
|
cd $project_path/build_out
|
||||||
|
rm -rf *.run
|
||||||
|
log "[INFO] Cmake begin."
|
||||||
|
|
||||||
|
if [ "x$AICPU_SOC_VERSION" = "xLMIX" ];then
|
||||||
|
CMAKE_ARGS="-DLMIX=TRUE"
|
||||||
|
cmake $CMAKE_ARGS ..
|
||||||
|
else
|
||||||
|
if [ "x$AICPU_SOC_VERSION" = "xAscend310RC" ];then
|
||||||
|
CMAKE_ARGS="-DMINRC=TRUE"
|
||||||
|
cmake $CMAKE_ARGS ..
|
||||||
|
else
|
||||||
|
cmake ..
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log "[ERROR] Please check cmake result."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "[INFO] Make begin."
|
||||||
|
make -j
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log "[ERROR] Please check make result."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
log "[INFO] Build successfully, the target is in $project_path/build_out."
|
|
@ -0,0 +1,118 @@
|
||||||
|
|
||||||
|
# set compile option -std=c++11
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
# set compile option -fPIC
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
set(OPP_CUSTOM_VENDOR "$ENV{OPP_CUSTOM_VENDOR}")
|
||||||
|
set(TOP_DIR ${CMAKE_SOURCE_DIR}/../..)
|
||||||
|
|
||||||
|
if(NOT DEFINED ASCEND_TENSOR_COMPILER_INCLUDE)
|
||||||
|
if(NOT "x$ENV{ASCEND_TENSOR_COMPILER_INCLUDE}" STREQUAL "x")
|
||||||
|
set(ASCEND_TENSOR_COMPILER_INCLUDE $ENV{ASCEND_TENSOR_COMPILER_INCLUDE})
|
||||||
|
else()
|
||||||
|
set(ASCEND_TENSOR_COMPILER_INCLUDE /usr/local/Ascend/compiler/include)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
message(STATUS "ASCEND_TENSOR_COMPILER_INCLUDE=${ASCEND_TENSOR_COMPILER_INCLUDE}")
|
||||||
|
|
||||||
|
set(ASCEND_INC ${ASCEND_TENSOR_COMPILER_INCLUDE})
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
if(NOT DEFINED SYSTEM_INFO)
|
||||||
|
if(NOT "x$ENV{SYSTEM_INFO}" STREQUAL "x")
|
||||||
|
set(SYSTEM_INFO $ENV{SYSTEM_INFO})
|
||||||
|
else()
|
||||||
|
execute_process(COMMAND grep -i ^id= /etc/os-release
|
||||||
|
OUTPUT_VARIABLE SYSTEM_NAME_INFO)
|
||||||
|
string(REGEX REPLACE "\n|id=|ID=|\"" "" SYSTEM_NAME ${SYSTEM_NAME_INFO})
|
||||||
|
message(STATUS "SYSTEM_NAME=${SYSTEM_NAME}")
|
||||||
|
set(SYSTEM_INFO ${SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "SYSTEM_INFO=${SYSTEM_INFO}")
|
||||||
|
elseif(WIN32)
|
||||||
|
message(STATUS "System is Windows. Only for pre-build.")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "${CMAKE_SYSTEM_NAME} not support.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(RUN_TARGET "custom_opp_${SYSTEM_INFO}.run")
|
||||||
|
message(STATUS "RUN_TARGET=${RUN_TARGET}")
|
||||||
|
set(PROJECT_DIR "vendors/mslite")
|
||||||
|
|
||||||
|
set(OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/makepkg)
|
||||||
|
message(STATUS "OUT_DIR=${OUT_DIR}")
|
||||||
|
|
||||||
|
set(TF_PLUGIN_TARGET "cust_tf_parsers")
|
||||||
|
set(TF_PLUGIN_TARGET_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/framework/tensorflow/)
|
||||||
|
|
||||||
|
set(ONNX_PLUGIN_TARGET "cust_onnx_parsers")
|
||||||
|
set(ONNX_PLUGIN_TARGET_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/framework/onnx/)
|
||||||
|
|
||||||
|
set(TF_SCOPE_FUSION_PASS_TARGET "cust_tf_scope_fusion")
|
||||||
|
set(TF_SCOPE_FUSION_PASS_TARGET_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/framework/tensorflow/)
|
||||||
|
|
||||||
|
set(CAFFE_PARSER_TARGET "_caffe_parser")
|
||||||
|
set(CAFFE_PLUGIN_TARGET "cust_caffe_parsers")
|
||||||
|
set(CAFFE_PLUGIN_TARGET_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/framework/caffe/)
|
||||||
|
|
||||||
|
set(OP_PROTO_TARGET "cust_op_proto")
|
||||||
|
set(OP_PROTO_TARGET_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/op_proto/)
|
||||||
|
|
||||||
|
set(OP_TILING_TARGET "optiling")
|
||||||
|
set(OP_TILING_TARGET_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/op_impl/ai_core/tbe/op_tiling)
|
||||||
|
|
||||||
|
set(AIC_FUSION_PASS_TARGET "cust_aic_fusion_pass")
|
||||||
|
set(AIC_FUSION_PASS_TARGET_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/fusion_pass/ai_core)
|
||||||
|
|
||||||
|
set(AIV_FUSION_PASS_TARGET "cust_aiv_fusion_pass")
|
||||||
|
set(AIV_FUSION_PASS_TARGET_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/fusion_pass/vector_core)
|
||||||
|
|
||||||
|
set(AIC_OP_INFO_CFG_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/op_impl/ai_core/tbe/config)
|
||||||
|
set(AIV_OP_INFO_CFG_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/op_impl/vector_core/tbe/config/)
|
||||||
|
|
||||||
|
set(AICPU_CONFIG_JSON_TARGET "aicpu_config_json")
|
||||||
|
set(AICPU_OP_INFO_CFG_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/op_impl/cpu/config)
|
||||||
|
set(AICPU_OP_IMPL_OUT_DIR ${OUT_DIR}/packages/${PROJECT_DIR}/op_impl/cpu/aicpu_kernel/impl/)
|
||||||
|
|
||||||
|
set(INI_2_JSON_PY "${CMAKE_SOURCE_DIR}/cmake/util/parse_ini_to_json.py")
|
||||||
|
set(AICPU_INI_2_JSON_PY "${CMAKE_SOURCE_DIR}/cmake/util/aicpu_parser_ini.py")
|
||||||
|
|
||||||
|
set(AICPU_KERNEL_TARGET $ENV{AICPU_KERNEL_TARGET})
|
||||||
|
|
||||||
|
set(CMAKE_SKIP_RPATH TRUE)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
|
||||||
|
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,relro,-z,now")
|
||||||
|
set(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -Wl,-z,relro,-z,now")
|
||||||
|
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
|
||||||
|
set(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -Wl,-z,noexecstack")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie")
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pie")
|
||||||
|
set(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -pie")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 -O2")
|
||||||
|
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fvisibility=hidden")
|
||||||
|
set(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -fvisibility=hidden")
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fvisibility-inlines-hidden")
|
||||||
|
set(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -fvisibility-inlines-hidden")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -ftrapv")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -fstack-check")
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG
|
||||||
|
"-fPIC -pthread -Wfloat-equal -Wshadow -Wformat=2 -Wno-deprecated -fstack-protector-strong -Wall -Wextra")
|
||||||
|
if("x${AICPU_KERNEL_TARGET}" STREQUAL "x")
|
||||||
|
set(AICPU_KERNEL_TARGET "cust_aicpu_kernels")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(${ASCEND_INC})
|
|
@ -0,0 +1,274 @@
|
||||||
|
# Copyright 2020 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.
|
||||||
|
|
||||||
|
"""
|
||||||
|
aicpu ini parser
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import stat
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
OP_INFO_ENGINE_VALUE = ["DNN_VM_AICPU", "DNN_VM_HOST_CPU"]
|
||||||
|
OP_INFO_FLAGPARTIAL_VALUE = ["False"]
|
||||||
|
OP_INFO_COMPUTECOST_VALUE = ["100"]
|
||||||
|
OP_INFO_SUBTYPE_OF_INFERSHAPE_VALUE = ["1", "2", "3", "4"]
|
||||||
|
BOOL_LIST = ["True", "False"]
|
||||||
|
TYPE_LIST = ["DT_UINT8", "DT_UINT16", "DT_INT8", "DT_INT16", "DT_INT32", "DT_INT64", "DT_UINT32", "DT_UINT64",
|
||||||
|
"DT_FLOAT16", "DT_FLOAT", "DT_DOUBLE", "DT_BOOL", "DT_COMPLEX64", "DT_COMPLEX128"]
|
||||||
|
FORMAT_LIST = ["ND", "NHWC", "NCHW"]
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ini_files(ini_files):
|
||||||
|
'''
|
||||||
|
init all ini files
|
||||||
|
'''
|
||||||
|
aicpu_ops_info = {}
|
||||||
|
for ini_file in ini_files:
|
||||||
|
check_file_size(ini_file)
|
||||||
|
parse_ini_to_obj(ini_file, aicpu_ops_info)
|
||||||
|
return aicpu_ops_info
|
||||||
|
|
||||||
|
|
||||||
|
def check_file_size(input_file):
|
||||||
|
try:
|
||||||
|
file_size = os.path.getsize(input_file)
|
||||||
|
except OSError as os_error:
|
||||||
|
print('[ERROR] Failed to open "%s". %s' % (input_file, str(os_error)))
|
||||||
|
raise OSError from os_error
|
||||||
|
if file_size > 10*1024*1024:
|
||||||
|
print('[WARN] The size of %s exceeds 10MB, it may take more time to run, please wait.' % input_file)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ini_to_obj(ini_file, aicpu_ops_info):
|
||||||
|
'''
|
||||||
|
parse all ini files to object
|
||||||
|
'''
|
||||||
|
with open(ini_file) as ini_read_file:
|
||||||
|
lines = ini_read_file.readlines()
|
||||||
|
ops = {}
|
||||||
|
find_op_type = False
|
||||||
|
for line in lines:
|
||||||
|
line = line.rstrip()
|
||||||
|
if line.startswith("["):
|
||||||
|
if line.endswith("]"):
|
||||||
|
op_name = line[1:-1]
|
||||||
|
ops = {}
|
||||||
|
aicpu_ops_info[op_name] = ops
|
||||||
|
find_op_type = True
|
||||||
|
elif "=" in line:
|
||||||
|
key1 = line[:line.index("=")]
|
||||||
|
key2 = line[line.index("=")+1:]
|
||||||
|
key1_0, key1_1 = key1.split(".")
|
||||||
|
if key1_0 not in ops:
|
||||||
|
ops[key1_0] = {}
|
||||||
|
dic_key = ops.get(key1_0)
|
||||||
|
dic_key[key1_1] = key2
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
if not find_op_type:
|
||||||
|
raise RuntimeError("Not find OpType in .ini file.")
|
||||||
|
|
||||||
|
|
||||||
|
def check_custom_op_opinfo(required_custom_op_info_keys, ops, op_key):
|
||||||
|
'''
|
||||||
|
check custom op info
|
||||||
|
'''
|
||||||
|
op_info = ops["opInfo"]
|
||||||
|
missing_keys = []
|
||||||
|
for required_op_info_key in required_custom_op_info_keys:
|
||||||
|
if required_op_info_key not in op_info:
|
||||||
|
missing_keys.append(required_op_info_key)
|
||||||
|
if missing_keys:
|
||||||
|
print("op: " + op_key + " opInfo missing: " + ",".join(missing_keys))
|
||||||
|
raise KeyError("Check opInfo failed!")
|
||||||
|
|
||||||
|
|
||||||
|
def check_opinfo_value(op_info):
|
||||||
|
"""
|
||||||
|
Function Description:
|
||||||
|
Check opinfo value
|
||||||
|
Parameter: op_info
|
||||||
|
"""
|
||||||
|
is_valid = True
|
||||||
|
check_key = ["engine", "flagPartial", "computeCost", "flagAsync", "subTypeOfInferShape", "flagSupportBlockDim"]
|
||||||
|
key_support = [OP_INFO_ENGINE_VALUE, OP_INFO_FLAGPARTIAL_VALUE, OP_INFO_COMPUTECOST_VALUE, BOOL_LIST,
|
||||||
|
OP_INFO_SUBTYPE_OF_INFERSHAPE_VALUE, BOOL_LIST]
|
||||||
|
for key, value_list in zip(check_key, key_support):
|
||||||
|
info_value = op_info.get(key)
|
||||||
|
if info_value is not None and info_value.strip() not in value_list:
|
||||||
|
is_valid = False
|
||||||
|
print("opInfo.{0} only support {1}.".format(key, value_list))
|
||||||
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
|
def check_op_opinfo(required_op_info_keys, required_custom_op_info_keys,
|
||||||
|
ops, op_key):
|
||||||
|
'''
|
||||||
|
check normal op info
|
||||||
|
'''
|
||||||
|
op_info = ops["opInfo"]
|
||||||
|
missing_keys = []
|
||||||
|
for required_op_info_key in required_op_info_keys:
|
||||||
|
if required_op_info_key not in op_info:
|
||||||
|
missing_keys.append(required_op_info_key)
|
||||||
|
if missing_keys:
|
||||||
|
print("op: " + op_key + " opInfo missing: " + ",".join(missing_keys))
|
||||||
|
raise KeyError("Check opInfo required key failed.")
|
||||||
|
if op_info["opKernelLib"] == "CUSTAICPUKernel":
|
||||||
|
check_custom_op_opinfo(required_custom_op_info_keys, ops, op_key)
|
||||||
|
ops["opInfo"]["userDefined"] = "True"
|
||||||
|
if not check_opinfo_value(op_info):
|
||||||
|
raise KeyError("Check opInfo value failed.")
|
||||||
|
|
||||||
|
|
||||||
|
def check_op_input_output(info, key, ops):
|
||||||
|
'''
|
||||||
|
check input and output infos of all ops
|
||||||
|
'''
|
||||||
|
op_input_output = ops.get(key)
|
||||||
|
for op_sets in op_input_output:
|
||||||
|
if op_sets not in ('format', 'type', 'name'):
|
||||||
|
print(info + " should has format type or name as the key, "
|
||||||
|
+ "but getting " + op_sets)
|
||||||
|
raise KeyError("Check input and output info failed.")
|
||||||
|
if not check_type_format(op_sets, op_input_output, key):
|
||||||
|
raise KeyError("Check input and output type or format failed.")
|
||||||
|
|
||||||
|
|
||||||
|
def check_type_format(op_key, op_dict, key_input_output):
|
||||||
|
"""
|
||||||
|
Function Description:
|
||||||
|
Check type and format
|
||||||
|
Parameter: op_key, such as name,type,format
|
||||||
|
Parameter: op_dict
|
||||||
|
Parameter: key_input_output, such as input0
|
||||||
|
"""
|
||||||
|
is_valid = True
|
||||||
|
type_format = ["type", "format"]
|
||||||
|
type_format_value = [TYPE_LIST, FORMAT_LIST]
|
||||||
|
for key, value_list in zip(type_format, type_format_value):
|
||||||
|
if op_key == key:
|
||||||
|
op_value_str = op_dict.get(key)
|
||||||
|
is_valid = check_value_valid(is_valid, key_input_output, op_key, op_value_str, value_list)
|
||||||
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
|
def check_value_valid(is_valid, key_input_output, op_key, op_value_str, value_list):
|
||||||
|
"""
|
||||||
|
Function Description:
|
||||||
|
Check value valid
|
||||||
|
Parameter: is_valid, bool
|
||||||
|
Parameter: key_input_output, such as input0
|
||||||
|
Parameter: op_key, such as name,type,format
|
||||||
|
Parameter: op_value_str,such as int8,int16
|
||||||
|
Parameter: value_list, support value
|
||||||
|
"""
|
||||||
|
if op_value_str:
|
||||||
|
for op_value in op_value_str.split(","):
|
||||||
|
if op_value.strip() not in value_list:
|
||||||
|
is_valid = False
|
||||||
|
print("{0}.{1} not support {2}.".format(key_input_output, op_key, op_value))
|
||||||
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
|
def check_op_info(aicpu_ops):
|
||||||
|
'''
|
||||||
|
check all ops
|
||||||
|
'''
|
||||||
|
print("==============check valid for aicpu ops info start==============")
|
||||||
|
required_op_info_keys = ["computeCost", "engine", "flagAsync",
|
||||||
|
"flagPartial", "opKernelLib", "kernelSo", "functionName"]
|
||||||
|
required_custom_op_info_keys = ["workspaceSize"]
|
||||||
|
|
||||||
|
for op_key in aicpu_ops:
|
||||||
|
ops = aicpu_ops[op_key]
|
||||||
|
for key in ops:
|
||||||
|
if key == "opInfo":
|
||||||
|
check_op_opinfo(required_op_info_keys,
|
||||||
|
required_custom_op_info_keys, ops, op_key)
|
||||||
|
|
||||||
|
elif (key[:5] == "input") and (key[5:].isdigit()):
|
||||||
|
check_op_input_output("input", key, ops)
|
||||||
|
elif (key[:6] == "output") and (key[6:].isdigit()):
|
||||||
|
check_op_input_output("output", key, ops)
|
||||||
|
elif (key[:13] == "dynamic_input") and (key[13:].isdigit()):
|
||||||
|
check_op_input_output("dynamic_input", key, ops)
|
||||||
|
elif (key[:14] == "dynamic_output") and (key[14:].isdigit()):
|
||||||
|
check_op_input_output("dynamic_output", key, ops)
|
||||||
|
else:
|
||||||
|
print("Only opInfo, input[0-9], output[0-9] can be used as a "
|
||||||
|
"key, but op %s has the key %s" % (op_key, key))
|
||||||
|
raise KeyError("bad key value")
|
||||||
|
print("==============check valid for aicpu ops info end================\n")
|
||||||
|
|
||||||
|
|
||||||
|
def write_json_file(aicpu_ops_info, json_file_path):
|
||||||
|
'''
|
||||||
|
write json file from ini file
|
||||||
|
'''
|
||||||
|
flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL
|
||||||
|
modes = stat.S_IWUSR | stat.S_IRUSR
|
||||||
|
json_file_real_path = os.path.realpath(json_file_path)
|
||||||
|
with os.fdopen(os.open(json_file_real_path, flags, modes), "w") as json_file:
|
||||||
|
# Only the owner and group have rights
|
||||||
|
os.chmod(json_file_real_path, stat.S_IWGRP + stat.S_IWUSR + stat.S_IRGRP
|
||||||
|
+ stat.S_IRUSR)
|
||||||
|
json.dump(aicpu_ops_info, json_file, sort_keys=True,
|
||||||
|
indent=4, separators=(',', ':'))
|
||||||
|
print("Compile aicpu op info cfg successfully.")
|
||||||
|
|
||||||
|
|
||||||
|
def dump_json(aicpu_ops_info, outfile_path_arg):
|
||||||
|
'''
|
||||||
|
dump_json
|
||||||
|
'''
|
||||||
|
check_op_info(aicpu_ops_info)
|
||||||
|
write_json_file(aicpu_ops_info, outfile_path_arg)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ini_to_json(ini_file_paths_arg, outfile_path_arg):
|
||||||
|
'''
|
||||||
|
parse ini to json
|
||||||
|
'''
|
||||||
|
aicpu_ops_info = parse_ini_files(ini_file_paths_arg)
|
||||||
|
check_flag = True
|
||||||
|
try:
|
||||||
|
dump_json(aicpu_ops_info, outfile_path_arg)
|
||||||
|
except KeyError:
|
||||||
|
check_flag = False
|
||||||
|
print("bad format key value, failed to generate json file")
|
||||||
|
return check_flag
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
get_args = sys.argv
|
||||||
|
|
||||||
|
OUTPUT = "tf_kernel.json"
|
||||||
|
ini_file_paths = []
|
||||||
|
|
||||||
|
for arg in get_args:
|
||||||
|
if arg.endswith("ini"):
|
||||||
|
ini_file_paths.append(arg)
|
||||||
|
if arg.endswith("json"):
|
||||||
|
OUTPUT = arg
|
||||||
|
|
||||||
|
if not ini_file_paths:
|
||||||
|
ini_file_paths.append("tf_kernel.ini")
|
||||||
|
|
||||||
|
if not parse_ini_to_json(ini_file_paths, OUTPUT):
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
project_path=$1
|
||||||
|
build_path=$2
|
||||||
|
vendor_name=mslite
|
||||||
|
if [[ ! -d "$project_path" ]]; then
|
||||||
|
echo "[ERROR] No projcet path is provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$build_path" ]]; then
|
||||||
|
echo "[ERROR] No build path is provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# copy ai_core operators implements
|
||||||
|
tbe_impl_files_num=$(ls $project_path/tbe/impl/* 2> /dev/null | wc -l)
|
||||||
|
if [[ "$tbe_impl_files_num" -gt 0 ]];then
|
||||||
|
cp -r ${project_path}/tbe/impl/* ${build_path}/makepkg/packages/vendors/$vendor_name/op_impl/ai_core/tbe/mslite_impl
|
||||||
|
cp -r ${project_path}/tbe/impl/* ${build_path}/makepkg/packages/vendors/$vendor_name/op_impl/vector_core/tbe/mslite_impl
|
||||||
|
fi
|
||||||
|
|
||||||
|
# copy aicpu kernel so operators
|
||||||
|
if [[ -d "${project_path}/cpukernel/aicpu_kernel_lib" ]]; then
|
||||||
|
cp -f ${project_path}/cpukernel/aicpu_kernel_lib/* ${build_path}/makepkg/packages/vendors/$vendor_name/op_impl/cpu/aicpu_kernel/impl
|
||||||
|
rm -rf ${project_path}/cpukernel/aicpu_kernel_lib
|
||||||
|
fi
|
||||||
|
|
||||||
|
# merge aicpu.ini and aicore.ini to generate npu_supported_ops.json
|
||||||
|
mkdir -p ${build_path}/framework/op_info_cfg
|
||||||
|
mkdir -p ${build_path}/framework/op_info_cfg/aicpu_kernel
|
||||||
|
mkdir -p ${build_path}/framework/op_info_cfg/ai_core
|
||||||
|
|
||||||
|
if [[ -d "${project_path}/tbe/op_info_cfg/ai_core" ]]; then
|
||||||
|
bash ${project_path}/cmake/util/gen_ops_filter.sh ${project_path}/tbe/op_info_cfg/ai_core ${build_path}/framework/op_info_cfg/ai_core
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -d "${project_path}/cpukernel/op_info_cfg/aicpu_kernel" ]]; then
|
||||||
|
bash ${project_path}/cmake/util/gen_ops_filter.sh ${project_path}/cpukernel/op_info_cfg/aicpu_kernel ${build_path}/framework/op_info_cfg/aicpu_kernel
|
||||||
|
fi
|
||||||
|
|
||||||
|
aicpu_filter_file=${build_path}/framework/op_info_cfg/aicpu_kernel/npu_supported_ops.json
|
||||||
|
aicore_filter_file=${build_path}/framework/op_info_cfg/ai_core/npu_supported_ops.json
|
||||||
|
if [[ -f "${aicpu_filter_file}" ]] && [[ ! -f "${aicore_filter_file}" ]]; then
|
||||||
|
cp $aicpu_filter_file ${build_path}/makepkg/packages/vendors/$vendor_name/framework/tensorflow
|
||||||
|
fi
|
||||||
|
if [[ -f "${aicore_filter_file}" ]] && [[ ! -f "${aicpu_filter_file}" ]]; then
|
||||||
|
cp $aicore_filter_file ${build_path}/makepkg/packages/vendors/$vendor_name/framework/tensorflow
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f "${aicore_filter_file}" ]] && [[ -f "${aicpu_filter_file}" ]]; then
|
||||||
|
chmod u+w ${aicpu_filter_file}
|
||||||
|
python3 ${project_path}/cmake/util/insert_op_info.py ${aicore_filter_file} ${aicpu_filter_file}
|
||||||
|
chmod u-w ${aicpu_filter_file}
|
||||||
|
cp $aicpu_filter_file ${build_path}/makepkg/packages/vendors/$vendor_name/framework/tensorflow
|
||||||
|
fi
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
# Description: Generate npu_supported_ops.json
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
echo -e "[ERROR] No source dir provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$2" ]]; then
|
||||||
|
echo -e "[ERROR] No destination dir provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
src=$1
|
||||||
|
dest_file=$2/npu_supported_ops.json
|
||||||
|
|
||||||
|
if [ -f "$dest_file" ];then
|
||||||
|
chmod u+w $dest_file
|
||||||
|
fi
|
||||||
|
|
||||||
|
add_ops() {
|
||||||
|
name=$1
|
||||||
|
isHeavy=$2
|
||||||
|
file=$3
|
||||||
|
grep -w "\"$name\"" ${file} >/dev/null
|
||||||
|
if [ $? == 0 ];then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo " \"${name}\": {" >> ${file}
|
||||||
|
echo " \"isGray\": false," >> ${file}
|
||||||
|
echo " \"isHeavy\": ${isHeavy}" >> ${file}
|
||||||
|
echo " }," >> ${file}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "{" > ${dest_file}
|
||||||
|
ini_files=$(find ${src} -name "*.ini")
|
||||||
|
for file in ${ini_files} ; do
|
||||||
|
name=$(grep '^\[' ${file} | sed 's/\[//g' | sed 's/]//g' | sed 's/\r//g')
|
||||||
|
grep 'heavyOp.flag' ${file} >/dev/null
|
||||||
|
if [ $? == 0 ];then
|
||||||
|
isHeavy=$(grep 'heavyOp.flag' ${file} | awk -F= '{print $2}')
|
||||||
|
else
|
||||||
|
isHeavy="false"
|
||||||
|
fi
|
||||||
|
add_ops ${name} ${isHeavy} ${dest_file}
|
||||||
|
done
|
||||||
|
echo "}" >> ${dest_file}
|
||||||
|
file_count=$(cat ${dest_file} | wc -l)
|
||||||
|
line=$(($file_count-1))
|
||||||
|
sed -i "${line}{s/,//g}" ${dest_file}
|
||||||
|
|
||||||
|
chmod 640 "${dest_file}"
|
||||||
|
echo -e "[INFO] Succeed generated ${dest_file}"
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,36 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Created on Feb 28 20:56:45 2020
|
||||||
|
Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import stat
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print(sys.argv)
|
||||||
|
print('argv error, inert_op_info.py your_op_file lib_op_file')
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
with open(sys.argv[1], 'r') as load_f:
|
||||||
|
insert_operator = json.load(load_f)
|
||||||
|
|
||||||
|
all_operators = {}
|
||||||
|
if os.path.exists(sys.argv[2]):
|
||||||
|
if os.path.getsize(sys.argv[2]) != 0:
|
||||||
|
with open(sys.argv[2], 'r') as load_f:
|
||||||
|
all_operators = json.load(load_f)
|
||||||
|
|
||||||
|
for k in insert_operator.keys():
|
||||||
|
if k in all_operators.keys():
|
||||||
|
print('replace op:[', k, '] success')
|
||||||
|
else:
|
||||||
|
print('insert op:[', k, '] success')
|
||||||
|
all_operators[k] = insert_operator[k]
|
||||||
|
|
||||||
|
flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL
|
||||||
|
modes = stat.S_IWUSR | stat.S_IRUSR
|
||||||
|
with os.fdopen(os.open(sys.argv[2], flags, modes), 'w') as json_file:
|
||||||
|
json_file.write(json.dumps(all_operators, indent=4))
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
project_path=$1
|
||||||
|
build_path=$2
|
||||||
|
vendor_name=mslite
|
||||||
|
|
||||||
|
if [[ ! -d "$project_path" ]]; then
|
||||||
|
echo "[ERROR] No projcet path is provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$build_path" ]]; then
|
||||||
|
echo "[ERROR] No build path is provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$ASCEND_OPP_PATH" ]]; then
|
||||||
|
echo "[ERROR] No opp install path is provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
custom_exist_info_json=$ASCEND_OPP_PATH/vendors/$vendor_name/op_impl/cpu/config/cust_aicpu_kernel.json
|
||||||
|
custom_new_info_json=$build_path/makepkg/packages/vendors/$vendor_name/op_impl/cpu/config/cust_aicpu_kernel.json
|
||||||
|
temp_info_json=$build_path/makepkg/packages/vendors/$vendor_name/op_impl/cpu/config/temp_cust_aicpu_kernel.json
|
||||||
|
|
||||||
|
if [[ -f "$custom_exist_info_json" ]] && [[ -f "$custom_new_info_json" ]]; then
|
||||||
|
cp -f $custom_exist_info_json $temp_info_json
|
||||||
|
chmod +w $temp_info_json
|
||||||
|
python3 ${project_path}/cmake/util/insert_op_info.py ${custom_new_info_json} ${temp_info_json}
|
||||||
|
cp -f $temp_info_json $custom_new_info_json
|
||||||
|
rm -f $temp_info_json
|
||||||
|
fi
|
|
@ -0,0 +1,345 @@
|
||||||
|
# Copyright 2020-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.
|
||||||
|
|
||||||
|
"""
|
||||||
|
parser ini to json
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import stat
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
ATTR_TYPE_LIST = ["int", "float", "bool", "str", "listInt", "listFloat", "listBool", "listStr", "listListInt",
|
||||||
|
"type", "listType", "tensor", "listTensor"]
|
||||||
|
ATTR_PARAMTYPE_LIST = ["optional", "required"]
|
||||||
|
BOOL_FLAG_KEY = ["dynamicFormat", "dynamicShapeSupport", "dynamicRankSupport", "precision_reduce", "heavyOp",
|
||||||
|
"needCheckSupport"]
|
||||||
|
BOOL_LIST = ["true", "false"]
|
||||||
|
DTYPE_LIST = ["float16", "float", "float32", "int8", "int16", "int32", "uint8", "uint16", "uint32", "bool",
|
||||||
|
"int64", "uint64", "qint8", "qint16", "qint32", "quint8", "quint16", "double", "complex64",
|
||||||
|
"complex128", "string", "resource"]
|
||||||
|
FORMAT_LIST = ["NCHW", "NHWC", "ND", "NC1HWC0", "FRACTAL_Z", "NC1C0HWPAD", "NHWC1C0", "FSR_NCHW", "FRACTAL_DECONV",
|
||||||
|
"C1HWNC0", "FRACTAL_DECONV_TRANSPOSE", "FRACTAL_DECONV_SP_STRIDE_TRANS", "NC1HWC0_C04",
|
||||||
|
"FRACTAL_Z_C04", "CHWN", "FRACTAL_DECONV_SP_STRIDE8_TRANS", "HWCN", "NC1KHKWHWC0", "BN_WEIGHT",
|
||||||
|
"FILTER_HWCK", "HASHTABLE_LOOKUP_LOOKUPS", "HASHTABLE_LOOKUP_KEYS", "HASHTABLE_LOOKUP_VALUE",
|
||||||
|
"HASHTABLE_LOOKUP_OUTPUT", "HASHTABLE_LOOKUP_HITS", "C1HWNCoC0", "MD", "NDHWC", "FRACTAL_ZZ",
|
||||||
|
"FRACTAL_NZ", "NCDHW", "DHWCN", "NDC1HWC0", "FRACTAL_Z_3D", "CN", "NC", "DHWNC",
|
||||||
|
"FRACTAL_Z_3D_TRANSPOSE", "FRACTAL_ZN_LSTM", "FRACTAL_ZN_RNN", "FRACTAL_Z_G", "NULL"]
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ini_files(ini_files):
|
||||||
|
"""
|
||||||
|
parse ini files to json
|
||||||
|
Parameters:
|
||||||
|
----------------
|
||||||
|
ini_files:input file list
|
||||||
|
return:ops_info
|
||||||
|
----------------
|
||||||
|
"""
|
||||||
|
tbe_ops_info = {}
|
||||||
|
for ini_file in ini_files:
|
||||||
|
check_file_size(ini_file)
|
||||||
|
parse_ini_to_obj(ini_file, tbe_ops_info)
|
||||||
|
return tbe_ops_info
|
||||||
|
|
||||||
|
|
||||||
|
def check_file_size(input_file):
|
||||||
|
try:
|
||||||
|
file_size = os.path.getsize(input_file)
|
||||||
|
except OSError as os_error:
|
||||||
|
print('[ERROR] Failed to open "%s". %s' % (input_file, str(os_error)))
|
||||||
|
raise OSError from os_error
|
||||||
|
if file_size > 10*1024*1024:
|
||||||
|
print('[WARN] The size of %s exceeds 10MB, it may take more time to run, please wait.' % input_file)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ini_to_obj(ini_file_path, tbe_ops_info):
|
||||||
|
"""
|
||||||
|
parse ini file to json obj
|
||||||
|
Parameters:
|
||||||
|
----------------
|
||||||
|
ini_file_path:ini file path
|
||||||
|
tbe_ops_info:ops_info
|
||||||
|
----------------
|
||||||
|
"""
|
||||||
|
with open(ini_file_path) as ini_file:
|
||||||
|
lines = ini_file.readlines()
|
||||||
|
op_dict = {}
|
||||||
|
op_name = ""
|
||||||
|
find_op_type = False
|
||||||
|
for line in lines:
|
||||||
|
line = line.rstrip()
|
||||||
|
if line == "":
|
||||||
|
continue
|
||||||
|
if line.startswith("["):
|
||||||
|
if line.endswith("]"):
|
||||||
|
op_name = line[1:-1]
|
||||||
|
op_dict = {}
|
||||||
|
tbe_ops_info[op_name] = op_dict
|
||||||
|
find_op_type = True
|
||||||
|
elif "=" in line:
|
||||||
|
key1 = line[:line.index("=")]
|
||||||
|
key2 = line[line.index("=")+1:]
|
||||||
|
key1_0, key1_1 = key1.split(".")
|
||||||
|
if not key1_0 in op_dict:
|
||||||
|
op_dict[key1_0] = {}
|
||||||
|
if key1_1 in op_dict.get(key1_0):
|
||||||
|
raise RuntimeError("Op:" + op_name + " " + key1_0 + " " +
|
||||||
|
key1_1 + " is repeated!")
|
||||||
|
dic_key = op_dict.get(key1_0)
|
||||||
|
dic_key[key1_1] = key2
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
if not find_op_type:
|
||||||
|
raise RuntimeError("Not find OpType in .ini file.")
|
||||||
|
|
||||||
|
|
||||||
|
def check_output_exist(op_dict, is_valid):
|
||||||
|
"""
|
||||||
|
Function Description:
|
||||||
|
Check output is exist
|
||||||
|
Parameter: op_dict
|
||||||
|
Parameter: is_valid
|
||||||
|
"""
|
||||||
|
if "output0" in op_dict:
|
||||||
|
output0_dict = op_dict.get("output0")
|
||||||
|
if output0_dict.get("name", None) is None:
|
||||||
|
is_valid = False
|
||||||
|
print("output0.name is required in .ini file!")
|
||||||
|
else:
|
||||||
|
is_valid = False
|
||||||
|
print("output0 is required in .ini file!")
|
||||||
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
|
def check_attr_dict(attr_dict, is_valid, attr):
|
||||||
|
"""
|
||||||
|
Function Description:
|
||||||
|
Check attr_dict
|
||||||
|
Parameter: attr_dict
|
||||||
|
Parameter: is_valid
|
||||||
|
Parameter: attr
|
||||||
|
"""
|
||||||
|
attr_type = attr_dict.get("type")
|
||||||
|
value = attr_dict.get("value")
|
||||||
|
param_type = attr_dict.get("paramType")
|
||||||
|
if attr_type is None or value is None:
|
||||||
|
is_valid = False
|
||||||
|
print(
|
||||||
|
"If attr.list is exist, {0}.type and {0}.value is required".format(attr))
|
||||||
|
if param_type and param_type not in ATTR_PARAMTYPE_LIST:
|
||||||
|
is_valid = False
|
||||||
|
print("{0}.paramType only support {1}.".format(
|
||||||
|
attr, ATTR_PARAMTYPE_LIST))
|
||||||
|
if attr_type and attr_type not in ATTR_TYPE_LIST:
|
||||||
|
is_valid = False
|
||||||
|
print("{0}.type only support {1}.".format(attr, ATTR_TYPE_LIST))
|
||||||
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
|
def check_attr(op_dict, is_valid):
|
||||||
|
"""
|
||||||
|
Function Description:
|
||||||
|
Check attr
|
||||||
|
Parameter: op_dict
|
||||||
|
Parameter: is_valid
|
||||||
|
"""
|
||||||
|
if "attr" in op_dict:
|
||||||
|
attr_dict = op_dict.get("attr")
|
||||||
|
attr_list_str = attr_dict.get("list", None)
|
||||||
|
if attr_list_str is None:
|
||||||
|
is_valid = False
|
||||||
|
print("attr.list is required in .ini file!")
|
||||||
|
else:
|
||||||
|
attr_list = attr_list_str.split(",")
|
||||||
|
for attr_name in attr_list:
|
||||||
|
attr = "attr_" + attr_name.strip()
|
||||||
|
attr_dict = op_dict.get(attr)
|
||||||
|
if attr_dict:
|
||||||
|
is_valid = check_attr_dict(attr_dict, is_valid, attr)
|
||||||
|
else:
|
||||||
|
is_valid = False
|
||||||
|
print("%s is required in .ini file, when attr.list is %s!" % (
|
||||||
|
attr, attr_list_str))
|
||||||
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
|
def check_bool_flag(op_dict, is_valid):
|
||||||
|
"""
|
||||||
|
Function Description:
|
||||||
|
check_bool_flag
|
||||||
|
Parameter: op_dict
|
||||||
|
Parameter: is_valid
|
||||||
|
"""
|
||||||
|
for key in BOOL_FLAG_KEY:
|
||||||
|
if key in op_dict:
|
||||||
|
op_bool_key = op_dict.get(key)
|
||||||
|
if op_bool_key.get("flag").strip() not in BOOL_LIST:
|
||||||
|
is_valid = False
|
||||||
|
print("{0}.flag only support {1}.".format(key, BOOL_LIST))
|
||||||
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
|
def check_type_format(op_info, is_valid, op_info_key):
|
||||||
|
"""
|
||||||
|
Function Description:
|
||||||
|
Check type and format
|
||||||
|
Parameter: op_info
|
||||||
|
Parameter: is_valid
|
||||||
|
Parameter: op_info_key
|
||||||
|
"""
|
||||||
|
op_info_dtype_str = op_info.get("dtype")
|
||||||
|
op_info_dtype_num = 0
|
||||||
|
op_info_format_num = 0
|
||||||
|
if op_info_dtype_str:
|
||||||
|
op_info_dtype = op_info_dtype_str.split(",")
|
||||||
|
op_info_dtype_num = len(op_info_dtype)
|
||||||
|
for dtype in op_info_dtype:
|
||||||
|
if dtype.strip() not in DTYPE_LIST:
|
||||||
|
is_valid = False
|
||||||
|
print("{0}.dtype not support {1}.".format(op_info_key, dtype))
|
||||||
|
op_info_format_str = op_info.get("format")
|
||||||
|
if op_info_format_str:
|
||||||
|
op_info_format = op_info_format_str.split(",")
|
||||||
|
op_info_format_num = len(op_info_format)
|
||||||
|
for op_format in op_info_format:
|
||||||
|
if op_format.strip() not in FORMAT_LIST:
|
||||||
|
is_valid = False
|
||||||
|
print("{0}.format not support {1}.".format(
|
||||||
|
op_info_key, op_format))
|
||||||
|
if op_info_dtype_num > 0 and op_info_format_num > 0:
|
||||||
|
if op_info_dtype_num != op_info_format_num:
|
||||||
|
is_valid = False
|
||||||
|
print("The number of {0}.dtype not match the number of {0}.format.".format(
|
||||||
|
op_info_key))
|
||||||
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
|
def check_op_info(tbe_ops):
|
||||||
|
"""
|
||||||
|
Function Description:
|
||||||
|
Check info.
|
||||||
|
Parameter: tbe_ops
|
||||||
|
Return Value: is_valid
|
||||||
|
"""
|
||||||
|
print("\n\n==============check valid for ops info start==============")
|
||||||
|
required_op_input_info_keys = ["paramType", "name"]
|
||||||
|
required_op_output_info_keys = ["paramType", "name"]
|
||||||
|
param_type_valid_value = ["dynamic", "optional", "required"]
|
||||||
|
is_valid = True
|
||||||
|
for op_key in tbe_ops:
|
||||||
|
op_dict = tbe_ops[op_key]
|
||||||
|
is_valid = check_output_exist(op_dict, is_valid)
|
||||||
|
for op_info_key in op_dict:
|
||||||
|
if op_info_key.startswith("input"):
|
||||||
|
op_input_info = op_dict[op_info_key]
|
||||||
|
missing_keys = []
|
||||||
|
for required_op_input_info_key in required_op_input_info_keys:
|
||||||
|
if not required_op_input_info_key in op_input_info:
|
||||||
|
missing_keys.append(required_op_input_info_key)
|
||||||
|
if missing_keys:
|
||||||
|
print("op: " + op_key + " " + op_info_key + " missing: " +
|
||||||
|
",".join(missing_keys))
|
||||||
|
is_valid = False
|
||||||
|
else:
|
||||||
|
if not op_input_info["paramType"] in param_type_valid_value:
|
||||||
|
print("op: " + op_key + " " + op_info_key +
|
||||||
|
" paramType not valid, valid key:[dynamic, "
|
||||||
|
"optional, required]")
|
||||||
|
is_valid = False
|
||||||
|
is_valid = check_type_format(
|
||||||
|
op_input_info, is_valid, op_info_key)
|
||||||
|
if op_info_key.startswith("output"):
|
||||||
|
op_input_info = op_dict[op_info_key]
|
||||||
|
missing_keys = []
|
||||||
|
for required_op_input_info_key in required_op_output_info_keys:
|
||||||
|
if not required_op_input_info_key in op_input_info:
|
||||||
|
missing_keys.append(required_op_input_info_key)
|
||||||
|
if missing_keys:
|
||||||
|
print("op: " + op_key + " " + op_info_key + " missing: " +
|
||||||
|
",".join(missing_keys))
|
||||||
|
is_valid = False
|
||||||
|
else:
|
||||||
|
if not op_input_info["paramType"] in param_type_valid_value:
|
||||||
|
print("op: " + op_key + " " + op_info_key +
|
||||||
|
" paramType not valid, valid key:[dynamic, "
|
||||||
|
"optional, required]")
|
||||||
|
is_valid = False
|
||||||
|
is_valid = check_type_format(
|
||||||
|
op_input_info, is_valid, op_info_key)
|
||||||
|
is_valid = check_attr(op_dict, is_valid)
|
||||||
|
is_valid = check_bool_flag(op_dict, is_valid)
|
||||||
|
print("==============check valid for ops info end================\n\n")
|
||||||
|
return is_valid
|
||||||
|
|
||||||
|
|
||||||
|
def write_json_file(tbe_ops_info, json_file_path):
|
||||||
|
"""
|
||||||
|
Save info to json file
|
||||||
|
Parameters:
|
||||||
|
----------------
|
||||||
|
tbe_ops_info: ops_info
|
||||||
|
json_file_path: json file path
|
||||||
|
----------------
|
||||||
|
"""
|
||||||
|
flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL
|
||||||
|
modes = stat.S_IWUSR | stat.S_IRUSR
|
||||||
|
json_file_real_path = os.path.realpath(json_file_path)
|
||||||
|
with os.fdopen(os.open(json_file_real_path, flags, modes), "w") as file_path:
|
||||||
|
# Only the owner and group have rights
|
||||||
|
os.chmod(json_file_real_path, stat.S_IWGRP + stat.S_IWUSR + stat.S_IRGRP
|
||||||
|
+ stat.S_IRUSR)
|
||||||
|
json.dump(tbe_ops_info, file_path, sort_keys=True, indent=4,
|
||||||
|
separators=(',', ':'))
|
||||||
|
print("Compile op info cfg successfully.")
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ini_to_json(ini_file_paths, outfile_path):
|
||||||
|
"""
|
||||||
|
parse ini files to json file
|
||||||
|
Parameters:
|
||||||
|
----------------
|
||||||
|
ini_file_paths: list of ini file path
|
||||||
|
outfile_path: output file path
|
||||||
|
----------------
|
||||||
|
"""
|
||||||
|
tbe_ops_info = parse_ini_files(ini_file_paths)
|
||||||
|
if not check_op_info(tbe_ops_info):
|
||||||
|
print("Compile op info cfg failed.")
|
||||||
|
return False
|
||||||
|
write_json_file(tbe_ops_info, outfile_path)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
args = sys.argv
|
||||||
|
|
||||||
|
output_file_path = "tbe_ops_info.json"
|
||||||
|
ini_file_path_list = []
|
||||||
|
|
||||||
|
for arg in args:
|
||||||
|
if arg.endswith("ini"):
|
||||||
|
ini_file_path_list.append(arg)
|
||||||
|
output_file_path = arg.replace(".ini", ".json")
|
||||||
|
if arg.endswith("json"):
|
||||||
|
output_file_path = arg
|
||||||
|
|
||||||
|
if not ini_file_path_list:
|
||||||
|
ini_file_path_list.append("tbe_ops_info.ini")
|
||||||
|
|
||||||
|
if not parse_ini_to_json(ini_file_path_list, output_file_path):
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
|
@ -0,0 +1,190 @@
|
||||||
|
# CMake minimum version number requirements
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(kernel)
|
||||||
|
set(TOOLCHAIN_DIR $ENV{TOOLCHAIN_DIR})
|
||||||
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -O2 -Wall -s")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -O0 -g -Wall")
|
||||||
|
set(CAMKE_SKIP_RPATH TRUE)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack -pie")
|
||||||
|
add_compile_options(
|
||||||
|
-fstack-protector-all
|
||||||
|
-D_FORTIFY_SOURCE=2 -O2
|
||||||
|
)
|
||||||
|
|
||||||
|
#Specify cross compiler
|
||||||
|
if(LMIX)
|
||||||
|
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
|
||||||
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}-g++)
|
||||||
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}-gcc)
|
||||||
|
else()
|
||||||
|
if(NOT "x${TOOLCHAIN_DIR}" STREQUAL "x")
|
||||||
|
if(NOT IS_DIRECTORY ${TOOLCHAIN_DIR})
|
||||||
|
message(FATAL_ERROR "specify cross compile toolchain directory(${TOOLCHAIN_DIR}) is not exist")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
message(STATUS "TOOLCHAIN_DIR=${TOOLCHAIN_DIR}")
|
||||||
|
if(MINRC)
|
||||||
|
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
|
||||||
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-g++)
|
||||||
|
else()
|
||||||
|
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
|
||||||
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-target-linux-gnu-g++)
|
||||||
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-target-linux-gnu-gcc)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
# =========================config json compile============================
|
||||||
|
macro(GEN_OPS_INFO_FILE op_type output_dir output_file_name_prefix)
|
||||||
|
|
||||||
|
SET(INI_PATH ${CMAKE_CURRENT_SOURCE_DIR}/op_info_cfg)
|
||||||
|
message(STATUS "ini file directory: ${CMAKE_CURRENT_SOURCE_DIR}/op_info_cfg")
|
||||||
|
if(NOT EXISTS ${INI_PATH})
|
||||||
|
set(INI_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
execute_process(COMMAND ls -1 ${INI_PATH}
|
||||||
|
OUTPUT_VARIABLE SUB_DIRS)
|
||||||
|
string(REPLACE "\n" ";" SUB_DIRS ${SUB_DIRS})
|
||||||
|
foreach(SUB_DIR ${SUB_DIRS})
|
||||||
|
if(IS_DIRECTORY ${INI_PATH}/${SUB_DIR})
|
||||||
|
execute_process(COMMAND find ${INI_PATH}/${SUB_DIR} -name "*.ini"
|
||||||
|
OUTPUT_VARIABLE INI_FILES)
|
||||||
|
if(NOT "x${INI_FILES}" STREQUAL "x")
|
||||||
|
string(REPLACE "\n" "\t" INI_FILES ${INI_FILES})
|
||||||
|
endif()
|
||||||
|
#string(REPLACE "\n" "\t" INI_FILES ${INI_FILES})
|
||||||
|
set(output_file_name ${output_file_name_prefix}_aicpu_kernel.json)
|
||||||
|
if(NOT "x${INI_FILES}" STREQUAL "x")
|
||||||
|
add_custom_command(OUTPUT ${output_file_name}
|
||||||
|
COMMAND echo "python3 ${AICPU_INI_2_JSON_PY} ${INI_FILES} ${output_dir}/${output_file_name}"
|
||||||
|
COMMAND mkdir -p ${output_dir}
|
||||||
|
COMMAND python3 ${AICPU_INI_2_JSON_PY} ${INI_FILES} ${output_dir}/${output_file_name}
|
||||||
|
COMMENT "generate configure json file")
|
||||||
|
set(OUTPUT_FILES ${OUTPUT_FILES} ${output_file_name})
|
||||||
|
else()
|
||||||
|
message(STATUS "ini file not exists.")
|
||||||
|
execute_process(COMMAND mkdir -p ${output_dir})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
if(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/op_info_cfg/aicpu_kernel)
|
||||||
|
add_custom_target(${AICPU_CONFIG_JSON_TARGET}
|
||||||
|
COMMAND echo "can not find directory ${CMAKE_CURRENT_SOURCE_DIR}/op_info_cfg/aicpu_kernel")
|
||||||
|
return(0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(OUTPUT_FILES "")
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
GEN_OPS_INFO_FILE("" ${AICPU_OP_INFO_CFG_OUT_DIR} cust)
|
||||||
|
|
||||||
|
if("x${OUTPUT_FILES}" STREQUAL "x")
|
||||||
|
add_custom_target(${AICPU_CONFIG_JSON_TARGET}
|
||||||
|
COMMAND echo "can not find ini file in ${CMAKE_CURRENT_SOURCE_DIR}/aicpu.")
|
||||||
|
return(0)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_target(${AICPU_CONFIG_JSON_TARGET} ALL DEPENDS ${OUTPUT_FILES}
|
||||||
|
COMMAND mkdir -p ${TF_PLUGIN_TARGET_OUT_DIR}
|
||||||
|
COMMAND bash ${CMAKE_SOURCE_DIR}/cmake/util/merge_aicpu_info_json.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
|
# =========================kernel compile============================
|
||||||
|
macro(SUBDIRLIST current_dir)
|
||||||
|
file(GLOB children RELATIVE ${current_dir} ${current_dir}/*)
|
||||||
|
set(SUB_DIR_LIST "")
|
||||||
|
foreach(child ${children})
|
||||||
|
if(IS_DIRECTORY ${current_dir}/${child})
|
||||||
|
LIST(APPEND SUB_DIR_LIST ${child})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# set compile option -std=c++11
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
# set compile option -fPIC
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
aux_source_directory(./impl/ KERNELS_SRCS)
|
||||||
|
|
||||||
|
if("x${KERNELS_SRCS}" STREQUAL "x")
|
||||||
|
add_custom_target(${AICPU_KERNEL_TARGET}
|
||||||
|
COMMAND echo "no source to make lib${AICPU_KERNEL_TARGET}.so")
|
||||||
|
return(0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(ASCEND_OPP_PATH $ENV{ASCEND_OPP_PATH})
|
||||||
|
if("x${ASCEND_OPP_PATH}" STREQUAL "x")
|
||||||
|
message(FATAL_ERROR "ENV ASCEND_OPP_PATH is not set")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
set(ASCEND_AICPU_PATH $ENV{ASCEND_AICPU_PATH})
|
||||||
|
if("x${ASCEND_AICPU_PATH}" STREQUAL "x")
|
||||||
|
message(FATAL_ERROR "ENV ASCEND_AICPU_PATH is not set")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(${ASCEND_OPP_PATH}/built-in/op_impl/aicpu/aicpu_kernel/inc)
|
||||||
|
|
||||||
|
# travers subdirectory
|
||||||
|
SUBDIRLIST(${CMAKE_CURRENT_SOURCE_DIR}/impl/third_party)
|
||||||
|
include_directories(./impl/third_party/${SUB_DIR_LIST})
|
||||||
|
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${AICPU_OP_IMPL_OUT_DIR})
|
||||||
|
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||||
|
add_library(${AICPU_KERNEL_TARGET} SHARED ${KERNELS_SRCS})
|
||||||
|
|
||||||
|
set(AICPU_SOC_VERSION $ENV{AICPU_SOC_VERSION})
|
||||||
|
message(STATUS "AICPU_SOC_VERSION=${AICPU_SOC_VERSION}")
|
||||||
|
|
||||||
|
set(AICPU_OPP_PATH Ascend)
|
||||||
|
if((AICPU_SOC_VERSION STREQUAL Ascend310) OR (AICPU_SOC_VERSION STREQUAL Ascend310P) OR
|
||||||
|
(AICPU_SOC_VERSION STREQUAL Ascend310RC) OR (AICPU_SOC_VERSION STREQUAL Ascend910))
|
||||||
|
set(AICPU_OPP_PATH ${AICPU_SOC_VERSION})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EXISTS "${ASCEND_AICPU_PATH}/opp/built-in/op_impl/aicpu/aicpu_kernel/lib/${AICPU_OPP_PATH}/libascend_protobuf.a")
|
||||||
|
target_link_libraries(${AICPU_KERNEL_TARGET} PRIVATE
|
||||||
|
-Wl,--whole-archive
|
||||||
|
${ASCEND_AICPU_PATH}/opp/built-in/op_impl/aicpu/aicpu_kernel/lib/${AICPU_OPP_PATH}/libascend_protobuf.a
|
||||||
|
-Wl,--no-whole-archive
|
||||||
|
-s
|
||||||
|
-Wl,-Bsymbolic
|
||||||
|
-Wl,--exclude-libs=libascend_protobuf.a
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Can not find libascend_protobuf.a in environment.
|
||||||
|
Please check whether the path of libascend_protobuf.a is correct or not")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EXISTS "${ASCEND_AICPU_PATH}/opp/built-in/op_impl/aicpu/aicpu_kernel/lib/${AICPU_OPP_PATH}/libcpu_kernels_context.a")
|
||||||
|
target_link_libraries(${AICPU_KERNEL_TARGET} PRIVATE
|
||||||
|
-Wl,--whole-archive
|
||||||
|
${ASCEND_AICPU_PATH}/opp/built-in/op_impl/aicpu/aicpu_kernel/lib/${AICPU_OPP_PATH}/libcpu_kernels_context.a
|
||||||
|
-Wl,--no-whole-archive
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
if(EXISTS "${ASCEND_AICPU_PATH}/opp/built-in/op_impl/aicpu/aicpu_kernel/lib/libcpu_kernels_context.a")
|
||||||
|
target_link_libraries(${AICPU_KERNEL_TARGET} PRIVATE
|
||||||
|
-Wl,--whole-archive
|
||||||
|
${ASCEND_AICPU_PATH}/opp/built-in/op_impl/aicpu/aicpu_kernel/lib/libcpu_kernels_context.a
|
||||||
|
-Wl,--no-whole-archive
|
||||||
|
)
|
||||||
|
elseif(EXISTS "${ASCEND_OPP_PATH}/built-in/op_impl/aicpu/aicpu_kernel/lib/device/libcpu_kernels_context.so")
|
||||||
|
target_link_libraries(${AICPU_KERNEL_TARGET} PRIVATE
|
||||||
|
-Wl,--whole-archive
|
||||||
|
${ASCEND_OPP_PATH}/built-in/op_impl/aicpu/aicpu_kernel/lib/device/libcpu_kernels_context.so
|
||||||
|
-Wl,--no-whole-archive
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Can not find libcpu_kernels_context.a
|
||||||
|
or libcpu_kernels_context.so in environment.
|
||||||
|
Please check whether the path of libcpu_kernels_context.a
|
||||||
|
or libcpu_kernels_context.so is correct or not")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
* Description: implement of AcosCpu
|
||||||
|
*/
|
||||||
|
#include "./acos_cpu_kernels.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const char *ACOS_CPU = "AcosCpu";
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace aicpu {
|
||||||
|
uint32_t AcosCpuCpuKernel::Compute(CpuKernelContext &ctx) {
|
||||||
|
Tensor *input = ctx.Input(0);
|
||||||
|
Tensor *output = ctx.Output(0);
|
||||||
|
|
||||||
|
if (input == nullptr || output == nullptr) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto inputData = static_cast<double *>(input->GetData());
|
||||||
|
auto outputData = static_cast<double *>(output->GetData());
|
||||||
|
if (inputData == nullptr || outputData == nullptr) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataType inputType = input->GetDataType();
|
||||||
|
switch (inputType) {
|
||||||
|
case DT_DOUBLE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto num = input->NumElements();
|
||||||
|
for (int64_t i = 0; i < num; i++) {
|
||||||
|
outputData[i] = std::acos(inputData[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_CPU_KERNEL(ACOS_CPU, AcosCpuCpuKernel);
|
||||||
|
} // namespace aicpu
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
* Description: api of AcosCpu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ACOS_CPU_KERNELS_H_
|
||||||
|
#define _ACOS_CPU_KERNELS_H_
|
||||||
|
|
||||||
|
#include "./cpu_kernel.h"
|
||||||
|
|
||||||
|
namespace aicpu {
|
||||||
|
class AcosCpuCpuKernel : public CpuKernel {
|
||||||
|
public:
|
||||||
|
~AcosCpuCpuKernel() = default;
|
||||||
|
uint32_t Compute(CpuKernelContext &ctx) override;
|
||||||
|
};
|
||||||
|
} // namespace aicpu
|
||||||
|
#endif
|
|
@ -0,0 +1,9 @@
|
||||||
|
[AcosCpu]
|
||||||
|
opInfo.engine=DNN_VM_AICPU
|
||||||
|
opInfo.flagPartial=False
|
||||||
|
opInfo.computeCost=100
|
||||||
|
opInfo.flagAsync=False
|
||||||
|
opInfo.opKernelLib=CUSTAICPUKernel
|
||||||
|
opInfo.kernelSo=libcust_aicpu_kernels.so
|
||||||
|
opInfo.functionName=RunCpuKernel
|
||||||
|
opInfo.workspaceSize=1024
|
|
@ -0,0 +1,37 @@
|
||||||
|
#this is required, only this variable is set, CMAKE recognize this is cross compilation
|
||||||
|
#in addition, CMAKE_CROSSCOMPILING is set true when CMAKE_SYSTEM_NAME is set
|
||||||
|
set(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
|
||||||
|
#Change the path to the absolute path of the cross compilation tool after the toolkit package is decompressed
|
||||||
|
# set cross compile toolchain dir
|
||||||
|
set(TOOLCHAIN_DIR $ENV{TOOLCHAIN_DIR})
|
||||||
|
#Specify cross compiler
|
||||||
|
if(LMIX)
|
||||||
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}-g++)
|
||||||
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}-gcc)
|
||||||
|
else()
|
||||||
|
if(NOT "x${TOOLCHAIN_DIR}" STREQUAL "x")
|
||||||
|
if(NOT IS_DIRECTORY ${TOOLCHAIN_DIR})
|
||||||
|
message(FATAL_ERROR "specify cross compile toolchain directory(${TOOLCHAIN_DIR}) is not exist")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
message(STATUS "TOOLCHAIN_DIR=${TOOLCHAIN_DIR}")
|
||||||
|
if(MINRC)
|
||||||
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gnu-g++)
|
||||||
|
else()
|
||||||
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-target-linux-gnu-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-target-linux-gnu-g++)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
#For FIND_PROGRAM(), there are three values, NEVER, ONLY, BOTH
|
||||||
|
#the first means not to search under your CMAKE_FIND_ROOT_PATH
|
||||||
|
#the second means to search only under this path
|
||||||
|
#the third means to find this path first, then Find the global path.
|
||||||
|
#For this variable, it is usually a program that calls the host, so it is generally set to NEVER
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
|
||||||
|
#The following three options indicate that only libraries and header files are found in the cross environment
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
if("x${CMAKE_CXX_COMPILER}" STREQUAL "x")
|
||||||
|
set(CMAKE_CXX_COMPILER g++)
|
||||||
|
endif()
|
||||||
|
if("x${CMAKE_C_COMPILER}" STREQUAL "x")
|
||||||
|
set(CMAKE_C_COMPILER gcc)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -O2 -Wall -s")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -O0 -g -Wall")
|
||||||
|
set(CAMKE_SKIP_RPATH TRUE)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack -pie")
|
||||||
|
add_compile_options(
|
||||||
|
-fstack-protector-all
|
||||||
|
-D_FORTIFY_SOURCE=2 -O2
|
||||||
|
)
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/caffe_plugin")
|
||||||
|
add_subdirectory(caffe_plugin)
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tf_plugin")
|
||||||
|
add_subdirectory(tf_plugin)
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tf_scope_fusion_pass")
|
||||||
|
add_subdirectory(tf_scope_fusion_pass)
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/onnx_plugin")
|
||||||
|
add_subdirectory(onnx_plugin)
|
||||||
|
endif()
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
aux_source_directory(. SRCS)
|
||||||
|
message(STATUS "SRCS = ${SRCS}")
|
||||||
|
|
||||||
|
if("x${SRCS}" STREQUAL "x")
|
||||||
|
add_custom_target(${TF_PLUGIN_TARGET}
|
||||||
|
COMMAND mkdir -p ${TF_PLUGIN_TARGET_OUT_DIR}
|
||||||
|
COMMAND echo "no source to make lib${TF_PLUGIN_TARGET}.so")
|
||||||
|
return(0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${TF_PLUGIN_TARGET_OUT_DIR})
|
||||||
|
|
||||||
|
add_library(${TF_PLUGIN_TARGET} SHARED ${SRCS})
|
||||||
|
|
||||||
|
target_compile_definitions(${TF_PLUGIN_TARGET} PRIVATE
|
||||||
|
google=ascend_private
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${TF_PLUGIN_TARGET} ${ASCEND_INC}/../lib64/libgraph.so)
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* Copyright (C) 2020-2021. Huawei Technologies Co., Ltd. All
|
||||||
|
rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the Apache License Version 2.0.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* Apache License for more details at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "register/register.h"
|
||||||
|
|
||||||
|
namespace domi {
|
||||||
|
// register op info to GE
|
||||||
|
REGISTER_CUSTOM_OP("AcosCpu")
|
||||||
|
.FrameworkType(TENSORFLOW) // type: CAFFE, TENSORFLOW
|
||||||
|
.OriginOpType("AcosCpu") // name in tf module
|
||||||
|
.ParseParamsByOperatorFn(AutoMappingByOpFn);
|
||||||
|
} // namespace domi
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* Copyright (C) 2020-2021. Huawei Technologies Co., Ltd. All
|
||||||
|
rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the Apache License Version 2.0.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* Apache License for more details at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "register/register.h"
|
||||||
|
|
||||||
|
namespace domi {
|
||||||
|
// register op info to GE
|
||||||
|
REGISTER_CUSTOM_OP("AddDSL")
|
||||||
|
.FrameworkType(TENSORFLOW) // type: CAFFE, TENSORFLOW
|
||||||
|
.OriginOpType("AddDSL") // name in tf module
|
||||||
|
.ParseParamsByOperatorFn(AutoMappingByOpFn);
|
||||||
|
} // namespace domi
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* Copyright (C) 2020-2021. Huawei Technologies Co., Ltd. All
|
||||||
|
rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the Apache License Version 2.0.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* Apache License for more details at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "register/register.h"
|
||||||
|
|
||||||
|
namespace domi {
|
||||||
|
// register op info to GE
|
||||||
|
REGISTER_CUSTOM_OP("AddTik")
|
||||||
|
.FrameworkType(TENSORFLOW) // type: CAFFE, TENSORFLOW
|
||||||
|
.OriginOpType("AddTik") // name in tf module
|
||||||
|
.ParseParamsByOperatorFn(AutoMappingByOpFn);
|
||||||
|
} // namespace domi
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
if("x${CMAKE_CXX_COMPILER}" STREQUAL "x")
|
||||||
|
set(CMAKE_CXX_COMPILER g++)
|
||||||
|
endif()
|
||||||
|
if("x${CMAKE_C_COMPILER}" STREQUAL "x")
|
||||||
|
set(CMAKE_C_COMPILER gcc)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -O2 -Wall -s")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -O0 -g -Wall")
|
||||||
|
set(CAMKE_SKIP_RPATH TRUE)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack -pie")
|
||||||
|
add_compile_options(
|
||||||
|
-fstack-protector-all
|
||||||
|
-D_FORTIFY_SOURCE=2 -O2
|
||||||
|
)
|
||||||
|
# add source files
|
||||||
|
aux_source_directory(. SRCS)
|
||||||
|
|
||||||
|
if("x${SRCS}" STREQUAL "x")
|
||||||
|
add_custom_target(${OP_PROTO_TARGET}
|
||||||
|
COMMAND mkdir -p ${OP_PROTO_TARGET_OUT_DIR}
|
||||||
|
COMMAND echo "no source to make lib${OP_PROTO_TARGET}.so")
|
||||||
|
return(0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${OP_PROTO_TARGET_OUT_DIR})
|
||||||
|
|
||||||
|
message(STATUS "OP_PROTO_TARGET=${OP_PROTO_TARGET}")
|
||||||
|
add_library(${OP_PROTO_TARGET} SHARED ${SRCS})
|
||||||
|
|
||||||
|
target_link_libraries(${OP_PROTO_TARGET} ${ASCEND_INC}/../lib64/libgraph.so)
|
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* Copyright 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "./acos_cpu.h"
|
||||||
|
namespace ge {
|
||||||
|
IMPLEMT_COMMON_INFERFUNC(AcosCpuInferShape) { return GRAPH_SUCCESS; }
|
||||||
|
|
||||||
|
IMPLEMT_VERIFIER(AcosCpu, AcosCpuVerify) { return GRAPH_SUCCESS; }
|
||||||
|
|
||||||
|
COMMON_INFER_FUNC_REG(AcosCpu, AcosCpuInferShape);
|
||||||
|
VERIFY_FUNC_REG(AcosCpu, AcosCpuVerify);
|
||||||
|
|
||||||
|
} // namespace ge
|
|
@ -0,0 +1,23 @@
|
||||||
|
/**
|
||||||
|
* Copyright 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GE_OP_ACOS_CPU_H
|
||||||
|
#define GE_OP_ACOS_CPU_H
|
||||||
|
#include "graph/operator_reg.h"
|
||||||
|
namespace ge {
|
||||||
|
REG_OP(AcosCpu).INPUT(x, TensorType({DT_DOUBLE})).OUTPUT(y, TensorType({DT_DOUBLE})).OP_END_FACTORY_REG(AcosCpu)
|
||||||
|
}
|
||||||
|
#endif // GE_OP_ACOS_CPU_H
|
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* Copyright 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "./add_dsl.h"
|
||||||
|
namespace ge {
|
||||||
|
IMPLEMT_COMMON_INFERFUNC(AddDSLInferShape) { return GRAPH_SUCCESS; }
|
||||||
|
|
||||||
|
IMPLEMT_VERIFIER(AddDSL, AddDSLVerify) { return GRAPH_SUCCESS; }
|
||||||
|
|
||||||
|
COMMON_INFER_FUNC_REG(AddDSL, AddDSLInferShape);
|
||||||
|
VERIFY_FUNC_REG(AddDSL, AddDSLVerify);
|
||||||
|
|
||||||
|
} // namespace ge
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* Copyright 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GE_OP_ADD_DSL_H
|
||||||
|
#define GE_OP_ADD_DSL_H
|
||||||
|
#include "graph/operator_reg.h"
|
||||||
|
namespace ge {
|
||||||
|
REG_OP(AddDSL)
|
||||||
|
.INPUT(x1, TensorType({DT_FLOAT16}))
|
||||||
|
.INPUT(x2, TensorType({DT_FLOAT16}))
|
||||||
|
.OUTPUT(y, TensorType({DT_FLOAT16}))
|
||||||
|
.OP_END_FACTORY_REG(AddDSL)
|
||||||
|
}
|
||||||
|
#endif // GE_OP_ADD_DSL_H
|
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* Copyright 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "./add_tik.h"
|
||||||
|
namespace ge {
|
||||||
|
IMPLEMT_COMMON_INFERFUNC(AddTikInferShape) { return GRAPH_SUCCESS; }
|
||||||
|
|
||||||
|
IMPLEMT_VERIFIER(AddTik, AddTikVerify) { return GRAPH_SUCCESS; }
|
||||||
|
|
||||||
|
COMMON_INFER_FUNC_REG(AddTik, AddTikInferShape);
|
||||||
|
VERIFY_FUNC_REG(AddTik, AddTikVerify);
|
||||||
|
|
||||||
|
} // namespace ge
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* Copyright 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GE_OP_ADD_TIK_H
|
||||||
|
#define GE_OP_ADD_TIK_H
|
||||||
|
#include "graph/operator_reg.h"
|
||||||
|
namespace ge {
|
||||||
|
REG_OP(AddTik)
|
||||||
|
.INPUT(x1, TensorType({DT_FLOAT16}))
|
||||||
|
.INPUT(x2, TensorType({DT_FLOAT16}))
|
||||||
|
.OUTPUT(y, TensorType({DT_FLOAT16}))
|
||||||
|
.OP_END_FACTORY_REG(AddTik)
|
||||||
|
}
|
||||||
|
#endif // GE_OP_ADD_TIK_H
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
if("x${CMAKE_CXX_COMPILER}" STREQUAL "x")
|
||||||
|
set(CMAKE_CXX_COMPILER g++)
|
||||||
|
endif()
|
||||||
|
if("x${CMAKE_C_COMPILER}" STREQUAL "x")
|
||||||
|
set(CMAKE_C_COMPILER gcc)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -O2 -Wall -s")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -O0 -g -Wall")
|
||||||
|
set(CAMKE_SKIP_RPATH TRUE)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack -pie")
|
||||||
|
add_compile_options(
|
||||||
|
-fstack-protector-all
|
||||||
|
-D_FORTIFY_SOURCE=2 -O2
|
||||||
|
)
|
||||||
|
# add source files
|
||||||
|
aux_source_directory(. SRCS)
|
||||||
|
|
||||||
|
if("x${SRCS}" STREQUAL "x")
|
||||||
|
add_custom_target(${OP_TILING_TARGET}
|
||||||
|
COMMAND mkdir -p ${OP_TILING_TARGET_OUT_DIR}
|
||||||
|
COMMAND echo "no source to make lib${OP_TILING_TARGET}.so")
|
||||||
|
return(0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${OP_TILING_TARGET_OUT_DIR})
|
||||||
|
|
||||||
|
message(STATUS "OP_TILING_TARGET=${OP_TILING_TARGET}")
|
||||||
|
add_library(${OP_TILING_TARGET} SHARED ${SRCS})
|
||||||
|
|
||||||
|
target_link_libraries(${OP_TILING_TARGET} ${ASCEND_INC}/../lib64/libgraph.so)
|
|
@ -0,0 +1,215 @@
|
||||||
|
#!/bin/bash
|
||||||
|
vendor_name=mslite
|
||||||
|
targetdir=/usr/local/Ascend/opp
|
||||||
|
|
||||||
|
sourcedir=$PWD/packages
|
||||||
|
vendordir=vendors/$vendor_name
|
||||||
|
|
||||||
|
QUIET="y"
|
||||||
|
|
||||||
|
for i in "$@"
|
||||||
|
do
|
||||||
|
echo $i
|
||||||
|
if test $i = "--quiet"; then
|
||||||
|
QUIET="y"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
log() {
|
||||||
|
cur_date=`date +"%Y-%m-%d %H:%M:%S"`
|
||||||
|
echo "[runtime] [$cur_date] "$1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "x${ASCEND_OPP_PATH}" == "x" ]];then
|
||||||
|
log "[ERROR] env ASCEND_OPP_PATH no exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
targetdir=${ASCEND_OPP_PATH}
|
||||||
|
|
||||||
|
if [ ! -d $targetdir ];then
|
||||||
|
log "[ERROR] $targetdir no exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
upgrade()
|
||||||
|
{
|
||||||
|
if [ ! -d ${sourcedir}/$vendordir/$1 ]; then
|
||||||
|
log "[INFO] no need to upgrade ops $1 files"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d ${targetdir}/$vendordir/$1 ];then
|
||||||
|
log "[INFO] create ${targetdir}/$vendordir/$1."
|
||||||
|
mkdir -p ${targetdir}/$vendordir/$1
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
log "[ERROR] create ${targetdir}/$vendordir/$1 failed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
has_same_file=-1
|
||||||
|
for file_a in ${sourcedir}/$vendordir/$1/*; do
|
||||||
|
file_b=${file_a##*/};
|
||||||
|
if [ "`ls ${targetdir}/${vendordir}/$1`" = "" ]; then
|
||||||
|
log "[INFO] ${targetdir}/$vendordir/$1 is empty !!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
ls_val=`ls "${targetdir}/${vendordir}/$1"`
|
||||||
|
grep -q $file_b <<< $ls_val;
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo -n "${file_b} "
|
||||||
|
has_same_file=0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ 0 -eq $has_same_file ]; then
|
||||||
|
if test $QUIET = "n"; then
|
||||||
|
echo "[INFO]: has old version in ${targetdir}/$vendordir/$1, \
|
||||||
|
you want to Overlay Installation , please enter:[o]; \
|
||||||
|
or replace directory installation , please enter: [r]; \
|
||||||
|
or not install , please enter:[n]."
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
read orn
|
||||||
|
if [ "$orn" = n ]; then
|
||||||
|
return 0
|
||||||
|
elif [ "$orn" = m ]; then
|
||||||
|
break;
|
||||||
|
elif [ "$orn" = r ]; then
|
||||||
|
rm_target="${targetdir}/${vendordir}/$1/*"
|
||||||
|
rm -rf $rm_target
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
echo "[ERROR] input error, please input again!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
log "[INFO] replace or merge old ops $1 files .g....."
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "copy new ops $1 files ......"
|
||||||
|
if [ -d ${targetdir}/$vendordir/$1/ ]; then
|
||||||
|
chmod -R +w "$targetdir/$vendordir/$1/" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
cp -rf ${sourcedir}/$vendordir/$1/* $targetdir/$vendordir/$1/
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
log "[ERROR] copy new $1 files failed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
upgrade_proto()
|
||||||
|
{
|
||||||
|
if [ ! -f ${sourcedir}/$vendordir/custom.proto ]; then
|
||||||
|
log "[INFO] no need to upgrade custom.proto files"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [ ! -d ${targetdir}/$vendordir/framework/caffe ];then
|
||||||
|
log "[INFO] create ${targetdir}/$vendordir/framework/caffe."
|
||||||
|
mkdir -p ${targetdir}/$vendordir/framework/caffe
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
log "[ERROR] create ${targetdir}/$vendordir/framework/caffe failed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ -f ${targetdir}/$vendordir/framework/caffe/custom.proto ]; then
|
||||||
|
# 有老版本,判断是否要覆盖式安装
|
||||||
|
if test $QUIET = "n"; then
|
||||||
|
echo "[INFO] ${targetdir}/$vendordir/framework/caffe has old version"\
|
||||||
|
"custom.proto file. Do you want to replace? [y/n] "
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
read yn
|
||||||
|
if [ "$yn" = n ]; then
|
||||||
|
return 0
|
||||||
|
elif [ "$yn" = y ]; then
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
echo "[ERROR] input error, please input again!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
log "[INFO] replace old caffe.proto files ......"
|
||||||
|
fi
|
||||||
|
chmod -R +w "$targetdir/$vendordir/framework/caffe/" >/dev/null 2>&1
|
||||||
|
cp -rf ${sourcedir}/$vendordir/custom.proto ${targetdir}/$vendordir/framework/caffe/
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
log "[ERROR] copy new custom.proto failed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
log "[INFO] copy custom.proto success"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
log "[INFO] copy uninstall sh success"
|
||||||
|
|
||||||
|
if [ ! -d ${targetdir}/vendors ];then
|
||||||
|
log "[INFO] create ${targetdir}/vendors."
|
||||||
|
mkdir -p ${targetdir}/vendors
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
log "[ERROR] create ${targetdir}/vendors failed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
chmod u+w ${targetdir}/vendors
|
||||||
|
|
||||||
|
echo "[ops_custom]upgrade framework"
|
||||||
|
upgrade framework
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[ops_custom]upgrade op proto"
|
||||||
|
upgrade op_proto
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[ops_custom]upgrade op impl"
|
||||||
|
upgrade op_impl
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
upgrade_proto
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
config_file=${targetdir}/vendors/config.ini
|
||||||
|
if [ ! -f ${config_file} ]; then
|
||||||
|
touch ${config_file}
|
||||||
|
chmod 550 ${config_file}
|
||||||
|
fi
|
||||||
|
|
||||||
|
found_vendors="$(grep -w "load_priority" "$config_file" | cut --only-delimited -d"=" -f2-)"
|
||||||
|
found_vendor=$(echo $found_vendors | sed "s/$vendor_name//g" | tr ',' ' ')
|
||||||
|
vendor=$(echo $found_vendor | tr -s ' ' ',')
|
||||||
|
if [ "$vendor" != "" ]; then
|
||||||
|
sed -i "/load_priority=$found_vendors/s@load_priority=$found_vendors@load_priority=$vendor_name,$vendor@g" "$config_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod u-w ${targetdir}/vendors
|
||||||
|
|
||||||
|
if [ -d ${targetdir}/$vendordir/op_impl/cpu/aicpu_kernel/impl/ ]; then
|
||||||
|
chmod -R 440 ${targetdir}/$vendordir/op_impl/cpu/aicpu_kernel/impl/* >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
if [ -f ${targetdir}/ascend_install.info ]; then
|
||||||
|
chmod -R 440 ${targetdir}/ascend_install.info
|
||||||
|
fi
|
||||||
|
if [ -f ${targetdir}/scene.info ]; then
|
||||||
|
chmod -R 440 ${targetdir}/scene.info
|
||||||
|
fi
|
||||||
|
if [ -f ${targetdir}/version.info ]; then
|
||||||
|
chmod -R 440 ${targetdir}/version.info
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "SUCCESS"
|
||||||
|
exit 0
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
#!/bin/bash
|
||||||
|
vendor_name=mslite
|
||||||
|
targetdir=/usr/local/Ascend/opp
|
||||||
|
|
||||||
|
sourcedir=$PWD/packages
|
||||||
|
vendordir=vendors/$vendor_name
|
||||||
|
|
||||||
|
log() {
|
||||||
|
cur_date=`date +"%Y-%m-%d %H:%M:%S"`
|
||||||
|
echo "[runtime] [$cur_date] "$1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "x${ASCEND_OPP_PATH}" == "x" ]];then
|
||||||
|
log "[ERROR] env ASCEND_OPP_PATH no exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
targetdir=${ASCEND_OPP_PATH}
|
||||||
|
|
||||||
|
if [ ! -d $targetdir ];then
|
||||||
|
log "[ERROR] $targetdir no exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
upgrade()
|
||||||
|
{
|
||||||
|
if [ ! -d ${sourcedir}/$vendordir/$1 ]; then
|
||||||
|
log "[INFO] no need to upgrade ops $1 files"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d ${targetdir}/$vendordir/$1 ]; then
|
||||||
|
log "[INFO] create ${targetdir}/$vendordir/$1."
|
||||||
|
mkdir -p ${targetdir}/$vendordir/$1
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
log "[ERROR] create ${targetdir}/$vendordir/$1 failed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
vendor_installed_dir=$(ls "$targetdir/vendors" 2> /dev/null)
|
||||||
|
for i in $vendor_installed_dir;do
|
||||||
|
vendor_installed_file=$(ls "$vendor_installed_dir/$vendor_name/$i" 2> /dev/null)
|
||||||
|
if [ "$i" = "$vendor_name" ] && [ "$vendor_installed_file" != "" ]; then
|
||||||
|
echo "[INFO]: $vendor_name custom opp package has been installed on the path $vendor_installed_dir, \
|
||||||
|
you want to Overlay Installation , please enter:[o]; \
|
||||||
|
or replace directory installation , please enter: [r]; \
|
||||||
|
or not install , please enter:[n]."
|
||||||
|
fi
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
read mrn
|
||||||
|
if [ "$mrn" = m ]; then
|
||||||
|
break
|
||||||
|
elif [ "$mrn" = r ]; then
|
||||||
|
[ -n "$vendor_installed_file" ] && rm -rf "$vendor_installed_file"
|
||||||
|
break
|
||||||
|
elif [ "$mrn" = n ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "[WARNING]: Input error, please input m or r or n to choose!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
log "[INFO] replace old ops $1 files ......"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "copy new ops $1 files ......"
|
||||||
|
cp -rf ${sourcedir}/$vendordir/$1/* $targetdir/$vendordir/$1/
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
log "[ERROR] copy new $1 files failed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
log "[INFO] copy uninstall sh success"
|
||||||
|
|
||||||
|
echo "[ops_custom]upgrade framework"
|
||||||
|
upgrade framework
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[ops_custom]upgrade op proto"
|
||||||
|
upgrade op_proto
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[ops_custom]upgrade op impl"
|
||||||
|
upgrade op_impl
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
config_file=${targetdir}/vendors/config.ini
|
||||||
|
found_vendors="$(grep -w "load_priority" "$config_file" | cut --only-delimited -d"=" -f2-)"
|
||||||
|
found_vendor=$(echo $found_vendors | sed "s/$vendor_name//g" | tr ',' ' ')
|
||||||
|
vendor=$(echo $found_vendor | tr -s ' ' ',')
|
||||||
|
if [ "$vendor" != "" ]; then
|
||||||
|
sed -i "/load_priority=$found_vendors/s@load_priority=$found_vendors@load_priority=$vendor_name,$vendor@g" "$config_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
changemode()
|
||||||
|
{
|
||||||
|
if [ -d ${targetdir} ];then
|
||||||
|
chmod -R 550 ${targetdir}>/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
echo "[ops_custom]changemode..."
|
||||||
|
#changemode
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "SUCCESS"
|
||||||
|
exit 0
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -O2 -Wall -s")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -O0 -g -Wall")
|
||||||
|
set(CAMKE_SKIP_RPATH TRUE)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack -pie")
|
||||||
|
add_compile_options(
|
||||||
|
-fstack-protector-all
|
||||||
|
-D_FORTIFY_SOURCE=2 -O2
|
||||||
|
)
|
||||||
|
|
||||||
|
macro(GEN_OPS_INFO_FILE op_type output_dir output_file_name_prefix)
|
||||||
|
|
||||||
|
SET(INI_PATH ${CMAKE_CURRENT_SOURCE_DIR}/op_info_cfg/${op_type})
|
||||||
|
if(NOT EXISTS ${INI_PATH})
|
||||||
|
set(INI_PATH ${CMAKE_CURRENT_SOURCE_DIR}/op_info_cfg.${op_type})
|
||||||
|
endif()
|
||||||
|
execute_process(COMMAND ls -1 ${INI_PATH}
|
||||||
|
OUTPUT_VARIABLE SUB_DIRS)
|
||||||
|
string(REPLACE "\n" ";" SUB_DIRS ${SUB_DIRS})
|
||||||
|
foreach(SUB_DIR ${SUB_DIRS})
|
||||||
|
if(IS_DIRECTORY ${INI_PATH}/${SUB_DIR})
|
||||||
|
execute_process(COMMAND find ${INI_PATH}/${SUB_DIR} -name "*.ini"
|
||||||
|
OUTPUT_VARIABLE INI_FILES)
|
||||||
|
string(REPLACE "\n" "\t" INI_FILES ${INI_FILES})
|
||||||
|
set(output_file_name ${output_file_name_prefix}-${SUB_DIR}-ops-info.json)
|
||||||
|
if(NOT "x${INI_FILES}" STREQUAL "x")
|
||||||
|
add_custom_command(OUTPUT ${output_file_name}
|
||||||
|
COMMAND echo "python3 ${INI_2_JSON_PY} ${INI_FILES} ${output_dir}/${output_file_name}"
|
||||||
|
COMMAND mkdir -p ${output_dir}/${SUB_DIR}
|
||||||
|
COMMAND python3 ${INI_2_JSON_PY} ${INI_FILES} ${output_dir}/${SUB_DIR}/${output_file_name}
|
||||||
|
COMMENT "generate configure json file")
|
||||||
|
set(OUTPUT_FILES ${OUTPUT_FILES} ${output_file_name})
|
||||||
|
else()
|
||||||
|
message(STATUS "ini file not exists.")
|
||||||
|
execute_process(COMMAND mkdir -p ${output_dir})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
set(OUTPUT_FILES "")
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
GEN_OPS_INFO_FILE(ai_core ${AIC_OP_INFO_CFG_OUT_DIR} aic)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "OUTPUT_FILES=${OUTPUT_FILES}")
|
||||||
|
if "x${OUTPUT_FILES}" STREQUAL "x")
|
||||||
|
add_custom_target(config_json
|
||||||
|
COMMAND echo "tbe_aic_ops_info.ini and tbe_aiv_ops_info.ini not exist.")
|
||||||
|
return(0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_target(config_json ALL DEPENDS ${OUTPUT_FILES}
|
||||||
|
COMMAND mkdir -p ${TF_PLUGIN_TARGET_OUT_DIR}
|
||||||
|
COMMAND bash ${CMAKE_SOURCE_DIR}/cmake/util/gen_ops_filter.sh ${INI_PATH} ${TF_PLUGIN_TARGET_OUT_DIR})
|
||||||
|
|
||||||
|
if(NOT "x$ENV{ADD_TESTCASE}" STREQUAL "x")
|
||||||
|
# add testcases subdirectory
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/testcases/bbit")
|
||||||
|
add_subdirectory(testcases/bbit)
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/testcases/st")
|
||||||
|
add_subdirectory(testcases/st)
|
||||||
|
endif()
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/testcases/acl_op/src")
|
||||||
|
add_subdirectory(testcases/acl_op/src)
|
||||||
|
endif()
|
||||||
|
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/testcases/st_cases/out/*")
|
||||||
|
foreach(file ${files})
|
||||||
|
message(STATUS ${file})
|
||||||
|
if(IS_DIRECTORY ${file})
|
||||||
|
add_subdirectory(${file})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
|
@ -0,0 +1,46 @@
|
||||||
|
# Copyright 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.
|
||||||
|
# ============================================================================
|
||||||
|
"""ascend custom op: add by dsl"""
|
||||||
|
import tbe.dsl as tbe
|
||||||
|
from tbe import tvm
|
||||||
|
from tbe.common.register import register_op_compute
|
||||||
|
from tbe.common.utils import para_check
|
||||||
|
|
||||||
|
|
||||||
|
@register_op_compute("add_dsl")
|
||||||
|
def add_dsl_compute(x1, x2, y, kernel_name="add_dsl"):
|
||||||
|
res = tbe.vadd(x1, x2)
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
@para_check.check_op_params(para_check.REQUIRED_INPUT, para_check.REQUIRED_INPUT,
|
||||||
|
para_check.REQUIRED_OUTPUT, para_check.KERNEL_NAME)
|
||||||
|
def add_dsl(x1, x2, y, kernel_name="add_dsl"):
|
||||||
|
"""add dsl impl function"""
|
||||||
|
data_x1 = tvm.placeholder(
|
||||||
|
x1.get("shape"), dtype=x1.get("dtype"), name="data_x1")
|
||||||
|
data_x2 = tvm.placeholder(
|
||||||
|
x2.get("shape"), dtype=x2.get("dtype"), name="data_x2")
|
||||||
|
|
||||||
|
res = add_dsl_compute(data_x1, data_x2, y, kernel_name)
|
||||||
|
|
||||||
|
# auto schedule
|
||||||
|
with tvm.target.cce():
|
||||||
|
schedule = tbe.auto_schedule(res)
|
||||||
|
|
||||||
|
# operator build
|
||||||
|
config = {"name": kernel_name,
|
||||||
|
"tensor_list": [data_x1, data_x2, res]}
|
||||||
|
tbe.build(schedule, config)
|
|
@ -0,0 +1,51 @@
|
||||||
|
# Copyright 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.
|
||||||
|
# ============================================================================
|
||||||
|
"""ascend custom op: add by tik"""
|
||||||
|
from tbe.common.register import register_op_compute
|
||||||
|
from tbe.common.utils import para_check
|
||||||
|
from tbe import tik
|
||||||
|
|
||||||
|
|
||||||
|
@register_op_compute("AddTik")
|
||||||
|
@para_check.check_op_params(para_check.REQUIRED_INPUT, para_check.REQUIRED_INPUT,
|
||||||
|
para_check.REQUIRED_OUTPUT, para_check.KERNEL_NAME)
|
||||||
|
def add_tik(x1, x2, y, kernel_name="add_tik"):
|
||||||
|
"""add dsl impl function"""
|
||||||
|
tik_instance = tik.Tik()
|
||||||
|
x1_shape = x1.get("shape")
|
||||||
|
x2_shape = x2.get("shape")
|
||||||
|
y_shape = y.get("shape")
|
||||||
|
|
||||||
|
data_a = tik_instance.Tensor(
|
||||||
|
"float16", x1_shape, name="x1", scope=tik.scope_gm)
|
||||||
|
data_b = tik_instance.Tensor(
|
||||||
|
"float16", x2_shape, name="x2", scope=tik.scope_gm)
|
||||||
|
data_c = tik_instance.Tensor(
|
||||||
|
"float16", y_shape, name="y", scope=tik.scope_gm)
|
||||||
|
data_a_ub = tik_instance.Tensor(
|
||||||
|
"float16", x1_shape, name="data_A_ub", scope=tik.scope_ubuf)
|
||||||
|
data_b_ub = tik_instance.Tensor(
|
||||||
|
"float16", x2_shape, name="data_B_ub", scope=tik.scope_ubuf)
|
||||||
|
data_c_ub = tik_instance.Tensor(
|
||||||
|
"float16", y_shape, name="data_C_ub", scope=tik.scope_ubuf)
|
||||||
|
|
||||||
|
tik_instance.data_move(data_a_ub, data_a, 0, 1, 128 // 16, 0, 0)
|
||||||
|
tik_instance.data_move(data_b_ub, data_b, 0, 1, 128 // 16, 0, 0)
|
||||||
|
tik_instance.vec_add(
|
||||||
|
128, data_c_ub[0], data_a_ub[0], data_b_ub[0], 1, 8, 8, 8)
|
||||||
|
tik_instance.data_move(data_c, data_c_ub, 0, 1, 128 // 16, 0, 0)
|
||||||
|
tik_instance.BuildCCE(kernel_name=kernel_name, inputs=[data_a, data_b], outputs=[data_c])
|
||||||
|
|
||||||
|
return tik_instance
|
|
@ -0,0 +1,15 @@
|
||||||
|
[AddDSL]
|
||||||
|
input0.name=x1
|
||||||
|
input0.dtype=float16
|
||||||
|
input0.paramType=required
|
||||||
|
input0.format=NCHW
|
||||||
|
input1.name=x2
|
||||||
|
input1.dtype=float16
|
||||||
|
input1.paramType=required
|
||||||
|
input1.format=NCHW
|
||||||
|
output0.name=y
|
||||||
|
output0.dtype=float16
|
||||||
|
output0.paramType=required
|
||||||
|
output0.format=NCHW
|
||||||
|
opFile.value=add_dsl
|
||||||
|
opInterface.value=add_dsl
|
|
@ -0,0 +1,15 @@
|
||||||
|
[AddTik]
|
||||||
|
input0.name=x1
|
||||||
|
input0.dtype=float16
|
||||||
|
input0.paramType=required
|
||||||
|
input0.format=ND
|
||||||
|
input1.name=x2
|
||||||
|
input1.dtype=float16
|
||||||
|
input1.paramType=required
|
||||||
|
input1.format=ND
|
||||||
|
output0.name=y
|
||||||
|
output0.dtype=float16
|
||||||
|
output0.paramType=required
|
||||||
|
output0.format=ND
|
||||||
|
opFile.value=add_tik
|
||||||
|
opInterface.value=add_tik
|
|
@ -0,0 +1,15 @@
|
||||||
|
[AddDSL]
|
||||||
|
input0.name=x1
|
||||||
|
input0.dtype=float16
|
||||||
|
input0.paramType=required
|
||||||
|
input0.format=NCHW
|
||||||
|
input1.name=x2
|
||||||
|
input1.dtype=float16
|
||||||
|
input1.paramType=required
|
||||||
|
input1.format=NCHW
|
||||||
|
output0.name=y
|
||||||
|
output0.dtype=float16
|
||||||
|
output0.paramType=required
|
||||||
|
output0.format=NCHW
|
||||||
|
opFile.value=add_dsl
|
||||||
|
opInterface.value=add_dsl
|
|
@ -0,0 +1,15 @@
|
||||||
|
[AddTik]
|
||||||
|
input0.name=x1
|
||||||
|
input0.dtype=float16
|
||||||
|
input0.paramType=required
|
||||||
|
input0.format=ND
|
||||||
|
input1.name=x2
|
||||||
|
input1.dtype=float16
|
||||||
|
input1.paramType=required
|
||||||
|
input1.format=ND
|
||||||
|
output0.name=y
|
||||||
|
output0.dtype=float16
|
||||||
|
output0.paramType=required
|
||||||
|
output0.format=ND
|
||||||
|
opFile.value=add_tik
|
||||||
|
opInterface.value=add_tik
|
|
@ -0,0 +1,15 @@
|
||||||
|
[AddDSL]
|
||||||
|
input0.name=x1
|
||||||
|
input0.dtype=float16
|
||||||
|
input0.paramType=required
|
||||||
|
input0.format=NCHW
|
||||||
|
input1.name=x2
|
||||||
|
input1.dtype=float16
|
||||||
|
input1.paramType=required
|
||||||
|
input1.format=NCHW
|
||||||
|
output0.name=y
|
||||||
|
output0.dtype=float16
|
||||||
|
output0.paramType=required
|
||||||
|
output0.format=NCHW
|
||||||
|
opFile.value=add_dsl
|
||||||
|
opInterface.value=add_dsl
|
|
@ -0,0 +1,15 @@
|
||||||
|
[AddTik]
|
||||||
|
input0.name=x1
|
||||||
|
input0.dtype=float16
|
||||||
|
input0.paramType=required
|
||||||
|
input0.format=ND
|
||||||
|
input1.name=x2
|
||||||
|
input1.dtype=float16
|
||||||
|
input1.paramType=required
|
||||||
|
input1.format=ND
|
||||||
|
output0.name=y
|
||||||
|
output0.dtype=float16
|
||||||
|
output0.paramType=required
|
||||||
|
output0.format=ND
|
||||||
|
opFile.value=add_tik
|
||||||
|
opInterface.value=add_tik
|
Loading…
Reference in New Issue