| # Copyright 2023 The IREE Authors |
| # |
| # Licensed under the Apache License v2.0 with LLVM Exceptions. |
| # See https://llvm.org/LICENSE.txt for license information. |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| |
| # Tests loading and executing a bytecode module and issuing a few calls showing |
| # how to take input, produce output, and support temporary values within the |
| # trace session. See iree-run-trace.mlir for how to compile the module and |
| # invoke the iree-run-trace tool. |
| |
| # Prepare the VM context for use; effectively a reset. |
| # API: iree_vm_context_create |
| type: context_load |
| |
| --- |
| |
| # Load the builtin HAL module used to execute the program. |
| # API: iree_hal_module_create |
| type: module_load |
| module: |
| type: builtin |
| name: hal |
| |
| --- |
| |
| # Load the compiled bytecode module. |
| # API: iree_vm_bytecode_module_create |
| type: module_load |
| module: |
| type: bytecode |
| name: module |
| # The test pulls the .vmfb from stdin but you can also reference relative or |
| # absolute file paths: |
| # path: ../iree-tmp/iree-run-trace.vmfb |
| path: <stdin> |
| |
| --- |
| |
| # Call #0 of @mul. |
| # API: iree_vm_invoke |
| type: call |
| function: module.mul |
| args: |
| # arg[0]: the first `--input=` buffer. !input.get would retain the input for |
| # other calls to use but otherwise prefer taking ownership. |
| - !input.take 0 |
| # arg[1]: constant value defined inline. |
| - !hal.buffer_view 4xf32=0,1,2,3 |
| results: |
| # result[0]: store in blackboard slot 4 for later use. |
| - !blackboard.set 4 |
| |
| --- |
| |
| # Assigns one or more source values to a set of target values. |
| # Effectively: outputs.push(retain(blackboard[4])) |
| type: assign |
| from: |
| # from[0]: retain blackboard slot 4, leaving it for later use. |
| - !blackboard.get 4 |
| to: |
| # to[0]: push on to the trace output list. --output= can save off the results |
| # and otherwise they are printed to stdout. |
| - !output.push |
| |
| --- |
| |
| # Call #1 of @mul. |
| # API: iree_vm_invoke |
| type: call |
| function: module.mul |
| args: |
| # arg[0]: take the previously-stored value in blackboard slot 4. |
| - !blackboard.take 4 |
| # arg[1]: another constant. |
| - !hal.buffer_view 4xf32=3,3,3,3 |
| results: |
| # result[0]: push on to the trace output list. |
| - !output.push |