Vengineerの戯言

人生は短いけど、長いです。人生を楽しみましょう!

TensorFlow Selectとは?

@Vengineerの戯言 : Twitter
SystemVerilogの世界へようこそすべては、SystemC v0.9公開から始まった

vengineer.hatenablog.com

のブログの中のビデオにも出てきた「TensorFlow Select」

Twitterで皆さんに聞いてみましたが、31人の回答によると知っている人は1割。

 で、では、「TensorFlow Select」とは?

 です。このビデオの「TensorFlow Select」のスライドを抜き出してみると、

Available now

  • Enables hundres more ops from TensorFlow on CPU.
  • Leverages eagper runtime
  • Caveat: binari size increase (~6MB compressed)

In the pipeline (このビデオでは、Future ではなく、in the pipeline を使っています)

  • Selective registration (of TensorFlow ops)
  • Improved performance

とあります。また、

Converter

  • Node def describles attributes values of op
  • Add a new custom op w/ NodeDef in flexbuffer

Runtime

  • Delegate interface resolves custom select ops
  • Copy TFLiet tensor + NodeDef into TF eager invocation

ガイドライとしてのドキュメントもあります。

www.tensorflow.org

TensorFlow Lite Converter をビルドするときには、下記のように --define=tflite_convert_with_select_tf_ops=true が必要なようです。これでビルドすると、TensorFlow Liteでサポートされていない Op には、”Flex”が prefix として付いて変換されます。

変換したモデルを動かすためには、Flex Delegateの共有ライブラリ lite/delegates/flex/delegate.so が必要になります。この共有ライブラリはデフォルト状態で bazel コマンドでビルドしても生成されません。

  % cd tensorflow/lite/delegates/flex
  % bazel build delegate

にて、手動でビルドする必要があります。ただし、これをビルドすると、TensorFlow Liteだけでなく、TensorFlow本体のソースコードをビルドするのでかなり時間がかかります。