-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into taplib-docs
- Loading branch information
Showing
229 changed files
with
8,077 additions
and
5,965 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ming_examples/basic/dma_transpose/aie2.py → ...ples/basic/dma_transpose/dma_transpose.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
..._examples/basic/dma_transpose/aie2_alt.py → .../basic/dma_transpose/dma_transpose_alt.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
programming_examples/basic/dma_transpose/dma_transpose_iron.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# dma_transpose/dma_transpose_iron.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 Advanced Micro Devices, Inc. or its affiliates | ||
import argparse | ||
import numpy as np | ||
import sys | ||
|
||
from aie.iron import ObjectFifo, Program, Runtime | ||
from aie.iron.device import NPU1Col1, AnyComputeTile | ||
from aie.iron.placers import SequentialPlacer | ||
from aie.helpers.taplib import TensorTiler2D | ||
|
||
|
||
def my_passthrough(M, K, generate_acccess_map=False): | ||
|
||
# Define types | ||
tensor_ty = np.ndarray[(M, K), np.dtype[np.int32]] | ||
|
||
# Define tensor access pattern | ||
tap_in = TensorTiler2D.simple_tiler((M, K), tile_col_major=True)[0] | ||
|
||
# Use tensor access pattern to create a graph | ||
if generate_acccess_map: | ||
tap_in.visualize(file_path="iron_transpose_data.png", show_tile=False) | ||
return | ||
|
||
# Dataflow with ObjectFifos | ||
of_in = ObjectFifo(tensor_ty) | ||
of_out = of_in.cons().forward(AnyComputeTile) | ||
|
||
# Runtime operations to move data to/from the AIE-array | ||
rt = Runtime() | ||
with rt.sequence(tensor_ty, tensor_ty, tensor_ty) as (a_in, _, c_out): | ||
rt.fill(of_in.prod(), a_in, tap_in) | ||
rt.drain(of_out.cons(), c_out, wait=True) | ||
|
||
# Create the program from the device type and runtime | ||
my_program = Program(NPU1Col1(), rt) | ||
|
||
# Place program components (assign them resources on the device) and generate an MLIR module | ||
module = my_program.resolve_program(SequentialPlacer()) | ||
|
||
# Print the generated MLIR | ||
print(module) | ||
|
||
|
||
if __name__ == "__main__": | ||
p = argparse.ArgumentParser() | ||
p.add_argument("dims", help="M K", type=int, nargs="*", default=[64, 64]) | ||
p.add_argument( | ||
"--generate-access-map", | ||
action="store_true", | ||
help="Produce a file showing data access order", | ||
) | ||
args = p.parse_args() | ||
|
||
if len(args.dims) != 2: | ||
print( | ||
"ERROR: Must provide either no dimensions or both M and K", file=sys.stderr | ||
) | ||
exit(-1) | ||
my_passthrough( | ||
M=args.dims[0], | ||
K=args.dims[1], | ||
generate_acccess_map=args.generate_access_map, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.