Ben Vanik | 902aada | 2023-03-01 11:23:59 -0800 | [diff] [blame] | 1 | // RUN: iree-compile %s -o ignored.mlir \ |
| 2 | // RUN: --iree-hal-target-backends=vmvx \ |
| 3 | // RUN: --iree-hal-dump-executable-sources-to=- | \ |
| 4 | // RUN: iree-compile - -o /dev/null \ |
| 5 | // RUN: --compile-mode=hal-executable \ |
| 6 | // RUN: --mlir-print-ir-before=iree-hal-serialize-executables 2>&1 | \ |
| 7 | // RUN: FileCheck %s |
| 8 | |
| 9 | // This test relies on us piping stdout and that there's only a single |
| 10 | // executable (otherwise we'd need to look at files and that's harder |
| 11 | // cross-platform). Real automation of this requires xargs: compile and dump a |
| 12 | // directory of .mlir sources by specifying a path to the dump flag instead |
| 13 | // of `-` (indicating stdout) and then ls | xargs them to iree-compile or |
| 14 | // iree-opt. |
| 15 | // |
| 16 | // Example of dumping per-dispatch executable sources and compiling each to |
| 17 | // their platform binary form, dumping their MLIR prior to lowering into the |
| 18 | // backend representation (SPIR-V/LLVM-IR/etc): |
| 19 | // iree-compile some_input.mlir -o ignored.mlir \ |
| 20 | // --iree-hal-target-backends=vmvx \ |
| 21 | // --iree-hal-dump-executable-sources-to=sources/ | \ |
| 22 | // ls -1 sources/ | xargs -i sh -c "iree-compile sources/{} --compile-mode=hal-executable --mlir-print-ir-before=iree-hal-serialize-executables" |
| 23 | // |
| 24 | // NOTE: executable sources are not runnable: they only exist to allow for |
| 25 | // iteration on executable translation. If you want to run them you need |
| 26 | // corresponding host code to dispatch them and can use benchmarks instead. |
| 27 | // |
| 28 | // If modifying the sources and wanting to see the changes in a full program the |
| 29 | // --iree-hal-substitute-executable-sources-from= flag can be used to substitute |
| 30 | // one or more executables dumped with this command from a path or for |
| 31 | // individual executables one or more `executable_name=file.mlir` pairs can be |
| 32 | // repeated in `--iree-hal-substitute-executable-source=`. |
| 33 | |
| 34 | func.func @abs(%input : tensor<f32>) -> (tensor<f32>) { |
| 35 | %result = math.absf %input : tensor<f32> |
| 36 | return %result : tensor<f32> |
| 37 | } |
| 38 | |
Ben Vanik | e2ba0a2 | 2023-12-18 18:38:26 -0800 | [diff] [blame] | 39 | // CHECK: IR Dump Before SerializeExecutablesPass |
Ben Vanik | 902aada | 2023-03-01 11:23:59 -0800 | [diff] [blame] | 40 | // CHECK: hal.executable public @abs_dispatch_0 |
| 41 | // CHECK: hal.executable.variant public @vmvx_bytecode_fb |
Lei Zhang | ff624dd | 2024-04-17 17:35:31 -0700 | [diff] [blame] | 42 | // CHECK: vm.func private @abs_dispatch_0_elementwise |