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

Determinant kernel support complex 易用性提升 #68390

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

NKNaN
Copy link
Contributor

@NKNaN NKNaN commented Sep 23, 2024

PR Category

User Experience

PR Types

Improvements

Description

Determinant kernel 支持complex64/complex128

  • 前向:由于 Eigen 库当矩阵数据类型是 std::complex 时在 windows 平台上编译 cuda kernel 会出现 std::complex 类型的 operators 重复定义的错误,所以将 complex 类型的 cuda kernel 实现改为用 cublas 库,先进行 LU 分解,然后求对角线元素的乘积。
  • 反向:原反向计算的公式依据是:https://people.maths.ox.ac.uk/gilesm/files/NA-08-01.pdf ,而该推导过程只适用于实数矩阵,对于复数矩阵需要修改的地方如下:
    image
    因此在最后需要对 out*inverse(A) 求共轭:(section 2.2.4)

$$ dC = C \cdot Tr(A^{-1} dA)$$

$$ \bar{C}^{H}dC = \bar{C}^{H}C \cdot Tr(A^{-1} dA) = Tr( \bar{C}^{H}C A^{-1} dA) $$

$$ dS_o = Tr(\bar{C}^H dC) = Tr( \bar{C}^{H}C A^{-1} dA)$$

$$ \bar{A} = \bar{C} \cdot (C A^{-1})^H $$

@paddle-bot paddle-bot bot added the contributor External developers label Sep 23, 2024
Copy link

paddle-ci-bot bot commented Oct 2, 2024

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

Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhwesky2010 zhwesky2010 merged commit 2d75c3a into PaddlePaddle:develop Oct 11, 2024
26 of 27 checks passed
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.

2 participants