File format converter

Overview

../../_images/file_format_converter_workflow.png

File format converter will realize Neural Network Libraries (or Console) workflow with ONNX file format, and also NNabla C Runtime.

File format converter has following functions.

  • Convert NNP valiations to valid NNP
  • Convert ONNX to NNP
  • Convert NNP to ONNX
  • Convert NNP to NNB(Binary format for NNabla C Runtime)
  • Convert NNP to C Source code for NNabla C Runtime

NNP

NNP is file format of NNabla.

NNP format is described at Data Format.

But with this file format converter is work with several variation of NNP.

  • Standard NNP format (.nnp)
  • Contents of NNP files(.nntxt, .prototxt, .h5, .protobuf)

Convert NNP to NNP

Sometimes we neeed convert NNP to NNP.

Most major usecase, expand repeat or recurrent network supported by Neural Network Console but does not supported by C++ API.

$ nnabla_cli convert --nnp-no-expand-network input.nnp output.nnp

Convert Contents of NNP to NNP

Current version of Neural Network Console outputs .nntxt and .h5 as training result.

Then we need to convert separated files into single NNP and parameters store with protobuf format.

Usage

  • Convert console output to single NNP file
$ nnabla_cli convert net.nntxt parameters.h5 output.nnp
  • Convert console output to single NNP file without expanding Repeat or recurrent.
$ nnabla_cli convert --nnp-no-expand-network net.nntxt parameters.h5 output.nnp
  • Keep parameter format as hdf5
$ nnabla_cli convert --nnp-no-expand-network --nnp-parameter-h5 net.nntxt parameters.h5 output.nnp
  • Everything into single nntxt.
$ nnabla_cli convert --nnp-parameter-nntxt net.nntxt parameters.h5 output.nntxt

ONNX converter

Limitation

Usage

  • Convert NNP to ONNX
$ nnabla_cli convert input.nnp output.onnx
  • Convert ONNX to NNP
$ nnabla_cli convert input.onnx output.nnp

Work with NNabla C Runtime

NNB

NNB is compact binary format for NNabla C Runtime. It is designed for nnabla-c-runtime.

C Source Code

File format converter supports C source code output for nnabla-c-runtime.

Usage

  • Convert NNP to NNB
$ nnabla_cli convert input.nnp output.nnb
  • Convert NNP to C source code.
$ nnabla_cli convert -O CSRC input.onnx output-dir