Skip to content

Commit 78e8749

Browse files
Merge pull request #5 from tsisw/FIR-714
FIR-714: Updated the SDK Release r0.1.3
2 parents 614dab8 + cea50af commit 78e8749

File tree

6 files changed

+32
-29
lines changed

6 files changed

+32
-29
lines changed

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ if (GGML_TSAVORITE)
1515

1616
if (NOT DEFINED MLIR_COMPILER_DIR)
1717
if (NOT DEFINED $ENV{MLIR_SDK_VERSION})
18-
set (MLIR_COMPILER_DIR /proj/work/rel/sw/sdk-r.0.1.2/compiler)
18+
set (MLIR_COMPILER_DIR /proj/rel/sw/sdk-r.0.1.3/compiler)
19+
message("MLIR_SDK_VERSION not set defaulting to ${MLIR_COMPILER_DIR}")
1920
else()
2021
set (MLIR_COMPILER_DIR $ENV{MLIR_SDK_VERSION}/compiler)
2122
endif()
2223
endif()
2324

2425
if (NOT DEFINED RUNTIME_DIR)
2526
if (NOT DEFINED $ENV{MLIR_SDK_VERSION})
26-
set (RUNTIME_DIR /proj/work/rel/sw/sdk-r.0.1.2/${GGML_TSAVORITE_TARGET}/runtime)
27+
set (RUNTIME_DIR /proj/rel/sw/sdk-r.0.1.3/${GGML_TSAVORITE_TARGET}/runtime)
28+
message("MLIR_SDK_VERSION not set defaulting to ${RUNTIME_DIR}")
2729
else()
2830
set (RUNTIME_DIR $ENV{MLIR_SDK_VERSION}/${GGML_TSAVORITE_TARGET}/runtime)
2931
endif()
@@ -33,14 +35,14 @@ if (GGML_TSAVORITE)
3335
set (GGML_TSI_KERNEL_DIR ${CMAKE_SOURCE_DIR}/ggml-tsi-kernel/${GGML_TSAVORITE_TARGET})
3436
endif()
3537

36-
file(GLOB TLIBS "${RUNTIME_DIR}/lib/*.so" "${GGML_TSI_KERNEL_DIR}/host/*.o")
3738

3839
if (${GGML_TSAVORITE_TARGET} STREQUAL fpga)
3940
set(CMAKE_CROSSCOMPILING ON)
4041
set(ARCH_FLAGS -march=armv8-a)
42+
file(GLOB TLIBS "${RUNTIME_DIR}/lib/*.so" "${GGML_TSI_KERNEL_DIR}/host/*.o" "${RUNTIME_DIR}/../utils/lib/TsavRTShimCAPI.cpp.o")
4143
message("Setting target as fpga")
4244
elseif (${GGML_TSAVORITE_TARGET} STREQUAL "posix")
43-
list(APPEND TLIBS "${MLIR_COMPILER_DIR}/lib/libFFMDeviceShim.so")
45+
file(GLOB TLIBS "${RUNTIME_DIR}/lib/*.so" "${GGML_TSI_KERNEL_DIR}/host/*.o" "${MLIR_COMPILER_DIR}/lib/libFFMDeviceShim.so" "${MLIR_COMPILER_DIR}/lib/libTsavRTPosixShimCAPI.so")
4446
message("Setting target as posix for tsavorite")
4547
endif()
4648

ggml-tsi-kernel

ggml/include/ggml-tsavorite.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ typedef struct tensor_log_ {
151151
const ggml_tensor *tensor;
152152
} tensor_log;
153153

154-
extern void _mlir_ciface_txe_add(void *a, void *b, void *res);
155-
extern void _mlir_ciface_txe_sub(void *a, void *b, void *res);
156-
extern void _mlir_ciface_txe_mult(void *a, void *b, void *res);
157-
extern void _mlir_ciface_txe_div(void *a, void *b, void *res);
158-
extern void _mlir_ciface_txe_sqrt(void *a, void *res);
159-
extern void _mlir_ciface_txe_neg(void *a, void *res);
160-
extern void _mlir_ciface_txe_abs(void *a, void *res);
161-
extern void _mlir_ciface_txe_sin(void *a, void *res);
162-
extern void _mlir_ciface_txe_sigmoid(void *a, void *res);
163-
extern void _mlir_ciface_txe_silu(void *a, void *res);
154+
extern void _mlir_ciface_txe_add_host(void *a, void *b, void *res);
155+
extern void _mlir_ciface_txe_sub_host(void *a, void *b, void *res);
156+
extern void _mlir_ciface_txe_mult_host(void *a, void *b, void *res);
157+
extern void _mlir_ciface_txe_div_host(void *a, void *b, void *res);
158+
extern void _mlir_ciface_txe_sqrt_host(void *a, void *res);
159+
extern void _mlir_ciface_txe_neg_host(void *a, void *res);
160+
extern void _mlir_ciface_txe_abs_host(void *a, void *res);
161+
extern void _mlir_ciface_txe_sin_host(void *a, void *res);
162+
extern void _mlir_ciface_txe_sigmoid_host(void *a, void *res);
163+
extern void _mlir_ciface_txe_silu_host(void *a, void *res);
164164
extern void ggml_tsi_log_tensor_data(tensor_log log_data);
165165

