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

627 views Asked by At

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.

2

There are 2 answers

0
stackunderflow On BEST ANSWER

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.

0
user15774525 On

The Vitis AI manual mentioned: "Currently, vai_c_tensorflow2 only supports Keras functional APIs. Sequential APIs will be supported in future releases." manual v1-3 page 86

So if you are using tf2 start by rewriting youre model to the functional format. functional api

If the error's persist, also look at the layers you are using if they are all supported there are differences between supported layers between tf1 and tf2.