代码拉取完成,页面将自动刷新
#!/bin/bash
# 设置工作目录
WORK_DIR=$(pwd)
PROJECT_NAME="torch-mlir"
PROJECT_REPO="https://github.com/llvm/torch-mlir.git"
COMMIT_ID="7e7af670802d99cacdaf26e6e37249d544e4896e"
# 创建并进入临时目录
mkdir -p "$WORK_DIR"/"$PROJECT_NAME"
cd "$WORK_DIR"/"$PROJECT_NAME"
# 克隆torch-mlir仓库
echo "Cloning torch-mlir repository..."
git clone "$PROJECT_REPO" --depth=1
cd "$PROJECT_NAME"
git remote set-branches origin "$COMMIT_ID"
git fetch --depth 1 origin "$COMMIT_ID"
git checkout "$COMMIT_ID"
cd ..
# 进入项目目录
cd "$PROJECT_NAME"
# 初始化子模块
echo "Initializing submodules..."
git submodule update --init --progress
# 配置编译选项
echo "Configuring build..."
cmake -GNinja -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DPython3_FIND_VIRTUALENV=ONLY \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DLLVM_TARGETS_TO_BUILD=host \
-DTORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS=ON \
-DTORCH_MLIR_ENABLE_JIT_IR_IMPORTER=ON \
externals/llvm-project/llvm
# 编译torch-mlir
echo "Building torch-mlir..."
cmake --build build --target tools/torch-mlir/all -j32
# install torch-mlir python package
echo "Installing torch-mlir python package..."
TORCH_MLIR_CMAKE_BUILD_DIR=build/ TORCH_MLIR_CMAKE_ALREADY_BUILT=1 python setup.py bdist_wheel
pip install dist/torch_mlir-0.0.1-*.whl
echo "Build completed."
# 返回原工作目录
cd "$WORK_DIR"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。