Skip to content

Add LSX support for S8S8 and S8U8 GEMM kernels #24397

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions onnxruntime/core/mlas/lib/mlasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,8 @@ struct MLAS_GEMM_QUANT_DISPATCH;

extern const MLAS_GEMM_QUANT_DISPATCH MlasGemmU8X8DispatchSse;
extern const MLAS_GEMM_QUANT_DISPATCH MlasGemmU8X8DispatchLSX;
extern const MLAS_GEMM_QUANT_DISPATCH MlasGemmS8S8DispatchLSX;
extern const MLAS_GEMM_QUANT_DISPATCH MlasGemmS8U8DispatchLSX;
extern const MLAS_GEMM_QUANT_DISPATCH MlasGemmU8S8DispatchSse41;
extern const MLAS_GEMM_QUANT_DISPATCH MlasGemmU8S8DispatchAvx2;
extern const MLAS_GEMM_QUANT_DISPATCH MlasGemmU8U8DispatchAvx2;
Expand Down Expand Up @@ -1150,6 +1152,8 @@ struct MLAS_PLATFORM {
#if defined(MLAS_TARGET_LARCH64)
const MLAS_GEMM_QUANT_DISPATCH* GemmU8S8Dispatch;
const MLAS_GEMM_QUANT_DISPATCH* GemmU8U8Dispatch;
const MLAS_GEMM_QUANT_DISPATCH* GemmS8S8Dispatch;
const MLAS_GEMM_QUANT_DISPATCH* GemmS8U8Dispatch;
MLAS_GEMM_FLOAT_KERNEL* GemmFloatKernel;
MLAS_GEMM_DOUBLE_KERNEL* GemmDoubleKernel;
MLAS_CONV_FLOAT_KERNEL* ConvNchwFloatKernel;
Expand Down
4 changes: 4 additions & 0 deletions onnxruntime/core/mlas/lib/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,14 @@ Return Value:

this->GemmU8S8Dispatch = &MlasGemmU8X8DispatchLSX;
this->GemmU8U8Dispatch = &MlasGemmU8X8DispatchLSX;
this->GemmS8S8Dispatch = &MlasGemmS8S8DispatchLSX;
this->GemmS8U8Dispatch = &MlasGemmS8U8DispatchLSX;
}else if( cap_lsx ){
this->GemmFloatKernel = MlasGemmFloatKernelLSX;
this->GemmU8S8Dispatch = &MlasGemmU8X8DispatchLSX;
this->GemmU8U8Dispatch = &MlasGemmU8X8DispatchLSX;
this->GemmS8S8Dispatch = &MlasGemmS8S8DispatchLSX;
this->GemmS8U8Dispatch = &MlasGemmS8U8DispatchLSX;
this->TransposePackB16x4Routine = MlasSgemmTransposePackB16x4LSX;
this->GemmDoubleKernel = MlasGemmDoubleKernelLSX;
this->ConvNchwFloatKernel = MlasConvNchwFloatKernelLSX;
Expand Down
5 changes: 4 additions & 1 deletion onnxruntime/core/mlas/lib/qgemm.h
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,10 @@ MlasGemmQuantGetDispatch(
GemmQuantDispatch = GetMlasPlatform().GemmU8X8Dispatch;
}
#elif defined(MLAS_TARGET_LARCH64)
if (!AIsSigned) {
if (AIsSigned) {
GemmQuantDispatch =
BIsSigned ? GetMlasPlatform().GemmS8S8Dispatch : GetMlasPlatform().GemmS8U8Dispatch;
} else { // !AIsSigned
GemmQuantDispatch =
BIsSigned ? GetMlasPlatform().GemmU8S8Dispatch : GetMlasPlatform().GemmU8U8Dispatch;
}
Expand Down
Loading
Loading