Skip to content

Commit 1d5f25c

Browse files
committed
Add build_commit and build_number in test_result
Signed-off-by: Xiaodong Ye <yeahdongcn@gmail.com>
1 parent bea01ea commit 1d5f25c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

tests/test-backend-ops.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
#include <thread>
3939
#include <vector>
4040

41+
// External declarations for build info
42+
extern int LLAMA_BUILD_NUMBER;
43+
extern const char *LLAMA_COMMIT;
44+
4145
static void init_tensor_uniform(ggml_tensor * tensor, float min = -1.0f, float max = 1.0f) {
4246
size_t nels = ggml_nelements(tensor);
4347
std::vector<float> data(nels);
@@ -347,6 +351,8 @@ static bool output_format_from_str(const std::string & s, output_formats & forma
347351
// Test result structure for SQL output
348352
struct test_result {
349353
std::string test_time;
354+
std::string build_commit;
355+
int build_number;
350356
std::string backend_name;
351357
std::string op_name;
352358
std::string op_params;
@@ -375,6 +381,10 @@ struct test_result {
375381
char buf[32];
376382
std::strftime(buf, sizeof(buf), "%FT%TZ", gmtime(&t));
377383
test_time = buf;
384+
385+
// Set build info
386+
build_commit = LLAMA_COMMIT;
387+
build_number = LLAMA_BUILD_NUMBER;
378388
}
379389

380390
test_result(const std::string& backend_name, const std::string& op_name, const std::string& op_params,
@@ -389,11 +399,15 @@ struct test_result {
389399
char buf[32];
390400
std::strftime(buf, sizeof(buf), "%FT%TZ", gmtime(&t));
391401
test_time = buf;
402+
403+
// Set build info
404+
build_commit = LLAMA_COMMIT;
405+
build_number = LLAMA_BUILD_NUMBER;
392406
}
393407

394408
static const std::vector<std::string> & get_fields() {
395409
static const std::vector<std::string> fields = {
396-
"test_time", "backend_name", "op_name", "op_params", "test_mode",
410+
"test_time", "build_commit", "build_number", "backend_name", "op_name", "op_params", "test_mode",
397411
"supported", "passed", "error_message", "time_us", "flops",
398412
"bandwidth_gb_s", "memory_kb", "n_runs"
399413
};
@@ -406,7 +420,7 @@ struct test_result {
406420
if (field == "supported" || field == "passed") {
407421
return BOOL;
408422
}
409-
if (field == "memory_kb" || field == "n_runs") {
423+
if (field == "memory_kb" || field == "n_runs" || field == "build_number") {
410424
return INT;
411425
}
412426
if (field == "time_us" || field == "flops" || field == "bandwidth_gb_s") {
@@ -418,6 +432,8 @@ struct test_result {
418432
std::vector<std::string> get_values() const {
419433
return {
420434
test_time,
435+
build_commit,
436+
std::to_string(build_number),
421437
backend_name,
422438
op_name,
423439
op_params,

0 commit comments

Comments
 (0)