Skip to content

Commit

Permalink
remove const_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyu-intel committed Dec 14, 2023
1 parent 9536f15 commit 1f25140
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions onnxruntime/core/mlas/lib/jblas_gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void*>(DataParams[i].B));
auto ptr = jblas::storage::gemm::PackedWeightParser::deserialBuffer(DataParams[i].B);
auto uptr = std::unique_ptr<jblas::storage::gemm::WeightBase>(ptr);
if (ptr) {
if (ptr->mPrologueID == JBLAS_PROLOGUEB_IDS::WeightKBlockS4) {
Expand Down Expand Up @@ -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<void*>(DataParams[i].B));
auto ptr = jblas::storage::gemm::PackedWeightParser::deserialBuffer(DataParams[i].B);
auto uptr = std::unique_ptr<jblas::storage::gemm::WeightBase>(ptr);
if (ptr) {
if (ptr->mPrologueID == JBLAS_PROLOGUEB_IDS::WeightKBlockS4) {
Expand Down Expand Up @@ -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<void*>(PackedBuf));
auto ptr = jblas::storage::gemm::PackedWeightParser::deserialBuffer(PackedBuf);
auto uptr = std::unique_ptr<jblas::storage::gemm::WeightBase>(ptr);
ORTThreading orth(ThreadPool);
auto N_ = static_cast<int>(N);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,13 @@ class StorageWeightKBlockF4 : public StorageWeightKBlockS4 {

class PackedWeightParser {
public:
static gemm::WeightBase* deserialBuffer(void* serialized_buf) {
auto rptr = reinterpret_cast<int8_t*>(serialized_buf);
static gemm::WeightBase* deserialBuffer(const void* serialized_buf) {
auto rptr = reinterpret_cast<int8_t*>(const_cast<void*>(serialized_buf));
rptr += WeightBase::offset();
int mProID = utils::deserialize<int>(rptr);
WeightBase* ptr = NULL;
if (mProID >= int(JBLAS_PROLOGUEB_IDS::Begin) && mProID < int(JBLAS_PROLOGUEB_IDS::End)) {
rptr = reinterpret_cast<int8_t*>(serialized_buf);
rptr = reinterpret_cast<int8_t*>(const_cast<void*>(serialized_buf));
auto type = static_cast<JBLAS_PROLOGUEB_IDS>(mProID);
switch (type) {
case JBLAS_PROLOGUEB_IDS::WeightPack:
Expand Down

0 comments on commit 1f25140

Please sign in to comment.