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

【Hackathon 6th No.9】Add cartesian_prod API to Paddle #833

Closed
wants to merge 2 commits into from

Conversation

Patrick-Star125
Copy link
Contributor

@Patrick-Star125 Patrick-Star125 commented Mar 21, 2024

新增 cartesian_prod API 设计文档,和 PaddlePaddle/Paddle#62939 同步修改

Copy link

paddle-bot bot commented Mar 21, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请检查PR提交格式和内容是否完备,具体请参考示例模版
Your PR has been submitted. Thanks for your contribution!
Please check its format and content. For this, you can refer to Template and Demo.

@luotao1
Copy link
Collaborator

luotao1 commented Mar 25, 2024

新增 Combinations API 设计文档,和 PaddlePaddle/Paddle#62939 同步修改

PR描述部分有误,达到可以review的状态请及时告知

@Patrick-Star125
Copy link
Contributor Author

已修改


## 1、相关背景

计算给定Tensor的长度为r的组合
Copy link
Collaborator

Choose a reason for hiding this comment

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

背景这句不太容易理解,r代表什么?


目前paddle缺少相关功能实现。

# 三、业内方案调研
Copy link
Collaborator

Choose a reason for hiding this comment

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

需要再补充下其他业内方案,如没有,也需要明确说明


## 命名与参数设计

API设计为`paddle.cartesian_prod(*tensors, name)`
Copy link
Collaborator

Choose a reason for hiding this comment

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

API的参数,*tensors->*args?
类似paddle.meshgrid(*args, **kargs)

Copy link
Collaborator

Choose a reason for hiding this comment

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

API设计为paddle.cartesian_prod(*tensors, name)

@Patrick-Star125 经过讨论:API设计为paddle.cartesian_prod(x, name),类似 paddle.stack
https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/stack_cn.html#stack
即输入 x 是多个 Tensor,打包成一个list或者tuple传进去

参数
:::::::::

- tensors (Tensor|list(Tensor)) - 输入的一个至多个 1-D Tensor,`x` 的数据类型可以是 float32,float64,int32,int64
Copy link
Collaborator

Choose a reason for hiding this comment

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

数据类型可以是 float32,float64,int32,int64

其他数据类型能否支持?默认都要支持 fp16/bf16/complex64/complex128
如果是组合API不支持的,需要增强API的功能,如增强paddle.meshgrid的数据类型

Copy link
Contributor Author

Choose a reason for hiding this comment

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

四种数据类型都需要支持吗,这样的话 meshgridflattenstack 的支持类型都需要扩充

return paddle.stack(grids, axis=1)
~~~

因为 paddle.flatten 并不支持当shape中有0存在的情况,因此对该情况做特殊处理
Copy link
Collaborator

Choose a reason for hiding this comment

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

torch.flatten是否支持当shape中有0存在的情况?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

支持,是否需要扩展 paddle.flatten 在该场景下的功能

Copy link
Collaborator

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

  1. fp16/bf16/complex64/complex128四种数据类型都需要,可以扩充meshgridflattenstack 的支持类型
  2. 需要扩展 paddle.flatten 在支持shape中有0存在的功能。
  3. 可以分别提单独的PR来解决上述问题。如果遇到比较大的难度,可以再进行沟通或调整星级🌟。

@luotao1
Copy link
Collaborator

luotao1 commented Jun 4, 2024

close due to the following PR is merged:

@luotao1 luotao1 closed this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants