microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.78k stars 2.94k forks source link

[SymbolicShapeInference] Support 10 Reduce* ops #22722

Open yf711 opened 2 weeks ago

yf711 commented 2 weeks ago

Description

Extend existing Reduce_Sum func to all 10 Reduce-series ops i.e ReduceMean def: https://onnx.ai/onnx/operators/onnx__ReduceMean.html

Op Defintions (bold: diff)
ReduceL1 Computes the L1 norm of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.
ReduceL2 Computes the L2 norm of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.
ReduceLogSum Computes the log sum of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.
ReduceLogSumExp Computes the log sum exponent of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.
ReduceMax Computes the max of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or the minimum value of the data type otherwise. If the input data type is Boolean, the comparison should consider False < True.
ReduceMean Computes the mean of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields undefined.
ReduceMin Computes the min of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields plus infinity (if supported by the datatype) or the maximum value of the data type otherwise. If the input data type is Boolean, the comparison should consider False < True.
ReduceProd Computes the product of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 1.
ReduceSum Computes the sum of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.
ReduceSumSquare Computes the sum square of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. Input tensors of rank zero are valid. Reduction over an empty set of values yields 0.

Motivation and Context

https://github.com/microsoft/onnxruntime/issues/22662 This ReduceMean op is not supported by current script

tianleiwu commented 3 days ago

LGTM. Please use "lintrunner -a" to format the script.