diff options
author | Tim Dettmers <tim.dettmers@gmail.com> | 2022-09-11 11:55:09 -0700 |
---|---|---|
committer | Tim Dettmers <tim.dettmers@gmail.com> | 2022-09-11 11:55:09 -0700 |
commit | 19a7adca7a6c9bf7061a384d7e9d9b13676a1a88 (patch) | |
tree | c6c29473641febdcf5598fb6ce7ced5452469117 /csrc/common.cpp | |
parent | f0ae860c86039d1c1e41166aaf2153a5bd9b9a89 (diff) |
Fixed 2^31 max size issue for cpu blockwise quant.
Diffstat (limited to 'csrc/common.cpp')
-rw-r--r-- | csrc/common.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/csrc/common.cpp b/csrc/common.cpp index 972602b..52f0299 100644 --- a/csrc/common.cpp +++ b/csrc/common.cpp @@ -12,16 +12,16 @@ void *quantize_block(void *arguments) { // 1. find absmax in block float absmax_block = -FLT_MAX; - for (int i = args->block_idx; i < args->block_end; i++) + for (long long i = args->block_idx; i < args->block_end; i++) absmax_block = fmax(absmax_block, fabs(args->A[i])); - args->absmax[args->block_idx / BLOCK_SIZE] = absmax_block; + args->absmax[args->block_idx / args->blocksize] = absmax_block; - for (int i = args->block_idx; i < args->block_end; i++) { + for (long long i = args->block_idx; i < args->block_end; i++) { // 2. divide input value by absmax to normalize into [-1.0, 1.0] // 3. do binary search to find the closest value float normed_value = args->A[i] / absmax_block; - int idx = args->bin_searcher->scalar(normed_value); + long long idx = args->bin_searcher->scalar(normed_value); // 4. check minimal distance // The binary search returns always the value to the left, which might not be the closest value |