Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
668a0d3b
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看板
未验证
提交
668a0d3b
编写于
4月 15, 2021
作者:
X
xiaoting
提交者:
GitHub
4月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support int for nearest_interp, test=develop (#32270)
上级
cfdde0ec
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
0 deletion
+26
-0
paddle/fluid/operators/interpolate_v2_op.cc
paddle/fluid/operators/interpolate_v2_op.cc
+2
-0
paddle/fluid/operators/interpolate_v2_op.cu
paddle/fluid/operators/interpolate_v2_op.cu
+1
-0
python/paddle/fluid/tests/unittests/test_nearest_interp_v2_op.py
...paddle/fluid/tests/unittests/test_nearest_interp_v2_op.py
+23
-0
未找到文件。
paddle/fluid/operators/interpolate_v2_op.cc
浏览文件 @
668a0d3b
...
...
@@ -672,6 +672,8 @@ REGISTER_OP_CPU_KERNEL(bilinear_interp_v2_grad,
ops
::
InterpolateV2GradKernel
<
double
>
);
REGISTER_OP_CPU_KERNEL
(
nearest_interp_v2
,
ops
::
InterpolateV2Kernel
<
float
>
,
ops
::
InterpolateV2Kernel
<
double
>
,
ops
::
InterpolateV2Kernel
<
int
>
,
ops
::
InterpolateV2Kernel
<
int64_t
>
,
ops
::
InterpolateV2Kernel
<
uint8_t
>
);
REGISTER_OP_CPU_KERNEL
(
nearest_interp_v2_grad
,
ops
::
InterpolateV2GradKernel
<
float
>
,
...
...
paddle/fluid/operators/interpolate_v2_op.cu
浏览文件 @
668a0d3b
...
...
@@ -1738,6 +1738,7 @@ REGISTER_OP_CUDA_KERNEL(bilinear_interp_v2_grad,
REGISTER_OP_CUDA_KERNEL
(
nearest_interp_v2
,
ops
::
InterpolateOpV2CUDAKernel
<
float
>
,
ops
::
InterpolateOpV2CUDAKernel
<
double
>
,
ops
::
InterpolateOpV2CUDAKernel
<
int64_t
>
,
ops
::
InterpolateOpV2CUDAKernel
<
int
>
);
REGISTER_OP_CUDA_KERNEL
(
nearest_interp_v2_grad
,
ops
::
InterpolateV2GradOpCUDAKernel
<
float
>
,
...
...
python/paddle/fluid/tests/unittests/test_nearest_interp_v2_op.py
浏览文件 @
668a0d3b
...
...
@@ -21,6 +21,7 @@ import paddle.fluid.core as core
import
paddle.fluid
as
fluid
import
paddle.nn
as
nn
import
paddle
from
paddle.nn.functional
import
interpolate
def
nearest_neighbor_interp_np
(
X
,
...
...
@@ -526,6 +527,28 @@ class TestNearestAPI(unittest.TestCase):
self
.
assertTrue
(
np
.
allclose
(
results
[
i
+
1
],
expect_res
))
class
TestNearestInterpOpAPI_dy
(
unittest
.
TestCase
):
def
test_case
(
self
):
import
paddle
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
else
:
place
=
core
.
CPUPlace
()
with
fluid
.
dygraph
.
guard
(
place
):
input_data
=
np
.
random
.
random
((
2
,
3
,
6
,
6
)).
astype
(
"int64"
)
scale_np
=
np
.
array
([
2
,
2
]).
astype
(
"int64"
)
input_x
=
paddle
.
to_tensor
(
input_data
)
scale
=
paddle
.
to_tensor
(
scale_np
)
expect_res
=
nearest_neighbor_interp_np
(
input_data
,
out_h
=
12
,
out_w
=
12
,
align_corners
=
False
)
out
=
interpolate
(
x
=
input_x
,
scale_factor
=
scale
,
mode
=
"nearest"
,
align_corners
=
False
)
self
.
assertTrue
(
np
.
allclose
(
out
.
numpy
(),
expect_res
))
class
TestNearestInterpException
(
unittest
.
TestCase
):
def
test_exception
(
self
):
input
=
fluid
.
data
(
name
=
"input"
,
shape
=
[
1
,
3
,
6
,
6
],
dtype
=
"float32"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录