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

[Prim] add meshgrid composite rule #51061

Merged
merged 13 commits into from
Mar 23, 2023

Conversation

rainyfly
Copy link
Contributor

@rainyfly rainyfly commented Mar 1, 2023

PR types

Others

PR changes

Ops

Describe

add composite op meshgrid

@paddle-bot
Copy link

paddle-bot bot commented Mar 1, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot
Copy link

paddle-bot bot commented Mar 1, 2023

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

"""
define composite rule of op meshgrid
If the input has N tensors of size S_0, ... S_n-1, then the output will also have N tensors, where
each tensor is of shape (S_0, ..., S_n-1)
Copy link
Contributor

Choose a reason for hiding this comment

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

explain diff of each tensor

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 , add an example to demonstrate it

@cyber-pioneer
Copy link
Contributor

image

make sure this code useful or add relative test case?

if dim == 0:
shape[i] = 1
else:
shape[i] = inputs[i].shape[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

may the logic be simplified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this op can support zero dim tensor, so we should consider 0 dim tensor as shape [1]

r2 is Tensor [[4,5], [4,5], [4,5]]
"""
size = len(inputs)
shape = [1 for i in range(size)]
Copy link
Contributor

Choose a reason for hiding this comment

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

[1] * size

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

shape = [1] * size
for i in range(size):
dim = inputs[i].dim()
assert dim == 0 or dim == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

这儿0-d相关的逻辑补充一下0-d的测试吧

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

@@ -28,6 +28,7 @@ def meshgrid_wrapper(x):
class TestMeshgridOp(OpTest):
def setUp(self):
self.op_type = "meshgrid"
self.prim_op_type = "comp"
self.python_api = meshgrid_wrapper
Copy link
Contributor

Choose a reason for hiding this comment

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

看一下python3流水线 新增一下public_python_api

@Charles-hit Charles-hit merged commit 53bb883 into PaddlePaddle:develop Mar 23, 2023
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.

3 participants