mlir 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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"
  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 tensorflow/core/ir"
  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. "https://github.com/SashwatAnagolum/ensemble-compilation.git|main|${src_dir}/ensemble-compilation|"
  26. "https://github.com/j2kun/mlir-tutorial.git|main|${src_dir}/mlir-tutorial|"
  27. "https://github.com/Xilinx/mlir-xten.git|feature/fused-ops|${src_dir}/mlir-xten|"
  28. "https://github.com/tenstorrent/tt-mlir.git|main|${src_dir}/tt-mlir|include"
  29. )
  30. clean() {
  31. echo "mlir clean"
  32. for entry in "${entries[@]}"; do
  33. IFS='|' read -r url branch dir root <<< "${entry}"
  34. rm -rf "${dir}"
  35. done
  36. }
  37. sync() {
  38. echo "mlir sync"
  39. for entry in "${entries[@]}"; do
  40. IFS='|' read -r url branch dir root <<< "${entry}"
  41. if [ ! -d "${dir}" ]; then
  42. if [ -n "${root}" ]; then
  43. if ! stderr=$(git clone --quiet --depth=1 --branch "${branch}" --single-branch --filter=blob:none --sparse "${url}" "${dir}" 2>&1); then
  44. echo "${stderr}" >&2
  45. exit 1
  46. fi
  47. if ! stderr=$(git -C "${dir}" sparse-checkout set ${root} 2>&1); then
  48. echo "${stderr}" >&2
  49. exit 1
  50. fi
  51. else
  52. if ! stderr=$(git clone --quiet --depth=1 --branch "${branch}" --single-branch "${url}" "${dir}" 2>&1); then
  53. echo "${stderr}" >&2
  54. exit 1
  55. fi
  56. fi
  57. else
  58. if [ -n "${root}" ]; then
  59. if ! stderr=$(git -C "${dir}" sparse-checkout set ${root} 2>&1); then
  60. echo "${stderr}" >&2
  61. exit 1
  62. fi
  63. fi
  64. if ! stderr=$(git -C "${dir}" fetch --quiet --depth=1 origin "${branch}" 2>&1); then
  65. echo "${stderr}" >&2
  66. exit 1
  67. fi
  68. if ! stderr=$(git -C "${dir}" reset --quiet --hard FETCH_HEAD 2>&1); then
  69. echo "${stderr}" >&2
  70. exit 1
  71. fi
  72. if ! stderr=$(git -C "${dir}" gc --quiet --prune=all 2>&1); then
  73. echo "${stderr}" >&2
  74. exit 1
  75. fi
  76. fi
  77. done
  78. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Interfaces"
  79. 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"
  80. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/Arithmetic/IR"
  81. 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"
  82. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/OpenACC"
  83. echo '#ifndef ACCCOMMON_TD
  84. #define ACCCOMMON_TD
  85. #endif // ACCCOMMON_TD' > "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/OpenACC/AccCommon.td"
  86. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/OpenMP"
  87. echo '#ifndef OMPCOMMON_TD
  88. #define OMPCOMMON_TD
  89. #endif // OMPCOMMON_TD' > "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/OpenMP/OmpCommon.td"
  90. mkdir -p "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/Linalg/IR"
  91. echo '#ifndef LINALG_NAMED_STRUCTURED_OPS_YAMLGEN_TD
  92. #define LINALG_NAMED_STRUCTURED_OPS_YAMLGEN_TD
  93. #endif // LINALG_NAMED_STRUCTURED_OPS_YAMLGEN_TD' > "${src_dir}/_/llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yamlgen.td"
  94. mkdir -p "${src_dir}/_/mlir-hlo/thlo/IR"
  95. curl --silent --show-error --location --output "${src_dir}/_/mlir-hlo/thlo/IR/thlo_ops.td" "https://raw.githubusercontent.com/rengolin/mlir-hlo/08ce879a5a04ea95dd02515baadc1796901546c5/thlo/IR/thlo_ops.td"
  96. mkdir -p "${src_dir}/_/mlir-hlo/gml_st/interfaces"
  97. curl --silent --show-error --location --output "${src_dir}/_/mlir-hlo/gml_st/interfaces/tiling_interface.td" "https://raw.githubusercontent.com/rengolin/mlir-hlo/08ce879a5a04ea95dd02515baadc1796901546c5/gml_st/interfaces/tiling_interface.td"
  98. }
  99. schema() {
  100. echo "mlir schema"
  101. node ./tools/mlir-script.js schema
  102. }
  103. test() {
  104. echo "mlir test"
  105. node ./tools/mlir-script.js test "$@"
  106. }
  107. while [ "$#" != 0 ]; do
  108. command="$1" && shift
  109. case "${command}" in
  110. "clean") clean;;
  111. "sync") sync;;
  112. "schema") schema;;
  113. "test") test "$@";;
  114. esac
  115. done