Skip to content

Commit

Permalink
w
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Nov 4, 2024
1 parent 952bedd commit 502d58b
Show file tree
Hide file tree
Showing 2 changed files with 6,827 additions and 324 deletions.
14 changes: 11 additions & 3 deletions src/layer/gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,18 @@ static void gemm_transB_int8(const Mat& A_int8, const Mat& BT_int8, const Mat& A
int sum = 0;
for (int k = 0; k < K; k++)
{
// NCNN_LOGE("ptrA[%d] %d", k, ptrA[k]);
// if (M==4 && N==7)
// {
// NCNN_LOGE("ptrA[%d] %d %d", k, ptrA[k], ptrBT[k]);
// }
sum += ptrA[k] * ptrBT[k];
}

// if (M==4 && N==7)
// {
// NCNN_LOGE("sum %d", sum);
// }

float sum_fp32 = sum * descale;

if (ptrC)
Expand Down Expand Up @@ -501,11 +509,11 @@ int Gemm::forward_int8(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& t
absmax = std::max(absmax, (float)fabs(ptr[k]));
}

// NCNN_LOGE("A[%d] absmax %f", i, absmax);

float A_int8_scale = absmax == 0.f ? 1.f : 127.f / absmax;
A_int8_scales[i] = A_int8_scale;

// NCNN_LOGE("A[%d] absmax %.9f %.9f", i, absmax, A_int8_scale);

signed char* ptrAi = A_int8.row<signed char>(i);

for (int k = 0; k < A_int8.w; k++)
Expand Down
Loading

0 comments on commit 502d58b

Please sign in to comment.