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 7th No.41】NO.41 为 Paddle 代码转换工具新增 API 转换规则(第 8 组) #6887

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

Conversation

decade-afk
Copy link

No description provided.

@CLAassistant
Copy link

CLAassistant commented Sep 22, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@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.

第8组只有这一个API吗

@decade-afk
Copy link
Author

第8组只有这一个API吗
并不是,其他的还在弄

@zhwesky2010
Copy link
Collaborator

zhwesky2010 commented Sep 24, 2024

第8组只有这一个API吗
并不是,其他的还在弄

那你在PR描述里,先标注一个 -PART1

@zhwesky2010 zhwesky2010 changed the title 【Hackathon 7th No.41】NO.41 为 Paddle 代码转换工具新增 API 转换规则(第 8 组) 【Hackathon 7th No.41】NO.41 为 Paddle 代码转换工具新增 API 转换规则(第 8 组)PRAT1 Sep 24, 2024
@@ -0,0 +1,7 @@
## [功能缺失 ]torch.distributions.constraints.Constraint
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个不是功能缺失,仔细查阅paddle源码,以源代码为准

@@ -0,0 +1,7 @@
## [ 功能缺失 ]torch.distributions.transforms.PositiveDefiniteTransform
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个找办法组合实现

infoflow 2024-09-24 17-17-53

判定为功能缺失需要慎重,只有确实需要在Paddle中新增API的才可判定功能缺失,尽可能要通过组合实现、或者paconvert的辅助函数aux_code实现

Copy link
Author

Choose a reason for hiding this comment

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

好的好的,目前正在修改

Copy link
Author

Choose a reason for hiding this comment

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

已经全都弄好了,请review

@decade-afk decade-afk changed the title 【Hackathon 7th No.41】NO.41 为 Paddle 代码转换工具新增 API 转换规则(第 8 组)PRAT1 【Hackathon 7th No.41】NO.41 为 Paddle 代码转换工具新增 API 转换规则(第 8 组) Sep 26, 2024
| --------- | ------------ | ------------------------------------------------------------------------------------ |
| median | loc | 输入 Tensor,仅参数名不一致。 |
| sigma | scale | 输入 Tensor,仅参数名不一致。 |
| * | - | 其他参数 |
Copy link
Collaborator

@zhwesky2010 zhwesky2010 Sep 27, 2024

Choose a reason for hiding this comment

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

* 表示后面为指定关键字参数,不代表某个形参。这个去学习下相关的python语法。

| ------- | ------------ | ----------------------------- |
| p | probs | 输入 Tensor,仅参数名不一致。 |

| * | - | 其他参数 |
Copy link
Collaborator

@zhwesky2010 zhwesky2010 Sep 27, 2024

Choose a reason for hiding this comment

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

同上,先查阅python相关语法

### [paddle.Tensor._is_inference](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html)

```python
paddle.Tensor._is_inference
Copy link
Collaborator

Choose a reason for hiding this comment

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

infoflow 2024-09-27 16-09-55

有这个API??

Copy link
Author

Choose a reason for hiding this comment

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

抱歉,这个是我搞错了,他是CompiledProgram类的属性


PaddlePaddle 目前无对应 API,可使用如下代码组合实现该 API。

### 参数映射
Copy link
Collaborator

Choose a reason for hiding this comment

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

组合实现有参数映射吗??认真查阅模板

| dim | dim | 表示输入的参数。 |
| concentration | concentration | 表示输入的参数。 |
| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 |
| - | sample_method | pytorch无此参数,保持默认即可。 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

paddle保持默认即可

Copy link
Collaborator

@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.

开发注意事项:

  1. 务必按照 映射文档模板 编写,一比一对照编写(可适当补充内容但不能减少内容),提交review前先自查一遍
  2. 本次放出来的API,内部已初步分析过,基本上都有相关功能,功能缺失的可能性较小。需尽可能去寻找组合替代实现,判定为功能缺失要慎重,除非paddle完全无相类似功能
  3. 先写好映射文档,再根据合入的文档来实现Matcher,注意不要出现文档与Matcher的diff。如果后面实现Matcher时,发现文档有误,需及时返工更正文档

@@ -0,0 +1,15 @@
## [ 无参数 ]torch.Tensor.is_inference
Copy link
Collaborator

Choose a reason for hiding this comment

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

加一个 torch.is_inference.md 的文档吧,这两个API是一样的

有个问题:这个看起来和stop_gradient不是完全一致的,如果没有更好的替代实现,就在文档里注明是近似实现吧,至少让读者知道存在差异
https://www.cnblogs.com/ToryRegulus/p/18141257

@@ -0,0 +1,22 @@
## [ 仅参数名不一致 ]torch.Tensor.geometric_
Copy link
Collaborator

Choose a reason for hiding this comment

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

torch参数更多

x.random_(from=0, to=10)

# Paddle 写法
paddle.assign(paddle.cast(paddle.randint(low=0, high=2, shape=x.shape), dtype='float32'), x)
Copy link
Collaborator

Choose a reason for hiding this comment

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

paddle.Tensor.uniform_ 能否实现?

尽量找更好的组合

### [paddle.distributed.shard_optimizer](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/distributed/shard_optimizer_cn.html)

```python
paddle.distributed.shard_optimizer(optimizer, shard_fn=None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个和 paddle.distributed.fleet.distributed_optimizer 哪个更能对应上?

### [paddle.distributed.rpc.rpc_async](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/distributed/rpc/rpc_async_cn.html#rpc-async)

```python
paddle.distributed.rpc.rpc_async(to, fn, args=None, kwargs=None, timeout=- 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

timeout=-1)

paddle.distribution.constraint.Constraint()
```

功能一致,无参数。
Copy link
Collaborator

Choose a reason for hiding this comment

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

上面的torch签名是无参数??


PaddlePaddle 目前无对应 API,可使用如下代码组合实现该 API。

### 参数映射
Copy link
Collaborator

Choose a reason for hiding this comment

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

组合替代实现 不需要参数映射

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor PaddlePaddle Hackathon 飞桨黑客松活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants