mlir 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. src_dir=./third_party/source/mlir
  5. entries=(
  6. "https://github.com/llvm/llvm-project.git|main|${src_dir}/llvm-project|mlir"
  7. "https://github.com/openxla/stablehlo.git|main|${src_dir}/stablehlo|stablehlo"
  8. "https://github.com/openxla/shardy.git|main|${src_dir}/shardy|shardy"
  9. "https://github.com/openxla/xla.git|main|${src_dir}/xla|xla/mlir_hlo"
  10. "https://github.com/onnx/onnx-mlir.git|main|${src_dir}/onnx-mlir|"
  11. "https://github.com/llvm/torch-mlir.git|main|${src_dir}/torch-mlir|"
  12. "https://github.com/triton-lang/triton|main|${src_dir}/triton|"
  13. "https://github.com/tensorflow/tensorflow.git|master|${src_dir}/tensorflow|tensorflow/compiler/mlir"
  14. "https://github.com/tensorflow/runtime.git|master|${src_dir}/runtime|"
  15. "https://github.com/NVIDIA/TensorRT-Incubator.git|main|${src_dir}/TensorRT-Incubator|mlir-tensorrt"
  16. "https://github.com/iree-org/iree.git|main|${src_dir}/iree|"
  17. "https://github.com/monellz/FlashTensor.git|main|${src_dir}/FlashTensor|"
  18. "https://github.com/plaidml/plaidml.git|plaidml-v1|${src_dir}/plaidml|pmlc"
  19. "https://github.com/sophgo/tpu-mlir.git|master|${src_dir}/tpu-mlir|include"
  20. "https://github.com/spcl/mlir-dace.git|main|${src_dir}/mlir-dace|"
  21. "https://github.com/woxjro/lltz.git|master|${src_dir}/lltz|"
  22. "https://github.com/pengmai/lagrad.git|main|${src_dir}/lagrad|include"
  23. "https://github.com/llvm/clangir.git|main|${src_dir}/clangir|clang/include/clang/CIR"
  24. "https://github.com/ROCm/rocMLIR.git|develop|${src_dir}/rocMLIR|mlir/include/mlir/Dialect"
  25. )
  26. clean() {
  27. echo "mlir clean"
  28. for entry in "${entries[@]}"; do
  29. IFS='|' read -r url branch dir root <<< "${entry}"
  30. rm -rf "${dir}"
  31. done
  32. }
  33. sync() {
  34. echo "mlir sync"
  35. for entry in "${entries[@]}"; do
  36. IFS='|' read -r url branch dir root <<< "${entry}"
  37. if [ ! -d "${dir}" ]; then
  38. if [ -n "${root}" ]; then
  39. git clone --quiet --depth=1 --branch "${branch}" --single-branch --filter=blob:none --sparse "${url}" "${dir}" >/dev/null 2>&1
  40. git -C "${dir}" sparse-checkout set "${root}" >/dev/null 2>&1
  41. else
  42. git clone --quiet --depth=1 --branch "${branch}" --single-branch "${url}" "${dir}"
  43. fi
  44. else
  45. if [ -n "${root}" ]; then
  46. git -C "${dir}" sparse-checkout set "${root}" >/dev/null 2>&1
  47. fi
  48. git -C "${dir}" fetch --quiet --depth=1 origin "${branch}"
  49. git -C "${dir}" reset --quiet --hard FETCH_HEAD >/dev/null 2>&1
  50. git -C "${dir}" gc --quiet --prune=all
  51. fi
  52. done
  53. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Interfaces"
  54. curl --silent --show-error --location --output "${src_dir}/_/llvm-project/mlir/include/mlir/Interfaces/CopyOpInterface.td" "https://raw.githubusercontent.com/llvm/llvm-project/llvmorg-14.0.0/mlir/include/mlir/Interfaces/CopyOpInterface.td"
  55. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/Arithmetic/IR"
  56. curl --silent --show-error --location --output "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticBase.td" "https://raw.githubusercontent.com/llvm/llvm-project/llvmorg-14.0.0/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticBase.td"
  57. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/OpenACC"
  58. echo '#ifndef ACCCOMMON_TD
  59. #define ACCCOMMON_TD
  60. #endif // ACCCOMMON_TD' > "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/OpenACC/AccCommon.td"
  61. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/OpenMP"
  62. echo '#ifndef OMPCOMMON_TD
  63. #define OMPCOMMON_TD
  64. #endif // OMPCOMMON_TD' > "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/OpenMP/OmpCommon.td"
  65. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/Linalg/IR"
  66. echo '#ifndef LINALG_NAMED_STRUCTURED_OPS_YAMLGEN_TD
  67. #define LINALG_NAMED_STRUCTURED_OPS_YAMLGEN_TD
  68. #endif // LINALG_NAMED_STRUCTURED_OPS_YAMLGEN_TD' > "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yamlgen.td"
  69. }
  70. schema() {
  71. echo "mlir schema"
  72. node ./tools/mlir-script.js schema
  73. }
  74. test() {
  75. echo "mlir test"
  76. node ./tools/mlir-script.js test "$@"
  77. }
  78. while [ "$#" != 0 ]; do
  79. command="$1" && shift
  80. case "${command}" in
  81. "clean") clean;;
  82. "sync") sync;;
  83. "schema") schema;;
  84. "test") test "$@";;
  85. esac
  86. done