Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with transposing shape in CMSIS-NN batch matmul #2741

Merged
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
7 changes: 6 additions & 1 deletion tensorflow/lite/micro/kernels/cmsis_nn/batch_matmul.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ inline TfLiteStatus PopulateEvalData(
RuntimeShape tmp_r = SwapRowColumnDims(*rhs_shape);
rhs_shape->ReplaceWith(tmp_r.DimensionsCount(), tmp_r.DimsData());
}
if (!params->adj_x) {
// ReferenceOps and CMSIS-NN have different requirements for when the
// lhs shape should be transposed, so we have to treat float differently.
if (!params->adj_x && original_lhs_input->type == kTfLiteFloat32) {
RuntimeShape tmp_l = SwapRowColumnDims(*lhs_shape);
lhs_shape->ReplaceWith(tmp_l.DimensionsCount(), tmp_l.DimsData());
} else if (params->adj_x && original_lhs_input->type != kTfLiteFloat32) {
RuntimeShape tmp_l = SwapRowColumnDims(*lhs_shape);
lhs_shape->ReplaceWith(tmp_l.DimensionsCount(), tmp_l.DimsData());
}
Expand Down
Loading