Skip to content

Conversation

@SriHarsha-23
Copy link

@SriHarsha-23 SriHarsha-23 commented Dec 13, 2025

Description

This PR addresses a stability issue in TfLiteWeightAccessor where loading incompatible or uninitialized models triggers a RET_CHECK failure, causing the application to crash (SIGABRT).

Context

As reported in #5600, using the Falcon CPU model on Android causes a hard crash due to dimension mismatches in quantized scale tensors. The current implementation uses RET_CHECK macros which terminate the process immediately upon failure.

Implementation

This change refactors LoadWeight and LoadTransposedWeight to replace fatal assertions with proper error handling:

  • Replaced RET_CHECK macros with standard absl::InternalError (for uninitialized models) and absl::InvalidArgumentError (for dimension mismatches).
  • Ensures the API returns a verifiable absl::Status that the caller can handle gracefully, rather than crashing the entire application.

Fixed Issue

Fixes #5600

Type of Change

  • Bug fix (non-breaking change which improves reliability)

Test Plan

Static Verification: * Verified that the logic correctly implements absl::Status returns and adheres to C++ best practices.

  • Confirmed clang-format Google style compliance.

CI/Build: * Relying on the repository's CI pipeline to verify the build against Android/iOS targets and run the regression suite, as the full cross-compilation environment is not available locally.

@google-cla
Copy link

google-cla bot commented Dec 13, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Replaces hard RET_CHECK failures with absl::InternalError and absl::InvalidArgumentError to prevent crashes on invalid models. Fixes google-ai-edge#5600.
@SriHarsha-23 SriHarsha-23 force-pushed the fix-crash-tflite-accessor branch from fad398f to 8a9048f Compare December 13, 2025 20:18
@SriHarsha-23
Copy link
Author

Hi @google-admin, I noticed the CI workflows are waiting for manual approval (Security Scan). Since this is my first contribution, I don't have permission to trigger them. Could a maintainer please approve the workflows so the tests can run? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant