From 1f251407d5d4ca0187dd4c2c9e9047efa9410951 Mon Sep 17 00:00:00 2001 From: luoyu-intel Date: Thu, 14 Dec 2023 19:52:25 +0800 Subject: [PATCH] remove const_cast --- onnxruntime/core/mlas/lib/jblas_gemm.cpp | 6 +++--- .../core/mlas/lib/x86_64/jblas/jblas/jit_blas_storage.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/onnxruntime/core/mlas/lib/jblas_gemm.cpp b/onnxruntime/core/mlas/lib/jblas_gemm.cpp index 4f56089439da4..2dde6a9895c9b 100644 --- a/onnxruntime/core/mlas/lib/jblas_gemm.cpp +++ b/onnxruntime/core/mlas/lib/jblas_gemm.cpp @@ -141,7 +141,7 @@ JblasSQ4GemmBatchDriver( ORTThreading orth(ThreadPool); bool processed = true; for (size_t i = 0; i < BatchN; i++) { - auto ptr = jblas::storage::gemm::PackedWeightParser::deserialBuffer(const_cast(DataParams[i].B)); + auto ptr = jblas::storage::gemm::PackedWeightParser::deserialBuffer(DataParams[i].B); auto uptr = std::unique_ptr(ptr); if (ptr) { if (ptr->mPrologueID == JBLAS_PROLOGUEB_IDS::WeightKBlockS4) { @@ -274,7 +274,7 @@ JblasSQ4GemmBatchWorkspaceSize( GetCPUDevice(); size_t size = 0; for (size_t i = 0; i < BatchN; i++) { - auto ptr = jblas::storage::gemm::PackedWeightParser::deserialBuffer(const_cast(DataParams[i].B)); + auto ptr = jblas::storage::gemm::PackedWeightParser::deserialBuffer(DataParams[i].B); auto uptr = std::unique_ptr(ptr); if (ptr) { if (ptr->mPrologueID == JBLAS_PROLOGUEB_IDS::WeightKBlockS4) { @@ -485,7 +485,7 @@ JblasQ4GemmPackB( bool JblasQ4GemmUnPackB(float* FpData, const void* PackedBuf, size_t N, size_t K, size_t ldb, MLAS_THREADPOOL* ThreadPool) { - auto ptr = jblas::storage::gemm::PackedWeightParser::deserialBuffer(const_cast(PackedBuf)); + auto ptr = jblas::storage::gemm::PackedWeightParser::deserialBuffer(PackedBuf); auto uptr = std::unique_ptr(ptr); ORTThreading orth(ThreadPool); auto N_ = static_cast(N); diff --git a/onnxruntime/core/mlas/lib/x86_64/jblas/jblas/jit_blas_storage.h b/onnxruntime/core/mlas/lib/x86_64/jblas/jblas/jit_blas_storage.h index 412dbf2f26562..052728dba687f 100644 --- a/onnxruntime/core/mlas/lib/x86_64/jblas/jblas/jit_blas_storage.h +++ b/onnxruntime/core/mlas/lib/x86_64/jblas/jblas/jit_blas_storage.h @@ -629,13 +629,13 @@ class StorageWeightKBlockF4 : public StorageWeightKBlockS4 { class PackedWeightParser { public: - static gemm::WeightBase* deserialBuffer(void* serialized_buf) { - auto rptr = reinterpret_cast(serialized_buf); + static gemm::WeightBase* deserialBuffer(const void* serialized_buf) { + auto rptr = reinterpret_cast(const_cast(serialized_buf)); rptr += WeightBase::offset(); int mProID = utils::deserialize(rptr); WeightBase* ptr = NULL; if (mProID >= int(JBLAS_PROLOGUEB_IDS::Begin) && mProID < int(JBLAS_PROLOGUEB_IDS::End)) { - rptr = reinterpret_cast(serialized_buf); + rptr = reinterpret_cast(const_cast(serialized_buf)); auto type = static_cast(mProID); switch (type) { case JBLAS_PROLOGUEB_IDS::WeightPack: