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

[PHI] Support code auto-gene for Sparse backward C++ API #40196

Merged
merged 1 commit into from
Mar 8, 2022

Conversation

zyfncg
Copy link
Contributor

@zyfncg zyfncg commented Mar 6, 2022

PR types

New features

PR changes

APIs

Describe

Sparse backward API支持通过Yaml配置完成接口代码的自动生成。Sparse 前向API可参考#PR40060

以sparse_conv3d_grad为例,其yaml配置格式如下:

- sparse_bw_api : conv3d_grad
  forward : conv3d (Tensor x, Tensor kernel, int[] paddings, int[] dilations, int[] strides, int groups) -> Tensor(out@SparseCooTensor), Tensor(rulebook@DenseTensor)
  args : (Tensor x, Tensor kernel, Tensor rulebook, Tensor out_grad, int[] paddings, int[] dilations, int[] strides, int groups)
  output : Tensor(x_grad@DenseTensor), Tensor(kernel_grad@DenseTensor)
  kernel :
    func : sparse_conv_grad

配置规则与普通反向API基本相同,区别在于:

  1. 无需配置infer_meta项
  2. output项中的变量名需使用 "@xxx" 的后缀标记返回Tensor的具体数据类型

@paddle-bot-old
Copy link

paddle-bot-old bot commented Mar 6, 2022

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@zyfncg zyfncg merged commit f876320 into PaddlePaddle:develop Mar 8, 2022
@zyfncg zyfncg deleted the sparse_bw_api branch March 8, 2022 03:15
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