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

Update the instruction for building multiple accelerators #3046

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion docs/AddCustomAccelerators.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ The folder content is flexible depending on each accelerator. However, we recomm
To build accelerators in onnx-mlir, use the cmake variable `ONNX_MLIR_ACCELERATORS` when building onnx-mlir. `ONNX_MLIR_ACCELERATORS` accepts a semicolon-separated list of accelerator names. For example,
```bash
$ cd build
$ cmake .. -DONNX_MLIR_ACCELERATORS=accel1;accel2
$ cmake .. -DONNX_MLIR_ACCELERATORS='accel1;accel2'
```
Note that the list should be quoted.

### 1.2 Compile a model to run with selected accelerators.

Expand Down
6 changes: 4 additions & 2 deletions src/Accelerators/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

# Populate the accelerator list and add the accelerator subdirectories.
# ONNX_MLIR_ACCELERATORS is the list of accelerators user specified
# ONNX_MLIR_ACCELERATORS is the semicolon-separated list of accelerators user specified
# Note that the list should be quoted, e.g. -DONNX_MLIR_ACCELERATORS='A;B'
# ACCEL_TARGET_LIST is the list of cmake targets
# ACCEL_LINK_LIST is the lists of accelerator libraries
# ACCEL_INCLUDE_LIST is the list passed to inc generator
Expand All @@ -10,7 +11,8 @@ if (ONNX_MLIR_ACCELERATORS)
add_subdirectory(${t})

# If the accelerator can be built
if (${t}_ENABLED)
string(TOUPPER ${t} T)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to normalize accelerator names to upper case, since all cmake variables seem to be in upper case.

if (${T}_ENABLED)
list(APPEND ACCEL_TARGET_LIST "${t}Accel")
list(APPEND ACCEL_LINK_LIST "OM${t}Accel")
list(APPEND ACCEL_INCLUDE_LIST "${t}")
Expand Down
3 changes: 2 additions & 1 deletion test/mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# accelerator code itself cannot be built.
if (ONNX_MLIR_ACCELERATORS)
foreach(t ${ONNX_MLIR_ACCELERATORS})
set(${t}_LIT_ENABLED 1)
string(TOUPPER ${t} T)
set(${T}_LIT_ENABLED 1)
list(APPEND ACCEL_LIT_LIST "${t}")
endforeach(t)
endif(ONNX_MLIR_ACCELERATORS)
Expand Down
Loading