Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pjr kernel readme #1369

Merged
merged 37 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fa5e374
[ML] Update relu and softmax with the trace
Apr 19, 2024
713709c
[ELTWISE] Add trace
Apr 19, 2024
54eda5b
[ELTWISE] Remove todo label
Apr 19, 2024
e5c9024
[MERGE] Merge
Apr 19, 2024
547d333
Update programming_examples/ml/softmax/softmax.cc
jamesroxbypb Apr 19, 2024
ce16b1e
Update programming_examples/ml/eltwise_add/aie2.py
jamesroxbypb Apr 19, 2024
3ed4270
Update programming_examples/ml/eltwise_add/aie2.py
jamesroxbypb Apr 19, 2024
4e2ecde
Update programming_examples/ml/eltwise_add/aie2.py
jamesroxbypb Apr 19, 2024
f197140
Update programming_examples/ml/eltwise_add/aie2.py
jamesroxbypb Apr 19, 2024
eacf05c
Update programming_examples/ml/eltwise_add/aie2.py
jamesroxbypb Apr 19, 2024
ac37703
Update programming_examples/ml/eltwise_add/aie2.py
jamesroxbypb Apr 19, 2024
f0f577e
Update programming_examples/ml/eltwise_add/aie2.py
jamesroxbypb Apr 19, 2024
81b6067
Update programming_examples/ml/eltwise_add/aie2.py
jamesroxbypb Apr 19, 2024
c4f3389
Update programming_examples/ml/relu/aie2.py
jamesroxbypb Apr 19, 2024
beb7d46
Update programming_examples/ml/softmax/aie2.py
jamesroxbypb Apr 19, 2024
3fa17cc
Update programming_examples/ml/softmax/aie2.py
jamesroxbypb Apr 19, 2024
e89c364
Update programming_examples/ml/softmax/aie2.py
jamesroxbypb Apr 19, 2024
ddabed1
Update programming_examples/ml/eltwise_mul/aie2.py
jamesroxbypb Apr 19, 2024
4f86d9a
Update programming_examples/ml/eltwise_mul/aie2.py
jamesroxbypb Apr 19, 2024
78fe460
Update programming_examples/ml/softmax/aie2.py
jamesroxbypb Apr 19, 2024
56143d5
Update programming_examples/ml/eltwise_mul/aie2.py
jamesroxbypb Apr 19, 2024
c371918
Update programming_examples/ml/eltwise_mul/aie2.py
jamesroxbypb Apr 19, 2024
3c90061
Update programming_examples/ml/eltwise_mul/aie2.py
jamesroxbypb Apr 19, 2024
0582114
Update programming_examples/ml/relu/aie2.py
jamesroxbypb Apr 19, 2024
aceef35
Update programming_examples/ml/relu/aie2.py
jamesroxbypb Apr 19, 2024
93ef98c
Update programming_examples/ml/relu/aie2.py
jamesroxbypb Apr 19, 2024
120b54b
Update programming_examples/ml/eltwise_mul/aie2.py
jamesroxbypb Apr 19, 2024
8edfeda
Update programming_examples/ml/relu/aie2.py
jamesroxbypb Apr 19, 2024
1c559ca
Update programming_examples/ml/eltwise_mul/aie2.py
jamesroxbypb Apr 19, 2024
686be69
Update programming_examples/ml/softmax/aie2.py
jamesroxbypb Apr 19, 2024
b38bf0d
[README] Doc update
Apr 19, 2024
87e5deb
[DOC] README documentaiton for kernels
Apr 22, 2024
da80cd3
Complete Convolution Description
singagan Apr 22, 2024
7b1471b
add class and datatypes column
denolf Apr 22, 2024
8bf715a
add note
denolf Apr 22, 2024
df7d1b0
[MERGE] Merge conflicts
Apr 22, 2024
c43b3dc
[MERGE] merge
Apr 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions aie_kernels/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!---//===- README.md --------------------------*- Markdown -*-===//
//
// 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
//
// Copyright (C) 2022, Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//-->

# AIE Kernels

These kernels are provided as example building blocks for larger designs, and also as illustrations of how to write single core programs for AIEs which can then be duplicated or mixed into multi-core designs using the structural IRON API.

