Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
60ffc220
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
60ffc220
编写于
9月 01, 2020
作者:
L
Leo Chen
提交者:
GitHub
9月 01, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine bernoulli and unsqueeze op (#26842)
* add check for bernoulli and register bool for unsqueeze * follow comments
上级
1127d0d3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
6 deletion
+22
-6
paddle/fluid/operators/bernoulli_op.cu
paddle/fluid/operators/bernoulli_op.cu
+4
-0
paddle/fluid/operators/bernoulli_op.h
paddle/fluid/operators/bernoulli_op.h
+6
-4
paddle/fluid/operators/unsqueeze_op.cc
paddle/fluid/operators/unsqueeze_op.cc
+6
-0
paddle/fluid/operators/unsqueeze_op.cu.cc
paddle/fluid/operators/unsqueeze_op.cu.cc
+4
-0
python/paddle/tensor/manipulation.py
python/paddle/tensor/manipulation.py
+2
-2
未找到文件。
paddle/fluid/operators/bernoulli_op.cu
浏览文件 @
60ffc220
...
...
@@ -31,6 +31,10 @@ struct BernoulliCudaFunctor {
__host__
__device__
BernoulliCudaFunctor
(
int
seed
)
:
seed_
(
seed
)
{}
__host__
__device__
T
operator
()(
const
unsigned
int
n
,
const
T
p
)
const
{
// NOTE(zhiqiu): currently, PADDLE_ENFORCE in cuda kernel may print several
// lines of error messages if, and it should be refined.
PADDLE_ENFORCE
(
p
>=
0.0
&&
p
<=
1.0
,
"The probability should be >=0 and <= 1, but got %f"
,
p
);
thrust
::
minstd_rand
rng
;
rng
.
seed
(
seed_
);
thrust
::
uniform_real_distribution
<
T
>
dist
(
0.0
,
1.0
);
...
...
paddle/fluid/operators/bernoulli_op.h
浏览文件 @
60ffc220
...
...
@@ -25,10 +25,12 @@ namespace operators {
template
<
typename
T
>
inline
HOSTDEVICE
T
BernoulliFunctor
(
T
p
,
T
rand
)
{
PADDLE_ENFORCE_LE
(
p
,
1
,
platform
::
errors
::
OutOfRange
(
"The probability should be <= 1, but got %f"
,
p
));
PADDLE_ENFORCE_GE
(
p
,
0
,
platform
::
errors
::
OutOfRange
(
"The probability should be >= 1, but got %f"
,
p
));
PADDLE_ENFORCE_LE
(
p
,
1.0
,
platform
::
errors
::
OutOfRange
(
"The probability should be <= 1, but got %f"
,
p
));
PADDLE_ENFORCE_GE
(
p
,
0.0
,
platform
::
errors
::
OutOfRange
(
"The probability should be >= 0, but got %f"
,
p
));
return
static_cast
<
T
>
(
rand
<
p
);
}
...
...
paddle/fluid/operators/unsqueeze_op.cc
浏览文件 @
60ffc220
...
...
@@ -13,9 +13,11 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/unsqueeze_op.h"
#include <memory>
#include <string>
#include <vector>
#include "paddle/fluid/framework/op_registry.h"
namespace
paddle
{
...
...
@@ -327,6 +329,7 @@ REGISTER_OPERATOR(unsqueeze2_grad, ops::Unsqueeze2GradOp,
REGISTER_OP_CPU_KERNEL
(
unsqueeze
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int8_t
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
);
...
...
@@ -334,12 +337,14 @@ REGISTER_OP_CPU_KERNEL(
unsqueeze_grad
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int8_t
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
);
REGISTER_OP_CPU_KERNEL
(
unsqueeze2
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int8_t
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
);
...
...
@@ -347,6 +352,7 @@ REGISTER_OP_CPU_KERNEL(
unsqueeze2_grad
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int8_t
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
);
paddle/fluid/operators/unsqueeze_op.cu.cc
浏览文件 @
60ffc220
...
...
@@ -21,6 +21,7 @@ REGISTER_OP_CUDA_KERNEL(
unsqueeze
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
double
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
plat
::
float16
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
bool
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int8_t
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int64_t
>
);
...
...
@@ -30,6 +31,7 @@ REGISTER_OP_CUDA_KERNEL(
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
double
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
plat
::
float16
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
bool
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int8_t
>
,
ops
::
UnsqueezeGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int64_t
>
);
...
...
@@ -38,6 +40,7 @@ REGISTER_OP_CUDA_KERNEL(
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
double
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
plat
::
float16
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
bool
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int8_t
>
,
ops
::
UnsqueezeKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int64_t
>
);
...
...
@@ -47,6 +50,7 @@ REGISTER_OP_CUDA_KERNEL(
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
double
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
plat
::
float16
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
bool
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int8_t
>
,
ops
::
Unsqueeze2GradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int64_t
>
);
python/paddle/tensor/manipulation.py
浏览文件 @
60ffc220
...
...
@@ -433,8 +433,8 @@ def stack(x, axis=0, name=None):
[5.0, 6.0] ] ]
Args:
x (Tensor|list[Tensor]
): Input ``x`` can be a single tensor, or a ``list
`` of tensors.
If ``x`` is a ``list``, the Tensors in ``x``
x (Tensor|list[Tensor]
|tuple[Tensor]): Input ``x`` can be a single tensor, or a ``list`` or ``tuple
`` of tensors.
If ``x`` is a ``list``
or ``tuple``
, the Tensors in ``x``
must be of the same shape and dtype. Supported data types: float32, float64, int32, int64.
axis (int, optional): The axis along which all inputs are stacked. ``axis`` range is ``[-(R+1), R+1)``,
where ``R`` is the number of dimensions of the first input tensor ``x[0]``.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录