Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion backends/xnnpack/runtime/XNNCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,12 @@ ET_NODISCARD Error XNNCompiler::compileModel(
flatbuffers::GetBufferIdentifier(flatbuffer_data));

auto flatbuffer_graph = fb_xnnpack::GetXNNGraph(flatbuffer_data);
ET_CHECK_OR_RETURN_ERROR(
flatbuffer_graph != nullptr && flatbuffer_graph->xvalues() != nullptr &&
flatbuffer_graph->xnodes() != nullptr,
InvalidProgram,
"Failed to deserialize XNNPACK flatbuffer graph; null graph, xvalues, or xnodes.");
Comment on lines +1847 to +1851

// initialize xnnpack
xnn_status status = xnn_initialize(/*allocator =*/nullptr);
ET_CHECK_OR_RETURN_ERROR(
Expand All @@ -1853,9 +1859,18 @@ ET_NODISCARD Error XNNCompiler::compileModel(
xnn_status_to_string(status));

// create xnnpack subgraph
uint32_t num_externs = flatbuffer_graph->num_externs();
uint32_t num_values = flatbuffer_graph->xvalues()->size();
ET_CHECK_OR_RETURN_ERROR(
num_externs <= num_values,
InvalidProgram,
"num_externs (%u) exceeds total number of values (%u)",
num_externs,
num_values);

xnn_subgraph_t subgraph_ptr = nullptr;
status = xnn_create_subgraph(
/*external_value_ids=*/flatbuffer_graph->num_externs(),
/*external_value_ids=*/num_externs,
/*flags=*/0,
&subgraph_ptr);
ET_CHECK_OR_RETURN_ERROR(
Expand Down
Loading