Skip to content

Commit 42bfe3b

Browse files
committed
Update stats output sort based on imatrix type
1 parent 2756617 commit 42bfe3b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tools/imatrix/imatrix.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,15 +1284,18 @@ static bool show_statistics(const common_params & params) {
12841284
}
12851285

12861286
struct tensor_comparer {
1287+
bool legacy_mode;
1288+
explicit tensor_comparer(const bool legacy) : legacy_mode(legacy) {}
1289+
12871290
bool operator()(const tensor_statistics & a, const tensor_statistics & b) const {
12881291
std::string layer, name_a, name_b;
1289-
;
12901292
process_tensor_name(a.tensor, layer, name_a);
12911293
process_tensor_name(b.tensor, layer, name_b);
1292-
return name_a < name_b || (name_a == name_b && a.sum_values > b.sum_values);
1294+
return legacy_mode ? name_a < name_b || (name_a == name_b && a.sum_values > b.sum_values) :
1295+
name_a < name_b || (name_a == name_b && a.cossim > b.cossim);
12931296
}
12941297
};
1295-
std::sort(ts.begin(), ts.end(), tensor_comparer());
1298+
std::sort(ts.begin(), ts.end(), tensor_comparer(legacy_mode));
12961299

12971300
struct layer_stats {
12981301
float lyr_sum = 0.0f;

0 commit comments

Comments
 (0)