ONNX
ONNX 란?
- Open Neural Network Exchange의 줄인 말로 이름과 깉이 다른 DNN 프레임워크 환경에서 만들어진 모델을 서로 호환되게 사용할 수 있도록 만들어진 공유 플랫폼
장점
- Framework Interoperability
- 특정 환경에서 생성된 모델을 다른 환경으로 import하여 자유롭게 사용 가능
- Shared OPtimization
- 규격화된 포멧으로 자리를 잡을 경우 다양한 환경에서 효율적으로 적용 가능
구성 방식
- ONNX exporter는 IR graph를 만든다는 목표를 가지고 있음
- 정보를 기록하는 방식에 따라 Trace, Script로 나눔
- Trace
- forward함수 내부에 Tensor 영상 혹은 유저 정의 함수 혹은 python 코드가 실행되며 forward를 한번 수행하는 동안 execution path에 존재한 모든 연산들을 IR로 기록
- forward함수 내부에 dynamic control flow가 존재한다면 Trace를 생성하기 위해 한번 forward가 호출되었을 때 거쳐가지 않은 control path는 추적이 되지 않음
- Input의 shape에 따라서 graph가 정적으로 고정
- tracing된 모델을 활용해서 training, inferencing을 한다면 example input과 정확히 동일한 형태의 input을 사용해야함
- Script
- Dynamic control flow를 살릴 수 있음
- example input을 필요로 하지 않음
- Trace
- 장단점
Trace | Script | |
장점 | Python primitive와의 호환성 문제가 적음 | 전체 코드를 보고 컴파일을 하기 때문에 Dynamic Control Flow를 살릴 수 있음 |
단점 | Dynamic Control Flow를 살릴 수 없음 example input을 필요로함 |
지원 하지 않는 Python 코드들이 많음 |
참고 자료 1 : https://en.wikipedia.org/wiki/Open_Neural_Network_Exchange
Open Neural Network Exchange - Wikipedia
The Open Neural Network Exchange (ONNX) [ˈɑnɪks][2] is an open-source artificial intelligence ecosystem[3] of technology companies and research organizations that establish open standards for representing machine learning algorithms and software tools t
en.wikipedia.org
참고 자료 2 : https://onnx.ai/
ONNX | Home
ONNX makes it easier to access hardware optimizations. Use ONNX-compatible runtimes and libraries designed to maximize performance across hardware. SUPPORTED ACCELERATORS
onnx.ai
참고 자료 3 : https://github.com/onnx/tutorials
GitHub - onnx/tutorials: Tutorials for creating and using ONNX models
Tutorials for creating and using ONNX models. Contribute to onnx/tutorials development by creating an account on GitHub.
github.com