Skip to content

Commit

Permalink
Update the instruction for building multiple accelerators (#3046)
Browse files Browse the repository at this point in the history
Signed-off-by: Tung D. Le <[email protected]>
  • Loading branch information
tungld authored Jan 20, 2025
1 parent 5a1e295 commit 008f777
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
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)
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

0 comments on commit 008f777

Please sign in to comment.