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 5th No.27】为 Paddle 新增 select_scatter API #664

Closed
wants to merge 2 commits into from

Conversation

wyq-carol
Copy link

为 Paddle 新增 select_scatter API

@paddle-bot
Copy link

paddle-bot bot commented Sep 27, 2023

你的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.

@CLAassistant
Copy link

CLAassistant commented Sep 27, 2023

CLA assistant check
All committers have signed the CLA.

* `x (Tensor)` 表示给定张量,支持数据类型 `bool`,`float16`,`float32`,`float64`,`int32`,`int64`
* `src (Tensor)` 表示被填充等价于 `value` 的张量,支持与 `x` 相同的数据类型(可以实现 `int` 向 `float` 的转化以及 `float` 之间的转化)
* `dim (int)` 表示指定轴
* `index (int)` 表示索引位置
Copy link
Contributor

Choose a reason for hiding this comment

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

再对照下命名规范呢,dim -> axis , src -> value等等。此外x支持的数据类型可以再根据依赖的api支持的数据类型验证一下,官网文档给的支持范围可能有点滞后了。

# 将dim的切片替换为index,用于在特定维度上定位元素
indices[dim] = index
# 使用tuple(indices)构造索引元组,将指定维度上的元素设置为value
x[tuple(indices)] = value
Copy link
Contributor

Choose a reason for hiding this comment

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

这个地方,最好不要直接调用方括号索引(setitem),首先会有一个额外的解析过程,其次setitem会原地修改x的值,不能达到非inplace的效果,建议通过调用set_value OP实现。

# 六、测试和验收的考量

基础测试:
- 计算输出数值结果的一致性和数据类型是否正确,使用 pytorch 作为参考标准
Copy link
Contributor

Choose a reason for hiding this comment

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

这里“参考标准”因为需要实际在单测中比较,目前单测中一般使用numpy进行,如果numpy没有提供直接对应的API,需要自行实现一个替代的函数用于单测对比。

@luotao1
Copy link
Collaborator

luotao1 commented Nov 30, 2023

已经有 RFC 合入了,如果需要更新和完善,可以在原来的 RFC 上进行修改,感谢!

@luotao1 luotao1 closed this Nov 30, 2023
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.

5 participants