onnx / tutorials

Tutorials for creating and using ONNX models
Apache License 2.0
3.34k stars 626 forks source link

Add Batch processing with SequenceMap tutorial #265

Closed jantonguirao closed 2 years ago

jantonguirao commented 2 years ago

Adding a tutorial showing how to use the SequenceMap operator to perform batch processing operations.

Signed-off-by: Joaquin Anton janton@nvidia.com

jantonguirao commented 2 years ago

@jcwchen The SequenceMap operator has been merged. I think this example is ready for review.

jantonguirao commented 2 years ago

Thanks for the quick update after your ONNX PR. May I ask you: are you fine if we forward this PR at least after official ONNXRuntime supports new ONNX operator SequenceMap? It can prevent some confusion if users would like to try it out with current ONNX and ORT. (If we directly publish this document, they will now see couple of warnings.)

IIUC, next release for ONNX will be in May and ORT will be in June.

Sure, that seems reasonable

jcwchen commented 2 years ago

Thanks for waiting. Now ONNX 1.12 has been released -- before merging it, @jantonguirao please let me know if you would like to add something else. Otherwise, I will forward this PR. Thank you

jantonguirao commented 2 years ago

Thanks for waiting. Now ONNX 1.12 has been released -- before merging it, @jantonguirao please let me know if you would like to add something else. Otherwise, I will forward this PR. Thank you

I don't have anything to add. We should probably just rerun the notebook. I have a question: shouldn't we wait until onnxruntime supports opset 17, or it is enough if it's there in ONNX?

jcwchen commented 2 years ago

Good point. Let's wait for ORT 1.12.0 then (which is also coming soon). Thanks!

jcwchen commented 2 years ago

ORT 1.12.0 has been released. @jantonguirao Shall we revive this work by updating the notebook with the latest onnx and onnxruntime? Thanks!

jantonguirao commented 2 years ago

@jcwchen I have tested with ORT 1.12.1 and unfortunately, it doesn't seem to work. I am getting errors like:

InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : This is an invalid model. In Node, ("", Loop, "", -1) : ("_0x39b8f70_SequenceMap_input_sequence_seqlen": tensor(int64),"_0x39b8f70_SequenceMap_input_sequence_cond": tensor(bool),"_0x39b8f70_SequenceMap_out_sequence_0_seqempty": seq(tensor(uint8)),) -> ("batch_processed": seq(tensor(uint8)),) , Error Nodes in a graph must be topologically sorted, however input '_0x39b8f70_target_size' of node: 
name:  OpType: Cast
 is not output of any previous nodes.

I'll prepare a self-contained reproduction script and file a bug.

jantonguirao commented 2 years ago

https://github.com/microsoft/onnxruntime/issues/12491 @jcwchen FYI

jantonguirao commented 2 years ago

@jcwchen The issue I mentioned above is fixed with https://github.com/microsoft/onnxruntime/pull/12758 I've updated the notebook. When this PR gets merged I think we can review and merge this notebook. Thank you.