Skip to content
Open
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
30 changes: 27 additions & 3 deletions backends/xnnpack/runtime/XNNCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,16 @@ Error defineTensor(
}

ET_CHECK_OR_RETURN_ERROR(
tensor_value != nullptr,
Internal,
"Deserialized Tensor is Null, this should never happen");
tensor_value != nullptr && tensor_value->dims() != nullptr,
InvalidProgram,
"Deserialized tensor is null, or tensor dims is null");

Comment on lines 287 to +291
ET_CHECK_OR_RETURN_ERROR(
tensor_value->num_dims() == tensor_value->dims()->size(),
InvalidProgram,
"Tensor num_dims %u does not match dims array size %u",
Comment on lines +291 to +295
tensor_value->num_dims(),
tensor_value->dims()->size());
Comment on lines 287 to +297

// Get tensor dims, here we need to use a vector in order
// to properly convert the uint32_t* to size_t*
Expand Down Expand Up @@ -966,6 +973,10 @@ Error defineStaticTransposeNode(
auto graph_node = node->xnode_union_as_XNNStaticTranspose();

// Get tensor dims, we need to convert the uint32_t* to size_t*
ET_CHECK_OR_RETURN_ERROR(
graph_node->perm() != nullptr,
InvalidProgram,
"StaticTranspose: perm is null");
std::vector<size_t> dims_data = flatbufferDimsToVector(graph_node->perm());
xnn_status status = xnn_define_static_transpose(
subgraph_ptr,
Expand Down Expand Up @@ -1031,6 +1042,11 @@ Error defineStaticConstantPadNode(
const fb_xnnpack::XNNStaticConstantPad* graph_node =
node->xnode_union_as_XNNStaticConstantPad();

ET_CHECK_OR_RETURN_ERROR(
graph_node->pre_paddings() != nullptr &&
graph_node->post_paddings() != nullptr,
InvalidProgram,
"StaticConstantPad: pre_paddings or post_paddings is null");
std::vector<size_t> pre_paddings_dims =
flatbufferDimsToVector(graph_node->pre_paddings());
std::vector<size_t> post_paddings_dims =
Expand Down Expand Up @@ -1111,6 +1127,10 @@ Error defineStaticReshapeNode(
auto graph_node = node->xnode_union_as_XNNStaticReshape();

// Get tensor dims, we need to convert the uint32_t* to size_t*
ET_CHECK_OR_RETURN_ERROR(
graph_node->new_shape() != nullptr,
InvalidProgram,
"StaticReshape: new_shape is null");
std::vector<size_t> dims_data =
flatbufferDimsToVector(graph_node->new_shape());
xnn_status status = xnn_define_static_reshape(
Expand Down Expand Up @@ -1406,6 +1426,10 @@ Error defineStaticSliceNode(

auto graph_node = node->xnode_union_as_XNNStaticSlice();

ET_CHECK_OR_RETURN_ERROR(
graph_node->offsets() != nullptr && graph_node->sizes() != nullptr,
InvalidProgram,
"StaticSlice: offsets or sizes is null");
std::vector<size_t> offsets = flatbufferDimsToVector(graph_node->offsets());
std::vector<size_t> sizes = flatbufferDimsToVector(graph_node->sizes());

Expand Down
Loading