Skip to content

Instantly share code, notes, and snippets.

@AmosLewis
Last active March 20, 2025 04:27
Show Gist options
  • Select an option

  • Save AmosLewis/dd31ab37517977b1c499d06495b4adc2 to your computer and use it in GitHub Desktop.

Select an option

Save AmosLewis/dd31ab37517977b1c499d06495b4adc2 to your computer and use it in GitHub Desktop.

Revisions

  1. AmosLewis revised this gist Oct 17, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -51,7 +51,7 @@ torch-mlir-opt --convert-torch-onnx-to-torch --torch-lower-to-backend-contract -

    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir -mlir-print-ir-after-all -mlir-disable-threading --mlir-print-ir-before-all --debug

    torch-mlir-opt --mlir-elide-elementsattrs-if-larger=4 non_elided.mlir > elided.mlir
    torch-mlir-opt --mlir-elide-elementsattrs-if-larger=400 --mlir-elide-resource-strings-if-larger=400 model.mlir > model.elide.mlir

    grep -r "AveragePool" Inception_v4_vaiq_int8.default.torch-onnx.mlir

  2. AmosLewis revised this gist Oct 17, 2024. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -54,4 +54,9 @@ torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir -mlir-print-ir-after-all -
    torch-mlir-opt --mlir-elide-elementsattrs-if-larger=4 non_elided.mlir > elided.mlir

    grep -r "AveragePool" Inception_v4_vaiq_int8.default.torch-onnx.mlir


    iree-compile --iree-vm-bytecode-module-output-format=flatbuffer-binary --dump-compilation-phases-to=./model-phases-rocm-Reshape_3/ /proj/gdba/shark/chi/src/SHARK-TestSuite/alt_e2eshark/test-run/mygpt4_trunc_Reshape_3/model.torch_onnx.mlir -o model_direct_Reshape_3.vmfb

    iree-run-module --trace_execution=true --print_statistics=true --module=compiled_model.vmfb --function=tf2onnx --input="1x4xsi32=1"

  3. AmosLewis revised this gist Oct 11, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -47,6 +47,8 @@ torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir | externals/llvm-project/m

    torch-mlir-opt --convert-torch-onnx-to-torch --torch-decompose-complex-ops --cse --canonicalize --convert-torch-to-linalg reshape.default.onnx.mlir --debug

    torch-mlir-opt --convert-torch-onnx-to-torch --torch-lower-to-backend-contract --torch-scalarize-shapes --torch-shape-refinement-pipeline --torch-backend-to-linalg-on-tensors-backend-pipeline onnx.mlir

    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir -mlir-print-ir-after-all -mlir-disable-threading --mlir-print-ir-before-all --debug

    torch-mlir-opt --mlir-elide-elementsattrs-if-larger=4 non_elided.mlir > elided.mlir
  4. AmosLewis revised this gist Oct 2, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ cmake -GNinja -Bbuild \
    -DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR=`pwd` \
    -DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR=`pwd`/externals/llvm-external-projects/torch-mlir-dialects \
    -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
    -DTORCH_MLIR_ENABLE_JIT_IR_IMPORTER=ON \
    -DTORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS=ON \
    -DLLVM_TARGETS_TO_BUILD=host \
    externals/llvm-project/llvm
    cmake --build build --target tools/torch-mlir/all
  5. AmosLewis revised this gist Oct 2, 2024. No changes.
  6. AmosLewis revised this gist Oct 2, 2024. No changes.
  7. AmosLewis revised this gist Oct 2, 2024. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,21 @@ cmake -GNinja -Bbuild \
    externals/llvm-project/llvm
    cmake --build build --target tools/torch-mlir/all

    cmake -GNinja -Bbuild \
    -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_C_COMPILER=clang \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DPython3_FIND_VIRTUALENV=ONLY \
    -DLLVM_ENABLE_PROJECTS=mlir \
    -DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
    -DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR=`pwd` \
    -DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR=`pwd`/externals/llvm-external-projects/torch-mlir-dialects \
    -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
    -DTORCH_MLIR_ENABLE_JIT_IR_IMPORTER=ON \
    -DLLVM_TARGETS_TO_BUILD=host \
    externals/llvm-project/llvm
    cmake --build build --target tools/torch-mlir/all

    git submodule update --init --progressgit submodule update --init --progress

    git add -u
  8. AmosLewis revised this gist Aug 7, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,8 @@ cmake -GNinja -Bbuild \
    externals/llvm-project/llvm
    cmake --build build --target tools/torch-mlir/all

    git submodule update --init --progressgit submodule update --init --progress

    git add -u
    git commit --amend --no-edit

  9. AmosLewis revised this gist Aug 6, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,7 @@ git reset --hard HEAD~1

    git push origin as_stride --force

    pip3 install clang-format
    git clang-format HEAD~1


  10. AmosLewis revised this gist Apr 25, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -33,5 +33,5 @@ torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir -mlir-print-ir-after-all -

    torch-mlir-opt --mlir-elide-elementsattrs-if-larger=4 non_elided.mlir > elided.mlir


    grep -r "AveragePool" Inception_v4_vaiq_int8.default.torch-onnx.mlir

  11. AmosLewis revised this gist Apr 11, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,8 @@ torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir | externals/llvm-project/m
    --convert-torch-to-linalg
    --torch-backend-to-linalg-on-tensors-backend-pipeline

    torch-mlir-opt --convert-torch-onnx-to-torch --torch-decompose-complex-ops --cse --canonicalize --convert-torch-to-linalg reshape.default.onnx.mlir --debug

    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir -mlir-print-ir-after-all -mlir-disable-threading --mlir-print-ir-before-all --debug

    torch-mlir-opt --mlir-elide-elementsattrs-if-larger=4 non_elided.mlir > elided.mlir
  12. AmosLewis revised this gist Apr 10, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,7 @@ git clang-format HEAD~1
    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir | externals/llvm-project/mlir/utils/generate-test-checks.py

    --convert-torch-to-linalg
    --torch-backend-to-linalg-on-tensors-backend-pipeline

    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir -mlir-print-ir-after-all -mlir-disable-threading --mlir-print-ir-before-all --debug

  13. AmosLewis revised this gist Apr 8, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,8 @@ git clang-format HEAD~1

    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir | externals/llvm-project/mlir/utils/generate-test-checks.py

    --convert-torch-to-linalg

    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir -mlir-print-ir-after-all -mlir-disable-threading --mlir-print-ir-before-all --debug

    torch-mlir-opt --mlir-elide-elementsattrs-if-larger=4 non_elided.mlir > elided.mlir
  14. AmosLewis revised this gist Jan 12, 2024. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,9 @@ cmake -GNinja -Bbuild \
    externals/llvm-project/llvm
    cmake --build build --target tools/torch-mlir/all

    git add -u
    git commit --amend --no-edit

    git reset --hard HEAD~1

    git push origin as_stride --force
  15. AmosLewis revised this gist Dec 21, 2023. No changes.
  16. AmosLewis renamed this gist Dec 21, 2023. 1 changed file with 0 additions and 0 deletions.
  17. AmosLewis renamed this gist Dec 21, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  18. AmosLewis renamed this gist Dec 21, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions torch_mlir_debug_command.txt → torch_mlir_debug_command.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,9 @@ cmake -GNinja -Bbuild \
    cmake --build build --target tools/torch-mlir/all

    git reset --hard HEAD~1

    git push origin as_stride --force

    git clang-format HEAD~1


  19. Chi_Liu revised this gist Mar 27, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions torch_mlir_debug_command.txt
    Original file line number Diff line number Diff line change
    @@ -23,3 +23,5 @@ torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir -mlir-print-ir-after-all -

    torch-mlir-opt --mlir-elide-elementsattrs-if-larger=4 non_elided.mlir > elided.mlir



  20. Chi_Liu renamed this gist Jan 16, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  21. Chi_Liu revised this gist Jan 16, 2023. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion debug-command.txt
    Original file line number Diff line number Diff line change
    @@ -18,5 +18,8 @@ git clang-format HEAD~1


    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir | externals/llvm-project/mlir/utils/generate-test-checks.py
    torch-mlir-opt -convert-torch-to-tosa /tmp/IndexTensorStaticModule.mlir -mlir-print-ir-after-all -mlir-disable-threading --mlir-print-ir-before-all --debug

    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir -mlir-print-ir-after-all -mlir-disable-threading --mlir-print-ir-before-all --debug

    torch-mlir-opt --mlir-elide-elementsattrs-if-larger=4 non_elided.mlir > elided.mlir

  22. Chi_Liu created this gist Jan 16, 2023.
    22 changes: 22 additions & 0 deletions debug-command.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    cmake -GNinja -Bbuild \
    -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_C_COMPILER=clang \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DPython3_FIND_VIRTUALENV=ONLY \
    -DLLVM_ENABLE_PROJECTS=mlir \
    -DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
    -DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR=`pwd` \
    -DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR=`pwd`/externals/llvm-external-projects/torch-mlir-dialects \
    -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
    -DLLVM_TARGETS_TO_BUILD=host \
    externals/llvm-project/llvm
    cmake --build build --target tools/torch-mlir/all

    git reset --hard HEAD~1
    git push origin as_stride --force
    git clang-format HEAD~1


    torch-mlir-opt -convert-torch-to-tosa /tmp/index.mlir | externals/llvm-project/mlir/utils/generate-test-checks.py
    torch-mlir-opt -convert-torch-to-tosa /tmp/IndexTensorStaticModule.mlir -mlir-print-ir-after-all -mlir-disable-threading --mlir-print-ir-before-all --debug