Skip to content

Commit 4d1325e

Browse files
committed
Refactor variables
1 parent a32a2ec commit 4d1325e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

tools/imatrix/imatrix.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,10 +1211,10 @@ static bool show_statistics(const common_params & params) {
12111211
std::sort(ts.begin(), ts.end(), tensor_comparer());
12121212

12131213
struct weighted_stats {
1214-
float weighted_bias = 0.0f;
1215-
float weighted_zd = 0.0f;
1216-
float weighted_cossim = 0.0f;
1217-
int total_elements = 0;
1214+
float w_sum = 0.0f;
1215+
float w_zd = 0.0f;
1216+
float w_cossim = 0.0f;
1217+
int n = 0;
12181218
};
12191219
std::map<int, weighted_stats> ws;
12201220

@@ -1262,22 +1262,22 @@ static bool show_statistics(const common_params & params) {
12621262
tstat.cossim
12631263
);
12641264

1265-
const float weighted_bias = tstat.elements * tstat.sum_values;
1266-
const float weighted_zd = tstat.elements * tstat.zd_score;
1267-
const float weighted_cossim = tstat.elements * tstat.cossim;
1265+
const float w_sum = tstat.elements * tstat.sum_values;
1266+
const float w_zd = tstat.elements * tstat.zd_score;
1267+
const float w_cossim = tstat.elements * tstat.cossim;
12681268

12691269
if (ws.find(blk) != ws.end()) {
1270-
ws[blk].weighted_bias += weighted_bias;
1271-
ws[blk].weighted_zd += weighted_zd;
1272-
ws[blk].weighted_cossim += weighted_cossim;
1273-
ws[blk].total_elements += tstat.elements;
1270+
ws[blk].w_sum += w_sum;
1271+
ws[blk].w_zd += w_zd;
1272+
ws[blk].w_cossim += w_cossim;
1273+
ws[blk].n += tstat.elements;
12741274
} else {
12751275
weighted_stats temp_ws;
1276-
temp_ws.weighted_bias = weighted_bias;
1277-
temp_ws.weighted_zd = weighted_zd;
1278-
temp_ws.weighted_cossim = weighted_cossim;
1279-
temp_ws.total_elements = tstat.elements;
1280-
ws[blk] = temp_ws;
1276+
temp_ws.w_sum = w_sum;
1277+
temp_ws.w_zd = w_zd;
1278+
temp_ws.w_cossim = w_cossim;
1279+
temp_ws.n = tstat.elements;
1280+
ws[blk] = temp_ws;
12811281
}
12821282
}
12831283

@@ -1289,14 +1289,14 @@ static bool show_statistics(const common_params & params) {
12891289
const auto & layer = first;
12901290
const auto & stats = second;
12911291

1292-
if (stats.total_elements == 0) {
1292+
if (stats.n == 0) {
12931293
continue;
12941294
}
12951295

12961296
if (layer >= 0) {
1297-
const float bias = stats.weighted_bias / stats.total_elements;
1298-
const float zd = stats.weighted_zd / stats.total_elements;
1299-
const float cossim = stats.weighted_cossim / stats.total_elements;
1297+
const float w_sum = stats.w_sum / stats.n;
1298+
const float w_zd = stats.w_zd / stats.n;
1299+
const float w_cossim = stats.w_cossim / stats.n;
13001300

13011301
LOG_INF("%5d\t%14.2f\t%10.4f%%\t%6.4f\n", layer, bias, 100.0f * zd, cossim);
13021302
}

0 commit comments

Comments
 (0)