Skip to content
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 elementwise max/min conversation and test case #92

Merged
merged 5 commits into from
Sep 16, 2022

Conversation

doombeaker
Copy link
Contributor

No description provided.

@@ -211,6 +211,8 @@ def _MakeMinOrMaxOp(ctx, op_type, inputs, outputs, output_shapes=None, output_dt

@flow_op("broadcast_minimum", onnx_op="Min")
@flow_op("broadcast_maximum", onnx_op="Max")
@flow_op("elementwise_minimum", onnx_op="Min")
@flow_op("elementwise_maximum", onnx_op="Max")
class MinMaxOp:
@classmethod
def Version_1(cls, ctx, node, **kwargs):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里我有个疑问,我看 https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Min-1 提到 Version 1 的 Min,是不支持 broadcast 的,所以在下面 _MakeMinOrMaxOp 里做了一些处理。

然而后面较高版本的 onnx op (比如 12 https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Min-12)又支持 broadcast 了。

不过自定义的 trick 好像又够用了,这个是不是暂时就不用添加更高版本的映射了?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的

@@ -34,6 +34,7 @@ def forward(self, x: flow.Tensor) -> flow.Tensor:
y3 = flow.acos(y3)
y3 = flow.pow(y3, 2.0)
y2 = y2 + y3
flow.minimum(y2, y3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpu那里的测试也对应加一下吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@doombeaker doombeaker requested review from oneflow-ci-bot and removed request for oneflow-ci-bot September 16, 2022 07:49
@doombeaker doombeaker merged commit b26216b into main Sep 16, 2022
@doombeaker doombeaker deleted the support_op_elementwise_minimum branch September 16, 2022 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants