Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
0c82e3a0
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0c82e3a0
编写于
11月 30, 2021
作者:
Y
Yang
提交者:
GitHub
11月 30, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix overflow in some cuda ops (#37670)
上级
b0dff05d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
17 addition
and
17 deletion
+17
-17
paddle/fluid/operators/bernoulli_op.cu
paddle/fluid/operators/bernoulli_op.cu
+4
-4
paddle/fluid/operators/gaussian_random_op.cu
paddle/fluid/operators/gaussian_random_op.cu
+4
-4
paddle/fluid/operators/gumbel_softmax_op.cu
paddle/fluid/operators/gumbel_softmax_op.cu
+2
-2
paddle/fluid/operators/multinomial_op.cu
paddle/fluid/operators/multinomial_op.cu
+1
-1
paddle/fluid/operators/truncated_gaussian_random_op.cu
paddle/fluid/operators/truncated_gaussian_random_op.cu
+2
-2
paddle/fluid/operators/uniform_random_inplace_op.cu
paddle/fluid/operators/uniform_random_inplace_op.cu
+2
-2
paddle/fluid/operators/uniform_random_op.cu
paddle/fluid/operators/uniform_random_op.cu
+2
-2
未找到文件。
paddle/fluid/operators/bernoulli_op.cu
浏览文件 @
0c82e3a0
...
...
@@ -61,16 +61,16 @@ class BernoulliOpKernel<platform::CUDADeviceContext, T>
BOOST_GET_CONST
(
platform
::
CUDAPlace
,
ctx
.
GetPlace
()).
GetDeviceId
();
auto
gen_cuda
=
framework
::
GetDefaultCUDAGenerator
(
device_id
);
auto
seed_offset
=
gen_cuda
->
IncrementOffset
(
1
);
int
gen_offset
=
size
*
seed_offset
.
second
;
int
64_t
gen_offset
=
size
*
seed_offset
.
second
;
platform
::
Transform
<
platform
::
CUDADeviceContext
>
trans
;
thrust
::
counting_iterator
<
unsigned
in
t
>
index_sequence_begin
(
0
);
thrust
::
counting_iterator
<
int64_
t
>
index_sequence_begin
(
0
);
auto
*
context
=
static_cast
<
const
platform
::
CUDADeviceContext
*>
(
&
ctx
.
device_context
());
trans
(
*
context
,
index_sequence_begin
,
index_sequence_begin
+
size
,
in_data
,
out_data
,
BernoulliCudaFunctor
<
T
>
(
static_cast
<
unsigned
in
t
>
(
seed_offset
.
first
),
static_cast
<
unsigned
in
t
>
(
gen_offset
)));
BernoulliCudaFunctor
<
T
>
(
static_cast
<
int64_
t
>
(
seed_offset
.
first
),
static_cast
<
int64_
t
>
(
gen_offset
)));
}
};
...
...
paddle/fluid/operators/gaussian_random_op.cu
浏览文件 @
0c82e3a0
...
...
@@ -59,7 +59,7 @@ class GPUGaussianRandomKernel : public framework::OpKernel<T> {
}
T
mean
=
static_cast
<
T
>
(
context
.
Attr
<
float
>
(
"mean"
));
T
std
=
static_cast
<
T
>
(
context
.
Attr
<
float
>
(
"std"
));
thrust
::
counting_iterator
<
unsigned
in
t
>
index_sequence_begin
(
0
);
thrust
::
counting_iterator
<
int64_
t
>
index_sequence_begin
(
0
);
auto
shape
=
GetShape
(
context
);
tensor
->
Resize
(
shape
);
T
*
data
=
tensor
->
mutable_data
<
T
>
(
context
.
GetPlace
());
...
...
@@ -72,7 +72,7 @@ class GPUGaussianRandomKernel : public framework::OpKernel<T> {
if
(
gen_cuda
->
GetIsInitPy
()
&&
seed_flag
)
{
auto
seed_offset
=
gen_cuda
->
IncrementOffset
(
1
);
int
gen_offset
=
size
*
seed_offset
.
second
;
int
64_t
gen_offset
=
size
*
seed_offset
.
second
;
thrust
::
transform
(
index_sequence_begin
,
index_sequence_begin
+
size
,
thrust
::
device_ptr
<
T
>
(
data
),
...
...
@@ -100,7 +100,7 @@ class GPUGaussianRandomBatchSizeLikeKernel : public framework::OpKernel<T> {
}
T
mean
=
static_cast
<
T
>
(
context
.
Attr
<
float
>
(
"mean"
));
T
std
=
static_cast
<
T
>
(
context
.
Attr
<
float
>
(
"std"
));
thrust
::
counting_iterator
<
unsigned
in
t
>
index_sequence_begin
(
0
);
thrust
::
counting_iterator
<
int64_
t
>
index_sequence_begin
(
0
);
int64_t
size
=
tensor
->
numel
();
int
device_id
=
...
...
@@ -109,7 +109,7 @@ class GPUGaussianRandomBatchSizeLikeKernel : public framework::OpKernel<T> {
if
(
gen_cuda
->
GetIsInitPy
()
&&
seed_flag
)
{
auto
seed_offset
=
gen_cuda
->
IncrementOffset
(
1
);
int
gen_offset
=
size
*
seed_offset
.
second
;
int
64_t
gen_offset
=
size
*
seed_offset
.
second
;
thrust
::
transform
(
index_sequence_begin
,
index_sequence_begin
+
size
,
thrust
::
device_ptr
<
T
>
(
data
),
GaussianGenerator
<
T
>
(
mean
,
std
,
seed_offset
.
first
,
...
...
paddle/fluid/operators/gumbel_softmax_op.cu
浏览文件 @
0c82e3a0
...
...
@@ -129,7 +129,7 @@ struct GumbleNoiseGenerator<platform::CUDADeviceContext, T> {
int64_t
size
=
size_to_axis
*
size_from_axis
;
T
*
random_data
=
random_tensor
.
mutable_data
<
T
>
({
size
},
platform
::
CUDAPlace
());
thrust
::
counting_iterator
<
unsigned
in
t
>
index_sequence_begin
(
0
);
thrust
::
counting_iterator
<
int64_
t
>
index_sequence_begin
(
0
);
// generate gumbel noise
int
device_id
=
...
...
@@ -137,7 +137,7 @@ struct GumbleNoiseGenerator<platform::CUDADeviceContext, T> {
auto
gen_cuda
=
framework
::
GetDefaultCUDAGenerator
(
device_id
);
if
(
gen_cuda
->
GetIsInitPy
())
{
auto
seed_offset
=
gen_cuda
->
IncrementOffset
(
1
);
int
gen_offset
=
size
*
seed_offset
.
second
;
int
64_t
gen_offset
=
size
*
seed_offset
.
second
;
thrust
::
transform
(
index_sequence_begin
,
index_sequence_begin
+
size
,
thrust
::
device_ptr
<
T
>
(
random_data
),
...
...
paddle/fluid/operators/multinomial_op.cu
浏览文件 @
0c82e3a0
...
...
@@ -239,7 +239,7 @@ class MultinomialOpKernel<platform::CUDADeviceContext, T>
auto
*
rng_data
=
rng_data_tensor
.
mutable_data
<
T
>
(
{
num_distributions
,
num_samples
},
ctx
.
GetPlace
());
thrust
::
counting_iterator
<
unsigned
in
t
>
index_sequence_begin
(
0
);
thrust
::
counting_iterator
<
int64_
t
>
index_sequence_begin
(
0
);
platform
::
Transform
<
platform
::
CUDADeviceContext
>
trans
;
auto
*
context
=
static_cast
<
const
platform
::
CUDADeviceContext
*>
(
&
ctx
.
device_context
());
...
...
paddle/fluid/operators/truncated_gaussian_random_op.cu
浏览文件 @
0c82e3a0
...
...
@@ -97,7 +97,7 @@ class GPUTruncatedGaussianRandomKernel : public framework::OpKernel<T> {
}
T
mean
=
static_cast
<
T
>
(
context
.
Attr
<
float
>
(
"mean"
));
T
std
=
static_cast
<
T
>
(
context
.
Attr
<
float
>
(
"std"
));
thrust
::
counting_iterator
<
unsigned
in
t
>
index_sequence_begin
(
0
);
thrust
::
counting_iterator
<
int64_
t
>
index_sequence_begin
(
0
);
int64_t
size
=
tensor
->
numel
();
int
device_id
=
...
...
@@ -106,7 +106,7 @@ class GPUTruncatedGaussianRandomKernel : public framework::OpKernel<T> {
if
(
gen_cuda
->
GetIsInitPy
()
&&
seed_flag
)
{
auto
seed_offset
=
gen_cuda
->
IncrementOffset
(
1
);
int
gen_offset
=
size
*
seed_offset
.
second
;
int
64_t
gen_offset
=
size
*
seed_offset
.
second
;
thrust
::
transform
(
index_sequence_begin
,
index_sequence_begin
+
size
,
thrust
::
device_ptr
<
T
>
(
data
),
...
...
paddle/fluid/operators/uniform_random_inplace_op.cu
浏览文件 @
0c82e3a0
...
...
@@ -118,14 +118,14 @@ class GPUUniformRandomInplaceKernel : public framework::OpKernel<T> {
unsigned
int
diag_step
=
static_cast
<
unsigned
int
>
(
ctx
.
Attr
<
int
>
(
"diag_step"
));
T
diag_val
=
static_cast
<
T
>
(
ctx
.
Attr
<
float
>
(
"diag_val"
));
thrust
::
counting_iterator
<
unsigned
in
t
>
index_sequence_begin
(
0
);
thrust
::
counting_iterator
<
int64_
t
>
index_sequence_begin
(
0
);
int64_t
size
=
tensor
->
numel
();
int
device_id
=
BOOST_GET_CONST
(
platform
::
CUDAPlace
,
ctx
.
GetPlace
()).
GetDeviceId
();
auto
gen_cuda
=
framework
::
GetDefaultCUDAGenerator
(
device_id
);
if
(
gen_cuda
->
GetIsInitPy
()
&&
seed_flag
)
{
auto
seed_offset
=
gen_cuda
->
IncrementOffset
(
1
);
int
gen_offset
=
size
*
seed_offset
.
second
;
int
64_t
gen_offset
=
size
*
seed_offset
.
second
;
thrust
::
transform
(
index_sequence_begin
,
index_sequence_begin
+
size
,
thrust
::
device_ptr
<
T
>
(
data
),
...
...
paddle/fluid/operators/uniform_random_op.cu
浏览文件 @
0c82e3a0
...
...
@@ -139,14 +139,14 @@ class GPUUniformRandomKernel : public framework::OpKernel<T> {
unsigned
int
diag_step
=
static_cast
<
unsigned
int
>
(
context
.
Attr
<
int
>
(
"diag_step"
));
T
diag_val
=
static_cast
<
T
>
(
context
.
Attr
<
float
>
(
"diag_val"
));
thrust
::
counting_iterator
<
unsigned
in
t
>
index_sequence_begin
(
0
);
thrust
::
counting_iterator
<
int64_
t
>
index_sequence_begin
(
0
);
int64_t
size
=
tensor
->
numel
();
int
device_id
=
BOOST_GET_CONST
(
platform
::
CUDAPlace
,
context
.
GetPlace
()).
GetDeviceId
();
auto
gen_cuda
=
framework
::
GetDefaultCUDAGenerator
(
device_id
);
if
(
gen_cuda
->
GetIsInitPy
()
&&
seed_flag
)
{
auto
seed_offset
=
gen_cuda
->
IncrementOffset
(
1
);
int
gen_offset
=
size
*
seed_offset
.
second
;
int
64_t
gen_offset
=
size
*
seed_offset
.
second
;
thrust
::
transform
(
index_sequence_begin
,
index_sequence_begin
+
size
,
thrust
::
device_ptr
<
T
>
(
data
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录