One: [cker/ruy] EXPERIMENTAL_RUY_FEATURE flag not working for android

Created on 4 Aug 2020  路  3Comments  路  Source: Samsung/ONE

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

bug

Most helpful comment

dynamic_cast in FullyConnectedLayer.cc produces nullptr for correct casting
https://github.com/Samsung/ONE/blob/60dd70837f2331c8f69555ed7b8dd7e03becbce4/runtime/onert/backend/cpu/ops/FullyConnectedLayer.cc#L135

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

I found some pages explain about dynamic_cast in Android

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.

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?

All 3 comments

dynamic_cast in FullyConnectedLayer.cc produces nullptr for correct casting
https://github.com/Samsung/ONE/blob/60dd70837f2331c8f69555ed7b8dd7e03becbce4/runtime/onert/backend/cpu/ops/FullyConnectedLayer.cc#L135

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

I found some pages explain about dynamic_cast in Android

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.

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?

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

Fixed by #3654.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

binarman picture binarman  路  3Comments

mhs4670go picture mhs4670go  路  3Comments

mhs4670go picture mhs4670go  路  4Comments

jinevening picture jinevening  路  3Comments

lucenticus picture lucenticus  路  3Comments