text: 
  
  TITLE
  convert_graph_to_onnx.py and associated example notebook are broken for TensorFlow
  
  COMMENTS
  7
  
  REACTIONS
  +1: 0
  -1: 0
  laugh: 0
  hooray: 0
  heart: 0
  rocket: 0
  eyes: 0
  
  BODY
  ## Information
  The `convert_graph_to_onnx.py` file and the associated [example notebook](https://github.com/huggingface/transformers/blob/master/notebooks/04-onnx-export.ipynb) appear to be broken for TensorFlow.
  
  
  For ONNX-exported TensorFlow models, **only input tokens of length 5 are accepted**.  Other inputs (e.g., `len(tokens)>5`) result in an error:
  
  ```
  InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: input_ids for the following indices
  index: 1 Got: 6 Expected: 5
  ```
  Also, If you run `session.get_inputs()` on ONNX-exported TensorFlow model, only `input_ids` key is listed as inputs (i.e., no `attention_mask`) while ONNX PyTorch behaves differently:
  ```python
  # ONNX TensorFlow inputs for BERT model
  print([input.name for input in cpu_model.get_inputs()])
  # only prints 'input_ids' - no 'attention_mask'
  
  # ONNX PyTorch inputs for BERT model
  print([input.name for input in cpu_model.get_inputs()])
  # prints ['input_ids', 'attention_mask', 'token_type_ids']
  ```
  
  
  ## How to Reproduce
  In the [example notebook](https://github.com/huggingface/transformers/blob/master/notebooks/04-onnx-export.ipynb), uncomment this TensorFlow `convert` line:
  ```
  convert(framework="tf", model="bert-base-cased", output="onnx-test-tf/bert-base-cased.onnx", opset=11)
  ```
  I have also posted [this Google Colab notebook](https://colab.research.google.com/drive/1A2frWgfRlL5Ysf7xVVifx58NmEoxeYmu?usp=sharing) that more concisely reproduces this issue.
  