We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 17b7109 commit 9c22a28Copy full SHA for 9c22a28
src/layer/gemm.cpp
@@ -212,7 +212,9 @@ int Gemm::load_model(const ModelBin& mb)
212
{
213
// block quantize
214
const i6x4_t* i6ptr1 = i6ptr + j * block_size / 4;
215
- const float inv_scale = 1.f / scale_ptr[j];
+ // Prevent division by zero: if scale_ptr[j] == 0, use 1.0 as safe default
216
+ const float safe_scale = (scale_ptr[j] == 0.f) ? 1.f : scale_ptr[j];
217
+ const float inv_scale = 1.f / safe_scale;
218
float* ptr1 = ptr + j * block_size;
219
const int block_size1 = std::min(block_size, constantK - j * block_size);
220
0 commit comments