Skip to content

Instantly share code, notes, and snippets.

@renxida
Created January 3, 2024 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renxida/ee59f268af6304a54ae42f7358a9c973 to your computer and use it in GitHub Desktop.
Save renxida/ee59f268af6304a54ae42f7358a9c973 to your computer and use it in GitHub Desktop.
OVERVIEW: MLIR modular optimizer driver
Available Dialects: builtin, chlo, complex, func, linalg, memref, ml_program, scf, sparse_tensor, stablehlo, tensor, tm_tensor, torch, torch_c, tosa, vhlo
USAGE: torch-mlir-opt [options] <input file>
OPTIONS:
Color Options:
--color - Use colors in output (default=autodetect)
General options:
--allow-unregistered-dialect - Allow operation with no registered dialects
--disable-i2p-p2i-opt - Disables inttoptr/ptrtoint roundtrip optimization
--dump-pass-pipeline - Print the pipeline that will be run
--elide-resource-data-from-bytecode - Elide resources when generating bytecode
--emit-bytecode - Emit bytecode when generating output
--emit-bytecode-version=<value> - Use specified bytecode when generating output
--experimental-debuginfo-iterators - Enable communicating debuginfo positions through iterators, eliminating intrinsics
--irdl-file=<filename> - IRDL file to register before processing the input
--load-dialect-plugin=<string> - Load dialects from plugin library
--load-pass-plugin=<string> - Load passes from plugin library
--log-actions-to=<string> - Log action execution to a file, or stderr if '-' is passed
--log-mlir-actions-filter=<string> - Comma separated list of locations to filter actions from logging
--mlir-debug-counter=<string> - Comma separated list of debug counter skip and count arguments
--mlir-disable-threading - Disable multi-threading within MLIR, overrides any further call to MLIRContext::enableMultiThreading()
--mlir-elide-elementsattrs-if-larger=<uint> - Elide ElementsAttrs with "..." that have more elements than the given upper limit
--mlir-elide-resource-strings-if-larger=<uint> - Elide printing value of resources if string is too long in chars.
--mlir-enable-debugger-hook - Enable Debugger hook for debugging MLIR Actions
--mlir-pass-pipeline-crash-reproducer=<string> - Generate a .mlir reproducer file at the given output path if the pass manager crashes or fails
--mlir-pass-pipeline-local-reproducer - When generating a crash reproducer, attempt to generated a reproducer with the smallest pipeline.
--mlir-pass-statistics - Display the statistics of each pass
--mlir-pass-statistics-display=<value> - Display method for pass statistics
=list - display the results in a merged list sorted by pass name
=pipeline - display the results with a nested pipeline view
--mlir-pretty-debuginfo - Print pretty debug info in MLIR output
--mlir-print-debug-counter - Print out debug counter information after all counters have been accumulated
--mlir-print-debuginfo - Print debug info in MLIR output
--mlir-print-elementsattrs-with-hex-if-larger=<long> - Print DenseElementsAttrs with a hex string that have more elements than the given upper limit (use -1 to disable)
--mlir-print-ir-after=<pass-arg> - Print IR after specified passes
--mlir-print-ir-after-all - Print IR after each pass
--mlir-print-ir-after-change - When printing the IR after a pass, only print if the IR changed
--mlir-print-ir-after-failure - When printing the IR after a pass, only print if the pass failed
--mlir-print-ir-before=<pass-arg> - Print IR before specified passes
--mlir-print-ir-before-all - Print IR before each pass
--mlir-print-ir-module-scope - When printing IR for print-ir-[before|after]{-all} always print the top-level operation
--mlir-print-local-scope - Print with local scope and inline information (eliding aliases for attributes, types, and locations
--mlir-print-op-on-diagnostic - When a diagnostic is emitted on an operation, also print the operation as an attached note
--mlir-print-stacktrace-on-diagnostic - When a diagnostic is emitted, also print the stack trace as an attached note
--mlir-print-value-users - Print users of operation results and block arguments as a comment
--mlir-timing - Display execution times
--mlir-timing-display=<value> - Display method for timing data
=list - display the results in a list sorted by total time
=tree - display the results ina with a nested tree view
--no-implicit-module - Disable implicit addition of a top-level module op during parsing
-o <filename> - Output filename
--pass-pipeline=<string> - Textual description of the pass pipeline to run
--profile-actions-to=<string> - Profile action execution to a file, or stderr if '-' is passed
--run-reproducer - Run the pipeline stored in the reproducer
--show-dialects - Print the list of registered dialects and exit
--split-input-file - Split the input file into pieces and process each chunk independently
Compiler passes to run
Passes:
--canonicalize - Canonicalize operations
--disable-patterns=<string> - Labels of patterns that should be filtered out during application
--enable-patterns=<string> - Labels of patterns that should be used during application, all other patterns are filtered out
--max-iterations=<long> - Max. iterations between applying patterns / simplifying regions
--max-num-rewrites=<long> - Max. number of pattern rewrites within an iteration
--region-simplify - Perform control flow optimizations to the region tree
--test-convergence - Test only: Fail pass on non-convergence to detect cyclic pattern
--top-down - Seed the worklist in general top-down order
--convert-torch-conversion-to-mlprogram - Convert recognized TorchConversion ops to MLProgram ops
--convert-torch-onnx-to-torch - Converts ONNX custom ops in the torch dialect to native torch ops
--convert-torch-to-arith - Convert recognized Torch ops to Std ops
--convert-torch-to-linalg - Convert recognized Torch ops to Linalg ops
--convert-torch-to-scf - Convert recognized Torch ops to SCF ops
--convert-torch-to-stablehlo - Convert Torch ops to Stablehlo ops
--enable-i32-index - Enable truncate index from i64 to i32(unsafely)
--enable-static-shape - Enable static shape conversion
--convert-torch-to-tensor - Convert Torch ops to the Tensor dialect
--convert-torch-to-tmtensor - Convert recognized Torch ops to TMTensor/Linalg ops
--convert-torch-to-tosa - Convert Torch ops to TOSA ops
--cse - Eliminate common sub-expressions
--inline - Inline function calls
--default-pipeline=<string> - The default optimizer pipeline used for callables
--max-iterations=<uint> - Maximum number of iterations when inlining within an SCC
--op-pipelines=<pass-manager> - Callable operation specific optimizer pipelines (in the form of `dialect.op(pipeline)`)
--loop-invariant-code-motion - Hoist loop invariant instructions outside of the loop
--print-op-stats - Print statistics of operations
--json - print the stats as JSON
--refback-expand-ops-for-llvm - Expand ops into more primitive ops before LLVM lowering.
--refback-generalize-tensor-concat - Convert tensor.concat to other tensor ops
--refback-generalize-tensor-pad - Convert tensor.pad to linalg ops
--refback-mlprogram-bufferize - Bufferize the MLProgram dialect ops
--refback-munge-calling-conventions - Munge calling conventions for calling via ExecutionEngine
--refback-munge-memref-copy - Munge memref.copy to linalg.copy
--snapshot-op-locations - Generate new locations from the current IR
--filename=<string> - The filename to print the generated IR
--tag=<string> - A tag to use when fusing the new locations with the original. If unset, the locations are replaced.
--strip-debuginfo - Strip debug info from all operations
--symbol-dce - Eliminate dead symbols
--tm-tensor-bufferize - Bufferize the TMTensor dialect
--tm-tensor-to-loops - Convert TMTensor ops to loops and Linalg ops.
--torch-adjust-calling-conventions - Adjust the calling conventions of functions
--torch-convert-custom-quant-op - Convert torch custom quant op to linalg
--torch-decompose-complex-ops - Decompose complicated torch operations
--legal-ops=<string> - List of operation names that should be considered legal
--torch-drop-abstract-interp-calculations - Drop reified abstract interpretation calculations.
--torch-erase-module-initializer - Erase the `torch.global_slot.module_initializer` op.
--torch-finalizing-backend-type-conversion - Finalizes a partial conversion to builtin tensors
--torch-func-backend-type-conversion - Convert functions to operate on builtin tensors
--torch-globalize-object-graph - Converts TorchScript object graphs to a globalized form
--torch-inline-global-slots - Inlines torch.global_slot ops.
--torch-lower-to-backend-contract - Perform simplifications until the backend contract is satisfied.
--backend-legal-ops=<string> - List of ops to be considered legal for the backend, such as 'aten.foo'.
--decompose - Decompose ops.
--extra-library=<string> - MLIR module for splicing into the abstract interpretation library
--max-iterations=<int> - Maximum number of invocations of the simplification pipeline.
--torch-maximize-value-semantics - Use value-semantic tensors where possible.
--torch-prepare-for-globalize-object-graph - Lowering in preparation for globalizing
--torch-recompose-complex-ops - Recompose torch operations that have been decomposed by TorchScript
--torch-reduce-op-variants - Reduces variants of ops to a smaller set of ops.
--extra-library=<string> - MLIR module for verifying custom op value semantics
--torch-refine-public-return - Refine public return
--torch-reify-dtype-calculations - Reify dtype calculations.
--extra-library=<string> - MLIR module for splicing into the dtype library
--torch-reify-shape-calculations - Reify shape calculations.
--extra-library=<string> - MLIR module for splicing into the shape library
--torch-simplify-dtype-calculations - Simplify reified dtype calculations.
--torch-simplify-shape-calculations - Simplify reified shape calculations.
--torch-unpack-quant-tensor - Unpack quantized int4 tensor from int8 containter
--torch-verify-backend-contract-no-decompositions - Check that program satisfies backend contract.
--torch-verify-linalg-on-tensors-backend-contract - Verifies conformity to the linalg-on-tensors backend contract
--torch-verify-stablehlo-backend-contract - Verifies conformity to the stablehlo backend contract
--torch-verify-tosa-backend-contract - Verifies conformity to the linalg-on-tensors backend contract
--view-op-graph - Print Graphviz visualization of an operation
--max-label-len=<uint> - Limit attribute/type length to number of chars
--print-attrs - Print attributes of operations
--print-control-flow-edges - Print control flow edges
--print-data-flow-edges - Print data flow edges
--print-result-types - Print result types of operations
Pass Pipelines:
--torch-backend-to-linalg-on-tensors-backend-pipeline- Pipeline lowering torch backend contract to linalg-on-tensors backend contract.
--torch-backend-to-stablehlo-backend-pipeline - Pipeline lowering torch backend contract to StableHLO backend contract.
--enable-i32-index - Enable truncate index from i64 to i32(unsafely)
--enable-static-shape - Enable static shape conversion.
--torch-backend-to-tosa-backend-pipeline - Pipeline lowering torch backend contract to TOSA backend contract.
--torch-function-to-torch-backend-pipeline - Pipeline lowering a Torch function to Torch backend form.
--backend-legal-ops=<string> - List of ops to be considered legal for the backend, such as 'aten.foo'.
--decompose-complex-ops - Decompose complex operations.
--extra-library=<string> - Filename of MLIR module for splicing into the abstract interpretation library.
--max-iterations=<int> - Maximum number of invocations of the simplification pipeline.
--torch-shape-refinement-pipeline - Pipeline refining shapes of tensors.
--backend-legal-ops=<string> - List of ops to be considered legal for the backend, such as 'aten.foo'.
--decompose-complex-ops - Decompose complex operations.
--extra-library=<string> - Filename of MLIR module for splicing into the abstract interpretation library.
--max-iterations=<int> - Maximum number of invocations of the simplification pipeline.
--torch-simplification-pipeline - Pipeline simplifying computations in the program.
--backend-legal-ops=<string> - List of ops to be considered legal for the backend, such as 'aten.foo'.
--decompose-complex-ops - Decompose complex operations.
--extra-library=<string> - Filename of MLIR module for splicing into the abstract interpretation library.
--max-iterations=<int> - Maximum number of invocations of the simplification pipeline.
--torchscript-module-to-torch-backend-pipeline - Pipeline lowering TorchScript object graph IR to Torch backend form.
--backend-legal-ops=<string> - List of ops to be considered legal for the backend, such as 'aten.foo'.
--decompose-complex-ops - Decompose complex operations.
--extra-library=<string> - Filename of MLIR module for splicing into the abstract interpretation library.
--max-iterations=<int> - Maximum number of invocations of the simplification pipeline.
--verify-diagnostics - Check that emitted diagnostics match expected-* lines on the corresponding line
--verify-each - Run the verifier after each transformation pass
--verify-roundtrip - Round-trip the IR after parsing and ensure it succeeds
Generic Options:
--help - Display available options (--help-hidden for more)
--help-list - Display list of available options (--help-list-hidden for more)
--version - Display the version of this program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment