You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When mapping python loops to ONNX Loop, we need some strategy for typing (the shape, really) the loop-condition variable.
One option is that all code uses a scalar (0D tensor) for the loop-condition, and this works fine.
But occasionally we run into situations where a 1D tensor with a single value is used. Currently, ONNX seems to permit this. If we want to allow this in ONNX Script:
If we type the loop-body-subgraph to expect a 0D value as "condition", the ONNX checker will fail if and when the actual condition is a 1D tensor
If we leave the loop-body-subgraph condition as a "boolean" without any shape, in some cases at least the ONNX checker fails (complaining about unknown rank).
If we want to handle both reasonably, we will likely need to integrate shape-inference info into the onnxscript translator so that it can do different things based on the inferred type.
One simpler short-cut would be for onnxscript to emit a Reshape/Squeeze for the loop-condition to convert it into a 0D tensor. But ideally, we should not emit this when it is unnecessary. Else, we end up with redundant ops (though a downstream optimizer could potentially remove it).
The text was updated successfully, but these errors were encountered:
When mapping python loops to ONNX Loop, we need some strategy for typing (the shape, really) the loop-condition variable.
But occasionally we run into situations where a 1D tensor with a single value is used. Currently, ONNX seems to permit this. If we want to allow this in ONNX Script:
The text was updated successfully, but these errors were encountered: