Skip to content

Commit 359d792

Browse files
committed
fix crash
Signed-off-by: Xiaodong Ye <[email protected]>
1 parent e258f76 commit 359d792

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tests/test-backend-ops.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,9 @@ struct test_case {
765765
// pre-graph sentinel
766766
add_sentinel(ctx);
767767

768-
ggml_tensor * out = build_graph(ctx); if (op_name != nullptr && op_desc(out) != op_name) {
768+
ggml_tensor * out = build_graph(ctx);
769+
std::string current_op_name = op_desc(out);
770+
if (op_name != nullptr && current_op_name != op_name) {
769771
//printf(" %s: skipping\n", op_desc(out).c_str());
770772
ggml_free(ctx);
771773
return true;
@@ -789,7 +791,7 @@ struct test_case {
789791
// Create test result for unsupported operation
790792
test_result result;
791793
result.backend_name = ggml_backend_name(backend1);
792-
result.op_name = op_desc(out);
794+
result.op_name = current_op_name;
793795
result.op_params = vars();
794796
result.test_mode = "test";
795797
result.supported = false;
@@ -911,12 +913,13 @@ struct test_case {
911913

912914
ggml_backend_buffer_free(buf);
913915

914-
ggml_free(ctx); bool test_passed = ud.ok && cmp_ok;
916+
ggml_free(ctx);
915917

916918
// Create test result
919+
bool test_passed = ud.ok && cmp_ok;
917920
test_result result;
918921
result.backend_name = ggml_backend_name(backend1);
919-
result.op_name = op_desc(out);
922+
result.op_name = current_op_name;
920923
result.op_params = vars();
921924
result.test_mode = "test";
922925
result.supported = supported;
@@ -948,7 +951,9 @@ struct test_case {
948951
ggml_context_ptr ctx(ggml_init(params)); // smart ptr
949952
GGML_ASSERT(ctx);
950953

951-
ggml_tensor * out = build_graph(ctx.get()); if (op_name != nullptr && op_desc(out) != op_name) {
954+
ggml_tensor * out = build_graph(ctx.get());
955+
std::string current_op_name = op_desc(out);
956+
if (op_name != nullptr && current_op_name != op_name) {
952957
//printf(" %s: skipping\n", op_desc(out).c_str());
953958
return true;
954959
}
@@ -958,7 +963,7 @@ struct test_case {
958963
// Create test result for unsupported performance test
959964
test_result result;
960965
result.backend_name = ggml_backend_name(backend);
961-
result.op_name = op_desc(out);
966+
result.op_name = current_op_name;
962967
result.op_params = vars();
963968
result.test_mode = "perf";
964969
result.supported = false;
@@ -1063,7 +1068,7 @@ struct test_case {
10631068
// Create test result
10641069
test_result result;
10651070
result.backend_name = ggml_backend_name(backend);
1066-
result.op_name = op_desc(out);
1071+
result.op_name = current_op_name;
10671072
result.op_params = vars();
10681073
result.test_mode = "perf";
10691074
result.supported = true; // If we got this far, it's supported

0 commit comments

Comments
 (0)