Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
f3c5e815
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f3c5e815
编写于
3月 15, 2018
作者:
K
Kexin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add fp16 for cast op
上级
4f3b73ed
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
3 deletion
+38
-3
paddle/fluid/operators/cast_op.cc
paddle/fluid/operators/cast_op.cc
+3
-1
paddle/fluid/operators/cast_op.cu
paddle/fluid/operators/cast_op.cu
+3
-1
python/paddle/fluid/tests/unittests/test_cast_op.py
python/paddle/fluid/tests/unittests/test_cast_op.py
+32
-1
未找到文件。
paddle/fluid/operators/cast_op.cc
浏览文件 @
f3c5e815
...
@@ -14,6 +14,7 @@ limitations under the License. */
...
@@ -14,6 +14,7 @@ limitations under the License. */
#include "paddle/fluid/operators/cast_op.h"
#include "paddle/fluid/operators/cast_op.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/float16.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
@@ -88,4 +89,5 @@ REGISTER_OP_CPU_KERNEL(cast, ops::CastOpKernel<CPU, float>,
...
@@ -88,4 +89,5 @@ REGISTER_OP_CPU_KERNEL(cast, ops::CastOpKernel<CPU, float>,
ops
::
CastOpKernel
<
CPU
,
double
>
,
ops
::
CastOpKernel
<
CPU
,
double
>
,
ops
::
CastOpKernel
<
CPU
,
int
>
,
ops
::
CastOpKernel
<
CPU
,
int
>
,
ops
::
CastOpKernel
<
CPU
,
int64_t
>
,
ops
::
CastOpKernel
<
CPU
,
int64_t
>
,
ops
::
CastOpKernel
<
CPU
,
bool
>
);
ops
::
CastOpKernel
<
CPU
,
bool
>
,
ops
::
CastOpKernel
<
CPU
,
paddle
::
platform
::
float16
>
);
paddle/fluid/operators/cast_op.cu
浏览文件 @
f3c5e815
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/fluid/operators/cast_op.h"
#include "paddle/fluid/operators/cast_op.h"
#include "paddle/fluid/platform/float16.h"
template
<
typename
T
>
template
<
typename
T
>
using
CastOpKernel
=
using
CastOpKernel
=
...
@@ -20,4 +21,5 @@ using CastOpKernel =
...
@@ -20,4 +21,5 @@ using CastOpKernel =
REGISTER_OP_CUDA_KERNEL
(
cast
,
CastOpKernel
<
float
>
,
CastOpKernel
<
double
>
,
REGISTER_OP_CUDA_KERNEL
(
cast
,
CastOpKernel
<
float
>
,
CastOpKernel
<
double
>
,
CastOpKernel
<
int
>
,
CastOpKernel
<
int64_t
>
,
CastOpKernel
<
int
>
,
CastOpKernel
<
int64_t
>
,
CastOpKernel
<
bool
>
);
CastOpKernel
<
bool
>
,
CastOpKernel
<
paddle
::
platform
::
float16
>
);
python/paddle/fluid/tests/unittests/test_cast_op.py
浏览文件 @
f3c5e815
...
@@ -18,7 +18,7 @@ import numpy as np
...
@@ -18,7 +18,7 @@ import numpy as np
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
class
TestCastOp
(
op_test
.
OpTest
):
class
TestCastOp
1
(
op_test
.
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
ipt
=
np
.
random
.
random
(
size
=
[
10
,
10
])
ipt
=
np
.
random
.
random
(
size
=
[
10
,
10
])
self
.
inputs
=
{
'X'
:
ipt
.
astype
(
'float32'
)}
self
.
inputs
=
{
'X'
:
ipt
.
astype
(
'float32'
)}
...
@@ -36,5 +36,36 @@ class TestCastOp(op_test.OpTest):
...
@@ -36,5 +36,36 @@ class TestCastOp(op_test.OpTest):
self
.
check_grad
([
'X'
],
[
'Out'
])
self
.
check_grad
([
'X'
],
[
'Out'
])
class
TestCastOp2
(
op_test
.
OpTest
):
def
setUp
(
self
):
ipt
=
np
.
random
.
random
(
size
=
[
10
,
10
])
# numpy float16 is binded to fluid float16 via uint16
self
.
inputs
=
{
'X'
:
ipt
.
astype
(
'float16'
).
view
(
uint16
)}
self
.
outputs
=
{
'Out'
:
ipt
.
astype
(
'float32'
)}
self
.
attrs
=
{
'in_dtype'
:
int
(
core
.
VarDesc
.
VarType
.
FP16
),
'out_dtype'
:
int
(
core
.
VarDesc
.
VarType
.
FP32
)
}
self
.
op_type
=
'cast'
def
test_check_output
(
self
):
self
.
check_output
()
class
TestCastOp2
(
op_test
.
OpTest
):
def
setUp
(
self
):
ipt
=
np
.
random
.
random
(
size
=
[
10
,
10
])
self
.
inputs
=
{
'X'
:
ipt
.
astype
(
'float32'
)}
self
.
outputs
=
{
'Out'
:
ipt
.
astype
(
'float16'
)}
self
.
attrs
=
{
'in_dtype'
:
int
(
core
.
VarDesc
.
VarType
.
FP32
),
'out_dtype'
:
int
(
core
.
VarDesc
.
VarType
.
FP16
)
}
self
.
op_type
=
'cast'
def
test_check_output
(
self
):
self
.
check_output
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录