Search code examples
tensorflowmachine-learningkerasxilinxvitis-ai

Error compiling model with Vitis-AI : Data value is out of range


I'm building a simple custom Keras model shown below:

model = Sequential()
model.add(Conv2D(16, (16, 1), activation='relu', input_shape=(300,2,1) ))   
model.add(Dropout(0.1))

model.add(Conv2D(32, (16, 1), activation='relu'))                               
model.add(Dropout(0.2))

model.add(Flatten())

model.add(Dense(32, activation='relu'))
model.add(Dropout(0.5))

model.add(Dense(3, activation='softmax'))

The Keras model needs to be compiled using Xilinx's Vitis-AI to be ran on an FPGA. We're following the steps outlined by Xilinx's Vitis AI tutorials to compile the model.

However, we're running into the following error during the compilation stage:

[VAI_C-BACKEND][Check Failed: (kernel_h - stride_h) <= 3 * pixel_parallel * stride_h][/home/xbuild/conda-bld/dnnc_1592904456005/work/submodules/asicv2com/src/Operator/OperatorConv.cpp:53][DATA_OUTRANGE][Data value is out of range!]

Any ideas on what this error message could mean? Or even, how we can get more debugging information?

We've successfully trained and ran inference using this model before in a python environment.


Solution

  • THE INPUTS TO THE CNN MODEL NEED TO BE SQUARE FOR VITIS AI. There was nothing incorrect or unsupported about the model presented in the question above.

    The compile step will fail if the input images are not square as shown below:

    [VAI_C-BACKEND][Check Failed: (kernel_h - stride_h) <= 3 * pixel_parallel * stride_h][/home/xbuild/conda-bld/dnnc_1592904456005/work/submodules/asicv2com/src/Operator/OperatorConv.cpp:53][DATA_OUTRANGE][Data value is out of range!]
    

    If the input isn't square it must be padded to make a square.

    padding = int(input_shape[0] - input_shape[1])
    model.add(Conv2D(16, (16, 1), activation='relu', input_shape=(300,2+padding,1) )) 
    

    I hope that this answer helps someone.