VOICEVOX / voicevox_core

無料で使える中品質なテキスト読み上げソフトウェア、VOICEVOXのコア
https://voicevox.hiroshiba.jp/
MIT License
864 stars 117 forks source link

Support CoreML via Onnxruntime CoreML EP (CoreMLで加速) #428

Open louy2 opened 1 year ago

louy2 commented 1 year ago

内容

New Rust binding to onnxruntime (#427) might enable using CoreML on Apple devices.

For the downloader, Microsoft provides prebuilt onnxruntime binary with CoreML EP in a CocoaPod onnxruntime-c (Podspec) (1.14.0 binary). (Alternative pods for mobile and obj-c are listed in Onnx Runtime CoreML EP documentation)

Pros 良くなる点

On macOS and iOS take full advantage of Apple Silicon GPU and Apple Neural Engine for inference acceleration.

macOSやiOSでApple Silicon GPUとApple Neural Engineをフル利用して加速できること。

Cons 悪くなる点

CoreML EP may not be compatible with all onnx models.

CoreML EPが実行できないONNXモデルがあるかもしれません。

実現方法

VOICEVOXのバージョン

0.?.0

OSの種類/ディストリ/バージョン

その他

Related 相関: #427 #399

Useful Links 使えそうなリンク:

PickledChair commented 1 year ago

Thank you for creating this issue!

Issue 作成ありがとうございます!

The libonnxruntime.dylib for macOS distributed by Microsoft is built with the --use_coreml flag turned on (cf. https://github.com/microsoft/onnxruntime/issues/11343#issuecomment-1108935687 ), so it can be implemented with a small modification of the current voicevox_core. In the past, I actually tried to implement voicevox_core with CoreML support. However, I did not see a reduction in execution time, so I could not evaluate that a significant performance improvement was achieved.

Microsoft が配布している macOS 向けの libonnxruntime.dylib は --use_coreml フラグをオンにしてビルドされているため (cf. https://github.com/microsoft/onnxruntime/issues/11343#issuecomment-1108935687 )、現在の voicevox_core の少しの改良でも実装可能です。以前、実際に CoreML 対応の voicevox_core を実装してみたことがありました。しかし実行時間の短縮が見られなかったので、著明なパフォーマンス向上が得られたとは評価できませんでした。

However, it may still be worthwhile to continue working on the following points:

ただし、以下の点でまだ取り組み続ける価値があるのかもしれません:

@Hiroshiba Is it acceptable to add CoreML support for macOS on an experimental basis, even if we don't see performance gains? It will make it easier to experiment to see if future onnxruntime updates, etc. will provide better performance gains from CoreML.

@Hiroshiba パフォーマンスの向上が見られないとしても、実験的に macOS の CoreML サポートを追加することは認められますか? 今後の onnxruntime のアップデート等で CoreML によるパフォーマンス向上が得られるようになっているかどうかを実験しやすくなります。

Hiroshiba commented 1 year ago

CoreML、良いと思います! CoreMLによって性能などが向上しなくても、ファイル容量やビルド時間が極端に増えたりしなければ!