Skip to content

Commit 44bc926

Browse files
authored
Programming examples small fixes (#2031)
1 parent 3a35554 commit 44bc926

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

programming_examples/basic/matrix_multiplication/single_core/single_core_iron.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,14 @@ def core_fn(of_a, of_b, of_c, zero, matmul):
190190
rows_per_block = 4
191191

192192
# Define tensor access patterns for inputs/outputs
193-
A_taps = TensorTiler2D.group_tiler(
193+
A_tiles = TensorTiler2D.group_tiler(
194194
(M, K), (m, k), (1, K_div_k), pattern_repeat=N_div_n
195195
)
196196
# There is only one access pattern for B - it tiles the entire matrix in (k x n) tiles.
197197
b_tap = TensorTiler2D.group_tiler(
198198
(K, N), (k, n), (K_div_k, N_div_n), tile_group_col_major=True
199199
)[0]
200-
C_taps = TensorTiler2D.group_tiler((M, N), (m, n), (rows_per_block // 2, N_div_n))
200+
C_tiles = TensorTiler2D.group_tiler((M, N), (m, n), (rows_per_block // 2, N_div_n))
201201
c_index = 0
202202

203203
# Runtime operations to move data to/from the AIE-array
@@ -221,19 +221,19 @@ def core_fn(of_a, of_b, of_c, zero, matmul):
221221
tgs.append(rt.task_group())
222222
for tile_row in range(num_tile_rows):
223223
# -- A --
224-
tile_offset = (row_base + tile_row) % len(A_taps)
225-
rt.fill(inA.prod(), A, tap=A_taps[tile_offset], task_group=tgs[-1])
226-
A_taps.append(A_taps[tile_offset])
224+
tile_offset = (row_base + tile_row) % len(A_tiles)
225+
rt.fill(inA.prod(), A, tap=A_tiles[tile_offset], task_group=tgs[-1])
226+
A_taps.append(A_tiles[tile_offset])
227227

228228
# -- B --
229229
rt.fill(inB.prod(), B, tap=b_tap, task_group=tgs[-1])
230230
B_taps.append(b_tap)
231231

232232
# -- C --
233233
rt.drain(
234-
outC.cons(), C, tap=C_taps[c_index], task_group=tgs[-1], wait=True
234+
outC.cons(), C, tap=C_tiles[c_index], task_group=tgs[-1], wait=True
235235
)
236-
C_taps.append(C_taps[c_index])
236+
C_taps.append(C_tiles[c_index])
237237
c_index += 1
238238

239239
if tile_row_block > 0 or (tile_row_block == 0 and pingpong > 0):

programming_examples/basic/vector_scalar_mul/vector_scalar_mul.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def core_body(of_in, of_factor, of_out, scale_fn):
5151
scale_fn(elem_in, elem_out, elem_factor, n)
5252
of_in.release(1)
5353
of_out.release(1)
54+
of_factor.release(1)
5455

5556
# Create a worker to run the task on a compute tile
5657
worker = Worker(

programming_examples/basic/vector_vector_add/vector_vector_add.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def core_body(of_in1, of_in2, of_out):
6363
rt.drain(of_out.cons(), C, wait=True)
6464

6565
# Place program components (assign them resources on the device) and generate an MLIR module
66-
return Program(NPU1Col1(), rt).resolve_program(SequentialPlacer())
66+
return Program(dev, rt).resolve_program(SequentialPlacer())
6767

6868

6969
module = my_vector_add()

programming_examples/basic/vector_vector_mul/vector_vector_mul.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def core_body(of_in1, of_in2, of_out):
6363
rt.drain(of_out.cons(), C, wait=True)
6464

6565
# Place program components (assign them resources on the device) and generate an MLIR module
66-
return Program(NPU1Col1(), rt).resolve_program(SequentialPlacer())
66+
return Program(dev, rt).resolve_program(SequentialPlacer())
6767

6868

6969
module = my_vector_mul()

0 commit comments

Comments
 (0)