-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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.18】Add Binomial kernel for Hackthon No. 18 -part #59690
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
这个test总是超时,请问可以上调一下test的时间吗 |
可以的,你先上调下test时间看下。这个test大概需要多少时间? |
PR-CI-Coverage里面看是15点多秒,超了一点 |
是在 CMakeLists.txt 里加时间吗,不太会这个,有没有参考 |
那TIMEOUT放到30估计就够了,120太多了。可以等 @cxxly 其他意见一起修改
|
好的,谢谢 |
python/paddle/tensor/random.py
Outdated
@@ -102,6 +102,74 @@ def bernoulli(x, name=None): | |||
return out | |||
|
|||
|
|||
def binomial(total_count, prob, name=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上,签名和torch保持一致
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
paddle/phi/api/yaml/ops.yaml
Outdated
@@ -323,6 +323,14 @@ | |||
func: bincount | |||
optional: weights | |||
|
|||
- op : binomial | |||
args : (Tensor total_count, Tensor prob) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
签名和torch一致,看了下第一个参数应该是count
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
const MetaTensor& prob, | ||
MetaTensor* out, | ||
MetaConfig config = MetaConfig()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上,签名统一修改下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
|
||
def verify_output(self, outs): | ||
hist, prob = output_hist(np.array(outs[0]), self.n, self.p, a=5, b=15) | ||
np.testing.assert_allclose(hist, prob, rtol=0, atol=0.01) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注明阈值设置参考标准
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已注释,参照 test_bernoulli_op,test_poisson_op 和 test_multinomial_op
test/legacy_test/test_binomial_op.py
Outdated
if not paddle.is_compiled_with_cuda(): | ||
return | ||
|
||
print("Test Fixed Random number on GPU------>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除print
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除
binomial设计与实现麻烦也补充到rfc,rfc与代码实现需要保持一致 |
paddle/phi/kernels/binomial_kernel.h
Outdated
@@ -0,0 +1,37 @@ | |||
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2022 -> 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
@@ -0,0 +1,42 @@ | |||
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
} // namespace phi | ||
|
||
PD_REGISTER_KERNEL( | ||
binomial, CPU, ALL_LAYOUT, phi::BinomialKernel, float, double) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改,参照 multinomial 的
@@ -0,0 +1,134 @@ | |||
/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2022 -> 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
@@ -0,0 +1,199 @@ | |||
/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2022 -> 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
test/legacy_test/test_binomial_op.py
Outdated
@@ -0,0 +1,272 @@ | |||
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2018 -> 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
好的,谢谢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,just 有一点疑问
>>> p = paddle.to_tensor([0.2, 0.6]) | ||
>>> out = paddle.binomial(n, p) | ||
>>> print(out) | ||
>>> # doctest: +SKIP("Random output") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加 seed 也不能固定输出吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
啊,这里应该是固定的,文档抄过来没去掉 SKIP
需要去掉一下吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NKNaN 你再提一个PR改吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
PR types
Others
PR changes
OPs
Description
Add Binomial kernel for Hackthon No. 18: pr #57856