forked from Xilinx/mlir-aie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
44 lines (37 loc) · 1.18 KB
/
Copy pathtest.py
File metadata and controls
44 lines (37 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# test.py -*- Python -*-
#
# This file is 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
#
# (c) Copyright 2024-2026 Advanced Micro Devices, Inc. or its affiliates
import numpy as np
import sys
import aie.utils.test as test_utils
import aie.iron as iron
from aie.utils import DefaultNPURuntime
def main(opts):
print("Running...\n")
data_size = int(opts.size)
dtype = np.uint8
input_data = np.arange(1, data_size + 1, dtype=dtype)
in1 = iron.tensor(input_data, dtype=dtype)
out = iron.zeros(data_size, dtype=dtype)
npu_opts = test_utils.create_npu_kernel(opts)
res = DefaultNPURuntime.run_test(
npu_opts.npu_kernel,
[in1, out],
{1: input_data},
verify=npu_opts.verify,
verbosity=npu_opts.verbosity,
)
if res == 0:
print("\nPASS!\n")
sys.exit(res)
if __name__ == "__main__":
p = test_utils.create_default_argparser()
p.add_argument(
"-s", "--size", required=True, dest="size", help="Passthrough kernel size"
)
opts = p.parse_args(sys.argv[1:])
main(opts)