-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ReduceMean shape infer to SymbolicShapeInference #22722
base: main
Are you sure you want to change the base?
Conversation
"ReduceSum": self._infer_ReduceSum, | ||
"ReduceMean": self._infer_ReduceMean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReduceSum
and ReduceMean
could use same shape infer function.
Also applies to ReduceMin
, ReduceMax
, ReduceProd
etc.
vi = self.known_vi_[node.output[0]] | ||
|
||
if axes is None: | ||
assert keep_dims == 1, "ReduceMean Op: Cannot infer shape when axes is unknown and keepdims is not 1." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opset 18 add an attribute noop_with_empty_axes
, shall we handle it here.
https://onnx.ai/onnx/operators/onnx__ReduceMean.html#reducemean-18
keep_dims = get_attribute(node, "keepdims", 1) | ||
opset = get_opset(self.out_mp_) | ||
|
||
if opset >= 13 and len(node.input) > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReduceMean-13 still uses attribute for axes. Maybe just check whether there is two inputs, and not check opset version so that it is more general for other Reduce* op. For example, starting with ReduceSum-13, ReduceMean-18, ReduceMax-18, axes is in input.
Description
Add symbolic shape inference support of ReduceMean op
ReduceMean def: https://onnx.ai/onnx/operators/onnx__ReduceMean.html
Motivation and Context
#22662
This op is not supported by current script