blob: b267dc2640b369a11758a19a41343ab444d64c21 [file] [log] [blame]
Ben Vanike91401e2023-03-06 18:05:09 -08001# Copyright 2023 The IREE Authors
2#
3# Licensed under the Apache License v2.0 with LLVM Exceptions.
4# See https://llvm.org/LICENSE.txt for license information.
5# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
7# Tests loading and executing a bytecode module and issuing a few calls showing
8# how to take input, produce output, and support temporary values within the
9# trace session. See iree-run-trace.mlir for how to compile the module and
10# invoke the iree-run-trace tool.
11
12# Prepare the VM context for use; effectively a reset.
13# API: iree_vm_context_create
14type: context_load
15
16---
17
18# Load the builtin HAL module used to execute the program.
19# API: iree_hal_module_create
20type: module_load
21module:
22 type: builtin
23 name: hal
24
25---
26
27# Load the compiled bytecode module.
28# API: iree_vm_bytecode_module_create
29type: module_load
30module:
31 type: bytecode
32 name: module
33 # The test pulls the .vmfb from stdin but you can also reference relative or
34 # absolute file paths:
35 # path: ../iree-tmp/iree-run-trace.vmfb
36 path: <stdin>
37
38---
39
40# Call #0 of @mul.
41# API: iree_vm_invoke
42type: call
43function: module.mul
44args:
45# arg[0]: the first `--input=` buffer. !input.get would retain the input for
46# other calls to use but otherwise prefer taking ownership.
47- !input.take 0
48# arg[1]: constant value defined inline.
49- !hal.buffer_view 4xf32=0,1,2,3
50results:
51# result[0]: store in blackboard slot 4 for later use.
52- !blackboard.set 4
53
54---
55
56# Assigns one or more source values to a set of target values.
57# Effectively: outputs.push(retain(blackboard[4]))
58type: assign
59from:
60# from[0]: retain blackboard slot 4, leaving it for later use.
61- !blackboard.get 4
62to:
63# to[0]: push on to the trace output list. --output= can save off the results
64# and otherwise they are printed to stdout.
65- !output.push
66
67---
68
69# Call #1 of @mul.
70# API: iree_vm_invoke
71type: call
72function: module.mul
73args:
74# arg[0]: take the previously-stored value in blackboard slot 4.
75- !blackboard.take 4
76# arg[1]: another constant.
77- !hal.buffer_view 4xf32=3,3,3,3
78results:
79# result[0]: push on to the trace output list.
80- !output.push