Skip to content

Commit 34e68b5

Browse files
committed
remotingbackend: add an optional call to support_op to avoid crashing the backend if the tensor is not supported
1 parent 65b92b9 commit 34e68b5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ggml/src/ggml-remotingbackend/backend-dispatched-backend.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ backend_graph_compute(struct vn_cs_encoder *enc, struct vn_cs_decoder *dec, stru
3232
ggml_cgraph *cgraph = vn_decode_ggml_cgraph(&secondary_dec, cgraph_size);
3333

3434
ggml_status status;
35+
#if APIR_BACKEND_CHECK_SUPPORTS_OP == 1
36+
for (int idx = 0; idx < cgraph->n_nodes; idx++) {
37+
ggml_tensor *op = ggml_graph_node(cgraph, idx);
38+
if (dev->iface.supports_op(dev, op)) {
39+
continue;
40+
}
41+
ERROR("Graph node %d (%s) not supported by the backend :/", idx, ggml_op_desc(op));
42+
43+
status = GGML_STATUS_ABORTED;
44+
vn_encode_ggml_status(enc, &status);
45+
46+
stop_timer(&graph_compute_timer);
47+
return 0;
48+
}
49+
#endif
3550
status = bck->iface.graph_compute(bck, cgraph);
3651

3752
vn_encode_ggml_status(enc, &status);

ggml/src/ggml-remotingbackend/shared/apir_backend.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// 1 is fast, 0 avoid micro-benchmark crashes
1313
#define APIR_DEVICE_SUPPORTS_OP_ALWAYS_TRUE 0
1414

15+
// 0 is fast, 1 avoids the backend to crash if an unsupported tensor is received
16+
#define APIR_BACKEND_CHECK_SUPPORTS_OP 0
17+
1518
typedef uintptr_t apir_buffer_type_host_handle_t;
1619
typedef uintptr_t apir_buffer_host_handle_t;
1720

0 commit comments

Comments
 (0)