Scott Todd | 9d2ec18 | 2023-12-14 11:10:47 -0800 | [diff] [blame] | 1 | // Passing no inputs is okay. |
| 2 | |
| 3 | // RUN: (iree-compile --iree-hal-target-backends=vmvx %s | \ |
| 4 | // RUN: iree-run-module --device=local-sync --module=- --function=no_input) | \ |
| 5 | // RUN: FileCheck --check-prefix=NO-INPUT %s |
| 6 | // NO-INPUT-LABEL: EXEC @no_input |
| 7 | func.func @no_input() { |
| 8 | return |
| 9 | } |
| 10 | |
| 11 | // ----- |
| 12 | |
| 13 | // Scalars use the form `--input=value`. Type (float/int) should be omitted. |
| 14 | // * The VM does not use i1/i8 types, so i32 VM types are returned instead. |
| 15 | |
| 16 | // RUN: (iree-compile --iree-hal-target-backends=vmvx %s | \ |
Ben Vanik | 30901f5 | 2024-02-08 11:23:21 -0800 | [diff] [blame] | 17 | // RUN: iree-run-module --device=local-sync \ |
| 18 | // RUN: --module=- \ |
| 19 | // RUN: --function=scalars \ |
| 20 | // RUN: --input=1 \ |
| 21 | // RUN: --input=5 \ |
| 22 | // RUN: --input=1234 \ |
| 23 | // RUN: --input=-3.14) | \ |
Scott Todd | 9d2ec18 | 2023-12-14 11:10:47 -0800 | [diff] [blame] | 24 | // RUN: FileCheck --check-prefix=INPUT-SCALARS %s |
| 25 | // INPUT-SCALARS-LABEL: EXEC @scalars |
| 26 | func.func @scalars(%arg0: i1, %arg1: i8, %arg2 : i32, %arg3 : f32) -> (i1, i8, i32, f32) { |
| 27 | // INPUT-SCALARS: result[0]: i32=1 |
| 28 | // INPUT-SCALARS: result[1]: i32=5 |
| 29 | // INPUT-SCALARS: result[2]: i32=1234 |
| 30 | // INPUT-SCALARS: result[3]: f32=-3.14 |
| 31 | return %arg0, %arg1, %arg2, %arg3 : i1, i8, i32, f32 |
| 32 | } |
| 33 | |
| 34 | // ----- |
| 35 | |
| 36 | // Buffers ("tensors") use the form `--input=[shape]xtype=[value]`. |
| 37 | // * If any values are omitted, zeroes will be used. |
| 38 | // * Quotes should be used around values with spaces. |
| 39 | // * Brackets may also be used to separate element values. |
| 40 | |
| 41 | // RUN: (iree-compile --iree-hal-target-backends=vmvx %s | \ |
Ben Vanik | 30901f5 | 2024-02-08 11:23:21 -0800 | [diff] [blame] | 42 | // RUN: iree-run-module --device=local-sync \ |
| 43 | // RUN: --module=- \ |
| 44 | // RUN: --function=buffers \ |
| 45 | // RUN: --input=i32=5 \ |
| 46 | // RUN: --input=2xi32 \ |
| 47 | // RUN: --input="2x3xi32=1 2 3 4 5 6") | \ |
Scott Todd | 9d2ec18 | 2023-12-14 11:10:47 -0800 | [diff] [blame] | 48 | // RUN: FileCheck --check-prefix=INPUT-BUFFERS %s |
| 49 | // INPUT-BUFFERS-LABEL: EXEC @buffers |
| 50 | func.func @buffers(%arg0: tensor<i32>, %arg1: tensor<2xi32>, %arg2: tensor<2x3xi32>) -> (tensor<i32>, tensor<2xi32>, tensor<2x3xi32>) { |
| 51 | // INPUT-BUFFERS: result[0]: hal.buffer_view |
| 52 | // INPUT-BUFFERS-NEXT: i32=5 |
| 53 | // INPUT-BUFFERS: result[1]: hal.buffer_view |
| 54 | // INPUT-BUFFERS-NEXT: 2xi32=0 0 |
| 55 | // INPUT-BUFFERS: result[2]: hal.buffer_view |
| 56 | // INPUT-BUFFERS-NEXT: 2x3xi32=[1 2 3][4 5 6] |
| 57 | return %arg0, %arg1, %arg2 : tensor<i32>, tensor<2xi32>, tensor<2x3xi32> |
| 58 | } |
| 59 | |
| 60 | // ----- |
| 61 | |
| 62 | // Buffer values can be read from binary files with `@some/file.bin`. |
| 63 | // * numpy npy files from numpy.save or previous tooling output can be read to |
| 64 | // provide 1+ values. |
| 65 | // * Some data types may be converted (i32 -> si32 here) - bug? |
| 66 | |
Ben Vanik | 30901f5 | 2024-02-08 11:23:21 -0800 | [diff] [blame] | 67 | // RUN: (iree-compile --iree-hal-target-backends=vmvx %s -o=%t.vmfb && \ |
| 68 | // RUN: iree-run-module --device=local-sync \ |
| 69 | // RUN: --module=%t.vmfb \ |
| 70 | // RUN: --function=npy_round_trip \ |
| 71 | // RUN: --input=2xi32=11,12 \ |
| 72 | // RUN: --input=3xi32=1,2,3 \ |
| 73 | // RUN: --output=@%t.npy \ |
| 74 | // RUN: --output=+%t.npy && \ |
| 75 | // RUN: iree-run-module --device=local-sync \ |
| 76 | // RUN: --module=%t.vmfb \ |
| 77 | // RUN: --function=npy_round_trip \ |
| 78 | // RUN: --input=*%t.npy) | \ |
| 79 | // RUN: FileCheck --check-prefix=INPUT-NUMPY %s |
Scott Todd | 9d2ec18 | 2023-12-14 11:10:47 -0800 | [diff] [blame] | 80 | |
Ben Vanik | 30901f5 | 2024-02-08 11:23:21 -0800 | [diff] [blame] | 81 | // INPUT-NUMPY-LABEL: EXEC @npy_round_trip |
Scott Todd | 9d2ec18 | 2023-12-14 11:10:47 -0800 | [diff] [blame] | 82 | func.func @npy_round_trip(%arg0: tensor<2xi32>, %arg1: tensor<3xi32>) -> (tensor<2xi32>, tensor<3xi32>) { |
Ben Vanik | 30901f5 | 2024-02-08 11:23:21 -0800 | [diff] [blame] | 83 | // INPUT-NUMPY: result[0]: hal.buffer_view |
| 84 | // INPUT-NUMPY-NEXT: 2xsi32=11 12 |
| 85 | // INPUT-NUMPY: result[1]: hal.buffer_view |
| 86 | // INPUT-NUMPY-NEXT: 3xsi32=1 2 3 |
Scott Todd | 9d2ec18 | 2023-12-14 11:10:47 -0800 | [diff] [blame] | 87 | return %arg0, %arg1 : tensor<2xi32>, tensor<3xi32> |
| 88 | } |