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

【complex op No.4】support complex for bmm #64603

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

YibinLiu666
Copy link
Contributor

@YibinLiu666 YibinLiu666 commented May 26, 2024

PR Category

Others

PR Types

New features

Description

支持bmm的复数类型,bmm前向是直接调用的blas的gemm,因此前向可以直接增加类型即可。反向参考
Paddle/paddle/phi/kernels/impl/matmul_grad_kernel_impl.h
中的matmulgradkernel新增了复数类型。

Copy link

paddle-bot bot commented May 26, 2024

你的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 paddle-bot bot added the contributor External developers label May 26, 2024
@luotao1 luotao1 changed the title support complex for bmm 【complex op No.4】support complex for bmm Jun 3, 2024
Copy link

paddle-ci-bot bot commented Jun 3, 2024

Sorry to inform you that 84df26b's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

Comment on lines 162 to 209
class TestBmmOpCaseComplex64(TestBmmOp):
def setUp(self):
self.op_type = "bmm"
self.python_api = paddle.tensor.bmm
self.public_python_api = paddle.tensor.bmm
X = (
np.random.uniform(1, 5, (10, 3, 4))
+ 1j * np.random.uniform(1, 5, (10, 3, 4))
).astype("complex64")
Y = (
np.random.uniform(1, 5, (10, 4, 2))
+ 1j * np.random.uniform(1, 5, (10, 4, 2))
).astype("complex64")
self.inputs = {'X': X, 'Y': Y}
Out = np.matmul(X, Y)
self.outputs = {'Out': Out}

def test_check_output(self):
self.check_output(check_pir=True, check_prim=False)
# pass

def test_checkout_grad(self):
self.check_grad(['X', 'Y'], 'Out', check_pir=True, check_prim=False)


class TestBmmOpCaseComplex128(TestBmmOp):
def setUp(self):
self.op_type = "bmm"
self.python_api = paddle.tensor.bmm
self.public_python_api = paddle.tensor.bmm
X = (
np.random.uniform(1, 5, (10, 3, 4))
+ 1j * np.random.uniform(1, 5, (10, 3, 4))
).astype("complex128")
Y = (
np.random.uniform(1, 5, (10, 4, 2))
+ 1j * np.random.uniform(1, 5, (10, 4, 2))
).astype("complex128")
self.inputs = {'X': X, 'Y': Y}
Out = np.matmul(X, Y)
self.outputs = {'Out': Out}

def test_check_output(self):
self.check_output(check_pir=True, check_prim=False)
# pass

def test_checkout_grad(self):
self.check_grad(['X', 'Y'], 'Out', check_pir=True, check_prim=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

参考其他单测,补充一下self.dtype=np.complex64/np.complex218这个设置

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,但是本地仍然有较大的误差

Copy link

paddle-ci-bot bot commented Jun 20, 2024

Sorry to inform you that 6c1582f's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants