Converters

Converters are Python libraries that run on x86 and are used to convert Keras or ONNX models to ElcoreNN format.

Supported operators

Converters from Keras/ONNX to ElcoreNN supports the following neural network operators:

Operators below are combination of Keras layers and ONNX Operators.

  • ✓: defined in the source framework, converter supports operator.

  • ×: defined in the source framework, converter doesn’t support operator.

  • empty: not defined in the source framework.

Operator

keras-elcorenn

onnx-elcorenn

2D Average pooling

✓

×

2D Convolution (dilation=1, groups=1)

✓

✓

2D Depth-wise convolution (dilation=1, multiplier=1)

✓

✓

2D Global average pooling

✓

✓

2D Max pooling

✓

✓

2D Transposed convolution (dilation=1)

✓

×

2D Upsampling (interpolation=”nearest”)

✓

Add (including broadcasting, only for two tensors)

✓

✓

BatchNormalization

✓

✓

Cast

✓

Concat

✓

✓

ConstantOfShape

✓

Gemm (Dense)

✓

✓

Equal

✓

Exp

✓

Expand

✓

Flatten

✓

✓

Gather

✓

ReduceL2 (L2 normalization)

✓

×

Log

✓

Mul (including broadcasting)

✓

✓

Pad (zero padding)

✓

×

Pow

✓

Range

✓

ReLU

✓

✓

ReLU6

✓

Reshape

✓

✓

Resize

✓

Shape

✓

Sigmoid

✓

✓

Slice

✓

Softmax

✓

✓

Sub

×

✓

Tanh

✓

✓

Transpose

✓

✓

Unsqueeze

✓

Where

✓

ElcoreNN model format

ElcoreNN model format is two files. The first is a JSON file that describes the layers of the model. The second is a binary file that contains the weights of the model.

keras-elcorenn and onnx-elcorenn convert Keras and ONNX model to ElcoreNN model format.

keras-elcorenn

keras-elcorenn is a Python library that converts a model from Keras to ElcoreNN.

Requirements:

  • python version >=3.7

  1. Download keras-elcorenn archive:

    wget --no-check-certificate https://box.elvees.com/index.php/s/SJRtBoB2HjFtAb9/download/keras-elcorenn-1.0.0.tar.gz
    
  2. Activate virtual environment:

    python3 -m venv env
    source ./env/bin/activate
    
  3. Installation from archive:

    pip install keras-elcorenn-1.0.0.tar.gz
    
  4. Convert model:

    python -m keras2elcorenn.convert --keras-model=<path-to-keras-model>
    

    To see more options run:

    python -m keras2elcorenn.convert --help
    

onnx-elcorenn

onnx-elcorenn is a Python library that converts a model from ONNX to ElcoreNN.

Requirements:

  • python3.6

  1. Download onnx-elcorenn archive and extract:

    wget --no-check-certificate https://box.elvees.com/index.php/s/MeYA8tEsTt5ew68/download/onnxparser-v1.2.1.tar.gz
    tar xfv onnxparser-v1.2.1.tar.gz
    
  2. Install requirements (it is recommended to use a virtual environment):

    cd onnxparser-v1.2.1
    python3.6 -m venv env
    source ./env/bin/activate
    pip install --upgrade pip
    pip install -r requirements.txt
    
  3. Put your onnx model to onnx_models folder.

  4. Run converter:

    python onnx_converter.py -n <model-name.onnx> -at
    

    Converter will write result to json_models/<model-name>.onnx folder.

    To see more options run:

    python onnx_converter.py --help
    

    or see README.md file.