166166
#define NUM_OF_TXES 1

ggml/src/ggml-tsavorite/ggml-tsavorite.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,55 +389,55 @@ static txe_compute_pipeline_state_s tsi_kernel_setup(enum ggml_tsavorite_kernel_
389389
if (ggml_tsavorite_kernel_mode_flag == GGML_TSAVORITE_KERNEL_MODE_CPU)
390390
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_add_test;
391391
else
392-
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_add;
392+
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_add_host;
393393
kernel_pipeline->kernel_name = "TXE_ADD";
394394
flag = true;
395395
break;
396396
case GGML_TSAVORITE_KERNEL_TYPE_SUB:
397-
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_sub;
397+
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_sub_host;
398398
kernel_pipeline->kernel_name = "TXE_SUB";
399399
flag = true;
400400
break;
401401
case GGML_TSAVORITE_KERNEL_TYPE_MULT:
402402
if (ggml_tsavorite_kernel_mode_flag == GGML_TSAVORITE_KERNEL_MODE_CPU)
403403
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_mult_test;
404404
else
405-
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_mult;
405+
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_mult_host;
406406
kernel_pipeline->kernel_name = "TXE_MULT";
407407
flag = true;
408408
break;
409409
case GGML_TSAVORITE_KERNEL_TYPE_DIV:
410-
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_div;
410+
kernel_pipeline->_mlir_fptr_2_input = &_mlir_ciface_txe_div_host;
411411
kernel_pipeline->kernel_name = "TXE_DIV";
412412
flag = true;
413413
break;
414414
case GGML_TSAVORITE_KERNEL_TYPE_SQRT:
415-
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_sqrt;
415+
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_sqrt_host;
416416
kernel_pipeline->kernel_name = "TXE_SQRT";
417417
flag = true;
418418
break;
419419
case GGML_TSAVORITE_KERNEL_TYPE_NEG:
420-
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_neg;
420+
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_neg_host;
421421
kernel_pipeline->kernel_name = "TXE_NEG";
422422
flag = true;
423423
break;
424424
case GGML_TSAVORITE_KERNEL_TYPE_ABS:
425-
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_abs;
425+
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_abs_host;
426426
kernel_pipeline->kernel_name = "TXE_ABS";
427427
flag = true;
428428
break;
429429
case GGML_TSAVORITE_KERNEL_TYPE_SIN:
430-
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_sin;
430+
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_sin_host;
431431
kernel_pipeline->kernel_name = "TXE_SIN";
432432
flag = true;
433433
break;
434434
case GGML_TSAVORITE_KERNEL_TYPE_SIGMOID:
435-
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_sigmoid;
435+
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_sigmoid_host;
436436
kernel_pipeline->kernel_name = "TXE_SIGMOID";
437437
flag = true;
438438
break;
439439
case GGML_TSAVORITE_KERNEL_TYPE_SILU:
440-
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_silu;
440+
kernel_pipeline->_mlir_fptr_1_input = &_mlir_ciface_txe_silu_host;
441441
kernel_pipeline->kernel_name = "TXE_SILU";
442442
flag = true;
443443
break;

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,4 @@ target_link_libraries(${LLAMA_TEST_NAME} PRIVATE mtmd)
174174
# dummy executable - not installed
175175
get_filename_component(TEST_TARGET test-c.c NAME_WE)
176176
add_executable(${TEST_TARGET} test-c.c)
177-
target_link_libraries(${TEST_TARGET} PRIVATE llama ${TLIBS})
177+
target_link_libraries(${TEST_TARGET} PRIVATE ${TLIBS} llama stdc++)

tsi-pkg-build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ echo 'updating submodule'
66
git submodule update --recursive --init
77
cd ggml-tsi-kernel/
88
module load tsi4 gcc/13.3.0
9+
export MLIR_SDK_VERSION=/proj/rel/sw/sdk-r.0.1.3
910
echo 'creating python virtual env'
11+
/proj/local/Python-3.10.12/bin/python3 -m venv blob-creation
1012
python3 -m venv blob-creation
1113
source blob-creation/bin/activate
1214
echo 'installing mlir and python dependencies'
13-
pip install -r /proj/rel/sw/mlir-compiler/python/requirements-common.txt
14-
pip install /proj/rel/sw/mlir-compiler/python/mlir_external_packages-1.2.1-py3-none-any.whl
15+
pip install -r ${MLIR_SDK_VERSION}/compiler/python/requirements-common.txt
16+
pip install ${MLIR_SDK_VERSION}/compiler/python/mlir_external_packages-1.3.0-py3-none-any.whl
1517
pip install onnxruntime-training
1618

1719
#build TSI kernels for the Tsavorite backend
@@ -31,7 +33,6 @@ cd ../posix-kernel/
3133

3234
cd ../../
3335

34-
export MLIR_SDK_VERSION=/proj/work/rel/sw/sdk-r.0.1.2
3536
#Compile for posix with build-posix as a target folder
3637

3738
echo 'building llama.cp, ggml for tsavorite and other binary for posix'

0 commit comments

Comments
 (0)