Last active
September 21, 2021 23:02
-
-
Save cdw/2fca134ef8a78cd82ff8e2673fce14dc to your computer and use it in GitHub Desktop.
ONNX Conversion for SQuAD example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
torch.onnx.export(model = torch_model, | |
args = (dummy_input['input_ids'].to(device), dummy_input['attention_mask'].to(device)), #Tuple of inputs for models that take more than one input | |
f = onnx_path, | |
export_params = True, | |
opset_version=11, | |
do_constant_folding = True, | |
input_names = ['input_ids', 'attention_mask'], | |
output_names = ['output'], | |
dynamic_axes = {'input_ids': {0: 'batch_size'}, | |
'attention_mask': {0: 'batch_size'}, | |
'output': {0: 'batch_size'}} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment