数か月前にリリースされたAndroid 8.1でNeural Network機能がAOSPに追加された。
公式ガイド:
https://developer.android.com/ndk/guides/neuralnetworks/index.html
framework側に組み込まれたことで、Tensorflow等のライブラリをアプリに組み込まずに基本的なNN機能をAndroid標準機能としてアプリから使用できるようになった。
NNAPI is designed to provide a base layer of functionality for higher-level machine learning frameworks (such as TensorFlow Lite, Caffe2, or others) that build and train neural networks.
アプリからNeural Network APIを使用するにはNDKを用いる必要がある。
足し算・掛け算をNeural Network APIで行う公式サンプルアプリ↓
https://github.com/googlesamples/android-ndk/tree/master/nn_sample
サンプルでもassetフォルダに学習済みバイナリデータを格納し読み込んでいるように、Neural Network APIに学習機能はなく、
- 学習済みモデル読み込み
- 学習済みモデルに値入力
- 結果出力
といった使用の流れを想定していると思われる。
NNAPI is meant to be called by machine learning libraries, frameworks, and tools that let developers train their models off-device and deploy them on Android devices.
FW側の実装は↓
https://android.googlesource.com/platform/frameworks/ml/+/android-8.1.0_r14/nn/
https://android.googlesource.com/platform/frameworks/ml/+/android-8.1.0_r14/nn/common/operations/
辺りを見てみると、RNN、LSTM、CNN(Conv2D)等あり、ディープラーニングも使えそうだが、実装例が見つからず。