-
Notifications
You must be signed in to change notification settings - Fork 90
Add scripts for building CMake files #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3dbd003
Add scripts for building CMake files
1329009851 415d6f6
changes from pre-commit
1329009851 632462c
changes from pre-commit
1329009851 e0d01e5
Modifying File Permissions
1329009851 d05fe54
Merge branch 'sgl-cmake2' of https://github.com/1329009851/sgl-kernel…
1329009851 113fba3
Changing the script file name
1329009851 84636cd
Modifying Script Permissions
1329009851 ef82e62
Fix a script call bug
1329009851 b1861fa
Fix a script call bug
1329009851 170cd9e
Merge branch 'sgl-cmake2' of https://github.com/1329009851/sgl-kernel…
1329009851 c474b57
Update build.sh
1329009851 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| [ | ||
| { | ||
| "op": "AddCustom", | ||
| "language": "cpp", | ||
| "input_desc": [ | ||
| { | ||
| "name": "x", | ||
| "param_type": "required", | ||
| "format": [ | ||
| "ND" | ||
| ], | ||
| "type": [ | ||
| "float16" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "y", | ||
| "param_type": "required", | ||
| "format": [ | ||
| "ND" | ||
| ], | ||
| "type": [ | ||
| "float16" | ||
| ] | ||
| } | ||
| ], | ||
| "output_desc": [ | ||
| { | ||
| "name": "z", | ||
| "param_type": "required", | ||
| "format": [ | ||
| "ND" | ||
| ], | ||
| "type": [ | ||
| "float16" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| #!/bin/bash | ||
| export MODULE_NAME="deepep" | ||
| export MODULE_SRC_PATH="${SRC_PATH}/${MODULE_NAME}" | ||
| export MODULE_SCRIPTS_PATH="${SCRIPTS_PATH}/${MODULE_NAME}" | ||
| export MODULE_BUILD_OUT_PATH="${BUILD_OUT_PATH}/${MODULE_NAME}" | ||
| export MODULE_TEST_PATH="${TEST_PATH}/${MODULE_NAME}" | ||
| IS_EXTRACT=0 | ||
| SOC_VERSION="all" | ||
| ENABLE_UT_BUILD=0 | ||
| ENABLE_PYBIND_BUILD=0 | ||
| ENABLE_SRC_BUILD=1 | ||
|
|
||
| BuildPybind() { | ||
| DIST_OUT_PATH=$MODULE_BUILD_OUT_PATH | ||
| if [ -d $DIST_OUT_PATH/dist ]; then | ||
| rm -rf $DIST_OUT_PATH/dist | ||
| fi | ||
| EXT_PATH=$MODULE_SRC_PATH | ||
| cd $EXT_PATH | ||
| sh build.sh | ||
| DIST_GEN_PATH=$EXT_PATH/dist/ | ||
| if [ -d $DIST_GEN_PATH ]; then | ||
| echo "copy $DIST_GEN_PATH to $DIST_OUT_PATH/" | ||
| cp -rf $DIST_GEN_PATH $DIST_OUT_PATH/ | ||
| else | ||
| echo $DIST_GEN_PATH does not exist | ||
| echo "BuildPybind fail" | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| BuildTest() { | ||
| cd ${MODULE_TEST_PATH}/ut_gtest | ||
| if [ -d "./build" ]; then | ||
| rm -rf "./build" | ||
| fi | ||
| mkdir ./build | ||
| cd build | ||
| cmake .. && make -j && make install | ||
| if [ $? -ne 0 ]; then | ||
| echo "BuildTest fail" | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| PrintHelp() { | ||
| echo " | ||
| ./build.sh comm_operator <opt>... | ||
| -x Extract the run package | ||
| -c Target SOC VERSION | ||
| Support Soc: [ascend910_93, ascend910b4] | ||
| -d Enable debug | ||
| -t enable UT build | ||
| -p enable pybind build | ||
| -r enable code coverage | ||
| " | ||
| } | ||
|
|
||
| while getopts "c:xdtprh" opt; do | ||
| case $opt in | ||
| c) | ||
| SOC_VERSION=$OPTARG | ||
| ;; | ||
| x) | ||
| IS_EXTRACT=1 | ||
| ;; | ||
| d) | ||
| export BUILD_TYPE="Debug" | ||
| ;; | ||
| t) | ||
| ENABLE_UT_BUILD=1 | ||
| ENABLE_SRC_BUILD=0 | ||
| ;; | ||
| p) | ||
| ENABLE_PYBIND_BUILD=1 | ||
| ENABLE_SRC_BUILD=0 | ||
| ;; | ||
| r) | ||
| export BUILD_TYPE="Debug" | ||
| export ENABLE_COV=1 | ||
| ;; | ||
| h) | ||
| PrintHelp | ||
| exit 0 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| echo "Start creating the CMake file" | ||
|
|
||
| if [ ! -d "$BUILD_OUT_PATH/${MODULE_NAME}" ]; then | ||
| echo "mkdir $BUILD_OUT_PATH/${MODULE_NAME}" | ||
| mkdir $BUILD_OUT_PATH/${MODULE_NAME} | ||
| fi | ||
|
|
||
| if [ $ENABLE_SRC_BUILD -eq 1 ]; then | ||
| if [[ "$SOC_VERSION" == "all" ]]; then | ||
| echo "$MODULE_SCRIPTS_PATH/compile_ascend_proj.sh $MODULE_SRC_PATH Ascend910_9382 $IS_EXTRACT $BUILD_TYPE" | ||
| bash $MODULE_SCRIPTS_PATH/compile_ascend_proj.sh $MODULE_SRC_PATH Ascend910_9382 $IS_EXTRACT $BUILD_TYPE | ||
| else | ||
| echo "$MODULE_SCRIPTS_PATH/compile_ascend_proj.sh $MODULE_SRC_PATH $SOC_VERSION $IS_EXTRACT $BUILD_TYPE" | ||
| bash $MODULE_SCRIPTS_PATH/compile_ascend_proj.sh $MODULE_SRC_PATH $SOC_VERSION $IS_EXTRACT $BUILD_TYPE | ||
| fi | ||
| if [ $? -ne 0 ]; then | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [ $ENABLE_PYBIND_BUILD -eq 1 ]; then | ||
| echo "Start to BuildPybind" | ||
| BuildPybind | ||
| if [ $? -ne 0 ]; then | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [ $ENABLE_UT_BUILD -eq 1 ]; then | ||
| echo "Start to BuildTest" | ||
| BuildTest | ||
| if [ $? -ne 0 ]; then | ||
| exit 1 | ||
| fi | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #!/bin/bash | ||
| CopyOps() { | ||
| local src_dir="$1" # Path of Source Directory A | ||
| local dst_dir="$2" # Path of Target Directory B | ||
|
|
||
| if [ -d "$src_dir/op_host" ]; then | ||
| cp -rf "$src_dir/op_host/"* "$dst_dir/op_host/" | ||
| echo "cp -rf $src_dir/op_host/* $dst_dir/op_host/" | ||
| fi | ||
|
|
||
| if [ -d "$src_dir/op_kernel" ]; then | ||
| cp -rf "$src_dir/op_kernel/"* "$dst_dir/op_kernel/" | ||
| echo "cp -rf $src_dir/op_kernel/* $dst_dir/op_kernel/" | ||
| fi | ||
|
|
||
| # Ensure that op_host and op_kernel exist in the target directory | ||
| mkdir -p "$dst_dir/op_host" "$dst_dir/op_kernel" | ||
|
|
||
| # Traverse all direct subdirectories under the source directory (including directory names with spaces) | ||
| find "$src_dir" -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d '' subdir; do | ||
| # Check whether the subdirectory exists (although find has already filtered it, double-checking is safer) | ||
| if [ -d "$subdir" ]; then | ||
| # Processing the op_host directory | ||
| if [ -d "$subdir/op_host" ]; then | ||
| cp -rf "$subdir/op_host/"* "$dst_dir/op_host/" | ||
| echo "cp -rf $subdir/op_host/* $dst_dir/op_host/" | ||
| fi | ||
|
|
||
| # Processing the op_kernel directory | ||
| if [ -d "$subdir/op_kernel" ]; then | ||
| cp -rf "$subdir/op_kernel/"* "$dst_dir/op_kernel/" | ||
| echo "cp -rf $subdir/op_kernel/* $dst_dir/op_kernel/" | ||
| fi | ||
| fi | ||
| done | ||
| echo "${src_dir} built successfully" | ||
| } | ||
|
|
||
| BuildOps() { | ||
| local proj_name=$1 | ||
| echo "${proj_name}" | ||
| local soc_version=$2 | ||
|
|
||
| if [ -d "./${proj_name}" ]; then | ||
| rm -rf ${proj_name}/cmake | ||
| rm -rf ${proj_name}/op_host | ||
| rm -rf ${proj_name}/op_kernel | ||
| rm -rf ${proj_name}/scripts | ||
| rm -rf ${proj_name}/build.sh | ||
| rm -rf ${proj_name}/CMakeLists.txt | ||
| rm -rf ${proj_name}/CMakePresets.json | ||
| rm -rf ${proj_name}/framework | ||
| fi | ||
|
|
||
| echo "msopgen gen -i ./AddCustom.json -c ai_core-${soc_version} -f pytorch -lan cpp -out ${proj_name}" | ||
| msopgen gen -i ./AddCustom.json -c ai_core-${soc_version} -f pytorch -lan cpp -out ${proj_name} | ||
| rm -rf ./${proj_name}/op_host/add_custom* | ||
| rm -rf ./${proj_name}/op_kernel/add_custom* | ||
| } | ||
|
|
||
| # Build the operator project and transfer its output to the specified location | ||
| BuildAscendProj() { | ||
| local os_id=$(grep ^ID= /etc/os-release | cut -d= -f2 | tr -d '"') | ||
| local arch=$(uname -m) | ||
| local soc_version=$2 | ||
| local is_extract=$3 | ||
| local build_type=$4 | ||
| # Modify the default operator name | ||
| export OPS_PROJECT_NAME=aclnnInner | ||
| # Enter the compilation path | ||
| echo "cd $1" | ||
| cd $1 | ||
|
|
||
| BuildOps "ops_${soc_version}" ${soc_version} | ||
| BuildOps "ops2_${soc_version}" ${soc_version} | ||
| CopyOps "./ops" "./ops_${soc_version}" | ||
| CopyOps "./ops2" "./ops2_${soc_version}" | ||
| cp -r ./ops_${soc_version}/cmake ./ops | ||
| cp -r ./ops2_${soc_version}/cmake ./ops2 | ||
| } | ||
|
|
||
| BuildAscendProj $1 $2 $3 $4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.