Skip to content

Commit 0af4992

Browse files
authored
Cap num_externs to 4096 (#18909)
Differential Revision: D100822659 Pull Request resolved: #18909
1 parent 8ed6e85 commit 0af4992

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

backends/xnnpack/runtime/XNNCompiler.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1916,9 +1916,17 @@ ET_NODISCARD Error XNNCompiler::compileModel(
19161916
xnn_status_to_string(status));
19171917

19181918
// create xnnpack subgraph
1919+
uint32_t num_externs = flatbuffer_graph->num_externs();
1920+
ET_CHECK_OR_RETURN_ERROR(
1921+
num_externs <= 4096,
1922+
InvalidProgram,
1923+
"XNNPACK flatbuffer blob has num_externs (%u) which exceeds maximum (4096)."
1924+
" This likely indicates a corrupted or invalid serialized graph",
1925+
num_externs);
1926+
19191927
xnn_subgraph_t subgraph_ptr = nullptr;
19201928
status = xnn_create_subgraph(
1921-
/*external_value_ids=*/flatbuffer_graph->num_externs(),
1929+
/*external_value_ids=*/num_externs,
19221930
/*flags=*/0,
19231931
&subgraph_ptr);
19241932
ET_CHECK_OR_RETURN_ERROR(

0 commit comments

Comments
 (0)