|
17 | 17 |
|
18 | 18 |
|
19 | 19 | @iron.jit
|
20 |
| -def vector_vector_add(dev, column_id, input0, input1, output): |
| 20 | +def vector_vector_add(config, input0, input1, output): |
21 | 21 | if input0.shape != input1.shape:
|
22 | 22 | raise ValueError(
|
23 | 23 | f"Input shapes are not the equal ({input0.shape} != {input1.shape})."
|
@@ -48,16 +48,16 @@ def vector_vector_add(dev, column_id, input0, input1, output):
|
48 | 48 |
|
49 | 49 | buffer_depth = 2
|
50 | 50 |
|
51 |
| - @device(dev) |
| 51 | + @device(config['device']) |
52 | 52 | def device_body():
|
53 | 53 | tensor_ty = np.ndarray[(num_elements,), np.dtype[dtype]]
|
54 | 54 | tile_ty = np.ndarray[(n,), np.dtype[dtype]]
|
55 | 55 |
|
56 | 56 | # AIE Core Function declarations
|
57 | 57 |
|
58 | 58 | # Tile declarations
|
59 |
| - ShimTile = tile(column_id, 0) |
60 |
| - ComputeTile2 = tile(column_id, 2) |
| 59 | + ShimTile = tile(config['column_id'], 0) |
| 60 | + ComputeTile2 = tile(config['column_id'], 2) |
61 | 61 |
|
62 | 62 | # AIE-array data movement with object fifos
|
63 | 63 | of_in1 = object_fifo("in1", ShimTile, ComputeTile2, buffer_depth, tile_ty)
|
@@ -128,13 +128,22 @@ def main():
|
128 | 128 |
|
129 | 129 | # Construct two input random tensors and an output zeroed tensor
|
130 | 130 | # The three tensor are in memory accessible to the NPU
|
131 |
| - input0 = iron.randint(0, 100, (args.num_elements,), dtype=np.int32, device=args.device) |
132 |
| - input1 = iron.randint(0, 100, (args.num_elements,), dtype=np.int32, device=args.device) |
| 131 | + input0 = iron.randint( |
| 132 | + 0, 100, (args.num_elements,), dtype=np.int32, device=args.device |
| 133 | + ) |
| 134 | + input1 = iron.randint( |
| 135 | + 0, 100, (args.num_elements,), dtype=np.int32, device=args.device |
| 136 | + ) |
133 | 137 | output = iron.zeros_like(input0)
|
134 | 138 |
|
135 | 139 | # JIT-compile the kernel then launches the kernel with the given arguments. Future calls
|
136 | 140 | # to the kernel will use the same compiled kernel and loaded code objects
|
137 |
| - vector_vector_add(device_map[args.device], args.column, input0, input1, output) |
| 141 | + vector_vector_add( |
| 142 | + {"device": device_map[args.device], "column_id": args.column}, |
| 143 | + input0, |
| 144 | + input1, |
| 145 | + output, |
| 146 | + ) |
138 | 147 |
|
139 | 148 | # Check the correctness of the result
|
140 | 149 | e = np.equal(input0.numpy() + input1.numpy(), output.numpy())
|
|
0 commit comments