gpu delegate的性能,tensorflow lite的nnapi在android mobile上几乎一样

Performance of gpu delegate, nnapi of tensorflow lite are almost the same on android mobile

我使用以下代码更改 phone(G3226)

上的委托
try {     
      if(delegateNum == 1){
        GpuDelegate delegate = new GpuDelegate();
        Interpreter.Options options = (new Interpreter.Options()).addDelegate(delegate);
        d.tfLite = new Interpreter(loadModelFile(assetManager, modelFilename), options);
      }else if(delegateNum == 2){
        NnApiDelegate delegate = new NnApiDelegate();
        Interpreter.Options options = (new Interpreter.Options()).addDelegate(delegate);
        d.tfLite = new Interpreter(loadModelFile(assetManager, modelFilename), options);
      }else{
        d.tfLite = new Interpreter(loadModelFile(assetManager, modelFilename));
      }      

    } catch (Exception e) {
      throw new RuntimeException(e);
    }

但是性能几乎一样,不知道会发生什么。

我猜的可能原因:

  1. 这个模型太小了,gpu或者nnapi还不够复杂
  2. 我的 phone 上的 gpu 或 nnapi 很弱
  3. 我的 phone 不支持 gpu 或 nnapi,所以他们退回到 cpu

如果是 3,我如何检查我的 phone 是否支持 gpu 或 nnapi?谢谢

一些事情:

  1. 量化的 SSD 模型可能已过时,请查看 these ones for better accuracy. You will have to convert them with these instructions 以获取 .tflite 版本。

  2. SSD 型号有一个很大的 post 处理步骤 (NMS),无法加速。因此,SSD 模型的差异通常小于用于分类的 MobileNet 等更简单的模型。

  3. NNAPI 仅适用于 Android 8.1 or later - 您的 phone 也是如此吗?此外,NNAPI 可能无法在所有架构上加速,因此存在这种情况。

  4. GPU 委托不支持量化模型(目前)。