Onnx serializes model that contains `if`

Sometimes we need to build models with if like resizing the shorter side of an image to 640 in faster rcnn, in this situation, according to doc here, onnx can’t correctly serialize the model, does this problem have a solution?

we do not support models that have control flow to be exported to onnx yet, it’s slated to be released at a later stage.

You can use this solution :

  1. Define ModuleA which expects fixed size input and doesn’t have any control flow
  2. Define ModuleB which which handles the input resize and then call ModuleA

ModuleA can be exported into onnx format, and you should care about the resize manually.