In some cases, the kernels are just generic C code, and will run on any family of AI Engines with varying performance. Other kernels are then optimized for the AIE1 and AIE2 architectures. Finally, some kernels use the AIE API, which is a C++ header-only library providing types and operations that get translated into efficient low-level intrinsics, and whose documentation can be found [here](https://www.xilinx.com/htmldocs/xilinx2023_2/aiengine_api/aie_api/doc/index.html), while others use the architecture specific low-level intrinsics directly

> **NOTE:** this set of AIE kernels are meant for demonstration along with the programming examples. The goal is not to be 100% performant, there may be room for further improvement. The kernels are provided as-is with no guarantees of support of AMD or AMD Research and Advanced Development.

## Generic
| Class | Name | Coding style | Purpose | Datatypes |
|-|-|-|-|-|
| basic | [passThrough.cc](./generic/passThrough.cc) | AIE API | A simple memcpy operation | `uint8_t`, `int16_t`, `int32_t` |

## AIE1
| Name | Coding style | Purpose |
|-|-|-|

## AIE2
| Class | Name | Coding style | Purpose | Datatypes |
|-|-|-|-|-|
| basic | [zero.cc](../../aie_kernels/aie2/zero.cc) | AIE API | Fill a tensor with zeroes | template |
| basic | [add.cc](../../aie_kernels/aie2/add.cc) | AIE API | Pointwise addition of 2 tensors | `bfloat16` |
| basic | [mul.cc](../../aie_kernels/aie2/mul.cc) | AIE API | Pointwise multiplication of 2 tensors | `bfloat16` |
| basic | [scale.cc](../../aie_kernels/aie2/scale.cc) | AIE API | Scale all elements of a tensor with a scale factor | `int32_t` |
| basic | [bitwiseOR.cc](../../aie_kernels/aie2/bitwiseOR.cc) | AIE API | Bitwise OR of fixed point tensors | `uint8_t`,`int16_t`,`int32_t`|
| basic | [bitwiseAND.cc](../../aie_kernels/aie2/bitwiseAND.cc) | AIE API | Bitwise AND of fixed point tensors | `uint8_t`,`int16_t`,`int32_t` |
| gemm | [mm.cc](../../aie_kernels/aie2/mm.cc) | AIE API | Matrix/Matrix multiplication | `int16_t`,`bfloat16_t` |
| gemm | [mv.cc](../../aie_kernels/aie2/mv.cc) | AIE API | Matrix/Vector multiplication | `bfloat16_t` |
| |
| reduction | [reduce_add.cc](../../aie_kernels/aie2/reduce_add.cc) | Intrinsics | Find the sum of elements in a tensor | `int32 _t` |
| reduction| [reduce_max.cc](../../aie_kernels/aie2/reduce_max.cc) | Intrinsics | Find max value across a tensor | `int32 _t` |
| reduction | [reduce_min.cc](../../aie_kernels/aie2/reduce_min.cc) | Intrinsics | Find min value across a tensor | `int32 _t` |
||
| ml | [conv2dk1_i8.cc](../../aie_kernels/aie2/conv2dk1_i8.cc) | AIE API | 1x1 Conv2D | `int8_t` |
| ml | [conv2dk1.cc](../../aie_kernels/aie2/conv2dk1.cc) | AIE API | 1x1 Conv2D with fused ReLU | `int8_t`, `uint8_t` |
| ml | [conv2dk3.cc](../../aie_kernels/aie2/conv2dk3.cc) | AIE API | 3x3 Conv2D with fused ReLU | `int8_t`, `uint8_t` |
| ml | [conv2dk1_skip.cc](../../aie_kernels/aie2/conv2dk1_skip.cc) | AIE API| 1x1 Conv2D with fused skip addition | `int8_t`, `uint8_t` |
| ml | [conv2dk1_skip_init.cc](../../aie_kernels/aie2/conv2dk1_skip_init.cc) | AIE API | 1x1 Conv2D with fused 1x1 Conv2D skip addition | `int8_t`, `uint8_t` |
| ml |[relu.cc](../../aie_kernels/aie2/relu.cc) | Intrinsics | ReLU activation function | `bfloat16_t` |
| ml | [bf16_exp.cc](../../aie_kernels/aie2/bf16_exp.cc) | AIE API | Raise all elements in a `bfloat` tensor to $e^x$ | `bfloat16_t` |
| |
| vision | [gray2rgba.cc](../../aie_kernels/aie2/gray2rgba.cc) | AIE API | Convert from grayscale to RGBA format | `uint8_t` |
| vision |[rgba2gray.cc](../../aie_kernels/aie2/rgba2gray.cc) | AIE API | Convert from RGBA format to grayscale | `uint8_t` |
| vision | [rgba2hue.cc](../../aie_kernels/aie2/rgba2hue.cc) | AIE API | Convert from RGBA to hue | `uint8_t` |
| vision | [addWeighted.cc](../../aie_kernels/aie2/addWeighted.cc) | AIE API | Fixed point weighted sum of two tensors | `uint8_t` |
| vision | [threshold.cc](../../aie_kernels/aie2/threshold.cc) | AIE API | Clipping | `uint8_t` |
| vision | [filter2d.cc](../../aie_kernels/aie2/filter2d.cc) | AIE API | Fixed point 2D image processing filter | `uint8_t` |
5 changes: 4 additions & 1 deletion programming_examples/ml/eltwise_add/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ all: build/final.xclbin
targetname = myEltwiseAdd
trace_size = 8192


VPATH := ../../../aie_kernels/aie2

build/%.o: %.cc
Expand All @@ -29,6 +28,10 @@ build/aie_trace.mlir: aie2.py
python3 $< ${trace_size} > $@


build/aie_trace.mlir: aie2.py
mkdir -p ${@D}
python3 $< ${trace_size} > $@

build/final.xclbin: build/aie.mlir build/add.o
mkdir -p ${@D}
cd ${@D} && aiecc.py --aie-generate-cdo --aie-generate-ipu --no-compile-host \
Expand Down
1 change: 1 addition & 0 deletions programming_examples/ml/eltwise_mul/aie2.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def sequence(A, B, C):
trace_size = 0 if (len(sys.argv) < 2) else int(sys.argv[1])
except ValueError:
print("Argument is not an integer")

with mlir_mod_ctx() as ctx:
my_eltwise_mul(trace_size)
res = ctx.module.operation.verify()
Expand Down
1 change: 1 addition & 0 deletions programming_examples/ml/relu/aie2.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def sequence(A, C):
trace_size = 0 if (len(sys.argv) != 2) else int(sys.argv[1])
except ValueError:
print("Argument is not an integer")

with mlir_mod_ctx() as ctx:
my_relu(trace_size)
res = ctx.module.operation.verify()
Expand Down
Loading