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.10】Add isin API to Paddle -part #64001

Merged
merged 9 commits into from
Jun 3, 2024

Conversation

NKNaN
Copy link
Contributor

@NKNaN NKNaN commented Apr 30, 2024

PR Category

User Experience

PR Types

New features

Description

rfcs: PaddlePaddle/community#884

Copy link

paddle-bot bot commented Apr 30, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Apr 30, 2024
@luotao1 luotao1 self-assigned this May 7, 2024
@luotao1 luotao1 added the API label May 7, 2024
>>> print(res)
Tensor(shape=[5], dtype=bool, place=Place(cpu), stop_gradient=True,
[True, False, False, True, False])
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

参考 pytorch 在 _decompose 中的设计:当 test_elements 元素个数较少时直接进行暴力搜索,较多时则采取基于排序的算法:若 assume_unique=True,则用稳定排序的 argsort 进行实现;若 assume_unique=False,则用 searchsorted 进行实现。

示例代码中,能否体现出 assume_unique=True/False 的区别?注释中是否要加入这段说明

Copy link
Contributor Author

Choose a reason for hiding this comment

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

增加了一个 assume_unique 设置错误导致结果出错的例子;
在下面代码中加了不同分支对应不同做法的注释

luotao1
luotao1 previously approved these changes May 13, 2024
@@ -7871,3 +7871,176 @@ def isreal(x, name=None):
return paddle.ones_like(x, dtype='bool')

return paddle.equal(paddle.imag(x), 0)


def isin(elements, test_elements, assume_unique=False, invert=False, name=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Accroding to API design guidelines standard, use x instead of elements and test_x instead of test_elements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

revised.

'float32',
'float64',
'int32',
'int64',
Copy link
Contributor

Choose a reason for hiding this comment

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

should we support bfloat16 and float16?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Temporarily not since paddle.searchsorted only support 'float32', 'float64', 'int32' and 'int64'.

'float32',
'float64',
'int32',
'int64',
Copy link
Contributor

Choose a reason for hiding this comment

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

same date type issue as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Temporarily not since paddle.searchsorted only support 'float32', 'float64', 'int32' and 'int64'.

@NKNaN
Copy link
Contributor Author

NKNaN commented May 14, 2024

@jeff41404 paddle.searchsorted currently does not support fp16 and bf16. I think the reason may be that the two input tensors' data type of paddle.searchsorted could be different, and since fp16 and bf16 has lower precision than float32 and float64, the comparision between them may be less meaningful.

@jeff41404
Copy link
Contributor

jeff41404 commented May 15, 2024

@jeff41404 paddle.searchsorted currently does not support fp16 and bf16. I think the reason may be that the two input tensors' data type of paddle.searchsorted could be different, and since fp16 and bf16 has lower precision than float32 and float64, the comparision between them may be less meaningful.

the logic of searchsorted also supports comparing two inputs with different data types. Registering the fp16 and bf16 data types in the Operator should support these two data types. searchsorted operator was developed many years ago, when fp16 and bf16 were not yet widely used, and it was not intentionally unsupported due to accuracy or lower precision.

@NKNaN
Copy link
Contributor Author

NKNaN commented May 15, 2024

the logic of searchsorted also supports comparing two inputs with different data types. Registering the fp16 and bf16 data types in the Operator should support these two data types. searchsorted operator was developed many years ago, when fp16 and bf16 were not yet widely used, and it was not intentionally unsupported due to accuracy or lower precision.

Got it. Let me update the searchsorted to support fp16 and bf16 first.

Copy link

paddle-ci-bot bot commented May 21, 2024

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

Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@sunzhongkai588 sunzhongkai588 left a comment

Choose a reason for hiding this comment

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

LGTM for docs

@luotao1 luotao1 merged commit a9c29da into PaddlePaddle:develop Jun 3, 2024
32 checks passed
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.

4 participants