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

[cker/ruy] EXPERIMENTAL_RUY_FEATURE flag not working for android #3632

Closed
periannath opened this issue Aug 4, 2020 · 3 comments
Closed

[cker/ruy] EXPERIMENTAL_RUY_FEATURE flag not working for android #3632

periannath opened this issue Aug 4, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@periannath
Copy link
Contributor

EXPERIMENTAL_RUY_FEATURE flag is introduced in #3446.

This flag works well on arm32 linux, but it is not working on arm64 android.

I'll investigate the reason of this error.

/cc @YongseopKim

@periannath periannath added the bug Something isn't working label Aug 4, 2020
@periannath periannath self-assigned this Aug 4, 2020
@periannath periannath added this to the Sprint 2020 #24 milestone Aug 4, 2020
@periannath
Copy link
Contributor Author

dynamic_cast in FullyConnectedLayer.cc produces nullptr for correct casting

auto weight_tensor = dynamic_cast<const Tensor *>(_weights);

  • This dynamic_cast works correctly on arm32 linux
  • Produces nullptr only at arm64 android

I found some pages explain about dynamic_cast in Android

  • NDK document for common problems

    Problem: Exceptions are not being caught when thrown across shared library boundaries, or dynamic_cast is failing.
    Solution: Add a key function to your types. A key function is the first non-pure, out-of-line virtual function for a type. For an example, see the discussion on Issue 533.

  • How to add a key function

In summary

  • dynamic_cast is not working across shared library boundaries (NDK only)
    • Declared type of _weight is IPortableTensor defined at libonert_core.so
    • Actual type of _weight is cpu_common::Tensor defined at libbackend_cpu.so
  • Solution
    • Method 1 : Add a key function to IPortableTensor and cpu_common::Tensor
      • Problem : Thers's no cpp file for IPortableTensor
    • Method 2 : Using static_cast instead of dynamic_cast
      • Problem : Type check for polymorphism is missing
      • Maybe use nnfw::misc::polymorphic_downcast instead of static_cast?

@periannath
Copy link
Contributor Author

Method 2 runs well on android. I've uploaded PR #3654.

@periannath
Copy link
Contributor Author

Fixed by #3654.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant