Skip to content

Commit

Permalink
feat(python): don't check .sparsity in interpreter (#2944)
Browse files Browse the repository at this point in the history
Remove the check for sparse tensors in the Python interpreter wrapper.
This fixes a broken build when TF_LITE_STATIC_MEMORY is set, which
should always be the case in TFLM. TfLiteTensor objects don't have a
.sparsity member when TF_LITE_STATIC_MEMORY is set, so this check
can't be made.

This prepares for an upcoming commit setting TF_LITE_STATIC_MEMORY
during Bazel builds. This hasn't caused build failures in Make builds,
which have always set TF_LITE_STATIC_MEMORY, because Make builds don't
build the Python interpreter wrapper.

BUG=#2636
  • Loading branch information
rkuester authored Nov 27, 2024
1 parent 1276385 commit c28b493
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions python/tflite_micro/interpreter_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ bool CheckTensor(const TfLiteTensor* tensor) {
return false;
}

if (tensor->sparsity != nullptr) {
PyErr_SetString(PyExc_ValueError, "TFLM doesn't support sparse tensors");
return false;
}

int py_type_num = TfLiteTypeToPyArrayType(tensor->type);
if (py_type_num == NPY_NOTYPE) {
PyErr_SetString(PyExc_ValueError, "Unknown tensor type.");
Expand Down

0 comments on commit c28b493

Please sign in to comment.