Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b470bd18
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
b470bd18
编写于
7月 25, 2022
作者:
W
Wang Bojun
提交者:
GitHub
7月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Phi gird sampler migration (#44562)
* add_ymal_utest for phi grid_sampler op
上级
c5a1e49c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
3 deletion
+33
-3
paddle/phi/api/yaml/legacy_api.yaml
paddle/phi/api/yaml/legacy_api.yaml
+12
-0
paddle/phi/api/yaml/legacy_backward.yaml
paddle/phi/api/yaml/legacy_backward.yaml
+12
-0
python/paddle/fluid/tests/unittests/test_grid_sampler_op.py
python/paddle/fluid/tests/unittests/test_grid_sampler_op.py
+4
-2
python/paddle/nn/functional/vision.py
python/paddle/nn/functional/vision.py
+5
-1
未找到文件。
paddle/phi/api/yaml/legacy_api.yaml
浏览文件 @
b470bd18
...
@@ -922,6 +922,18 @@
...
@@ -922,6 +922,18 @@
kernel
:
kernel
:
func
:
greater_than
func
:
greater_than
# grid sample
-
api
:
grid_sample
args
:
(Tensor x, Tensor grid, str mode, str padding_mode, bool align_corners)
output
:
Tensor(out)
infer_meta
:
func
:
GridSampleBaseInferMeta
param
:
[
x
,
grid
]
kernel
:
func
:
grid_sample
data_type
:
x
backward
:
grid_sample_grad
-
api
:
group_norm
-
api
:
group_norm
args
:
(Tensor x, Tensor scale, Tensor bias, float epsilon, int groups, str data_layout)
args
:
(Tensor x, Tensor scale, Tensor bias, float epsilon, int groups, str data_layout)
output
:
Tensor(y), Tensor(mean), Tensor(variance)
output
:
Tensor(y), Tensor(mean), Tensor(variance)
...
...
paddle/phi/api/yaml/legacy_backward.yaml
浏览文件 @
b470bd18
...
@@ -848,6 +848,18 @@
...
@@ -848,6 +848,18 @@
data_type
:
out_grad
data_type
:
out_grad
optional
:
out, dst_count
optional
:
out, dst_count
# grid sample
-
backward_api
:
grid_sample_grad
forward
:
grid_sample (Tensor x, Tensor grid, str mode, str padding_mode, bool align_corners) -> Tensor(out)
args
:
(Tensor x, Tensor grid, Tensor out_grad, str mode, str padding_mode, bool align_corners)
output
:
Tensor(x_grad), Tensor(grid_grad)
infer_meta
:
func
:
GeneralBinaryGradInferMeta
param
:
[
x
,
grid
]
kernel
:
func
:
grid_sample_grad
data_type
:
x
-
backward_api
:
group_norm_grad
-
backward_api
:
group_norm_grad
forward
:
group_norm (Tensor x, Tensor scale, Tensor bias, float epsilon, int groups, str data_layout) -> Tensor(y), Tensor(mean), Tensor(variance)
forward
:
group_norm (Tensor x, Tensor scale, Tensor bias, float epsilon, int groups, str data_layout) -> Tensor(y), Tensor(mean), Tensor(variance)
args
:
(Tensor x, Tensor scale, Tensor bias, Tensor y, Tensor mean, Tensor variance, Tensor y_grad, float epsilon, int groups, str data_layout)
args
:
(Tensor x, Tensor scale, Tensor bias, Tensor y, Tensor mean, Tensor variance, Tensor y_grad, float epsilon, int groups, str data_layout)
...
...
python/paddle/fluid/tests/unittests/test_grid_sampler_op.py
浏览文件 @
b470bd18
...
@@ -144,6 +144,7 @@ class TestGridSamplerOp(OpTest):
...
@@ -144,6 +144,7 @@ class TestGridSamplerOp(OpTest):
self
.
use_cudnn
=
False
self
.
use_cudnn
=
False
self
.
numeric_grad_delta
=
0.0001
self
.
numeric_grad_delta
=
0.0001
self
.
op_type
=
'grid_sampler'
self
.
op_type
=
'grid_sampler'
self
.
python_api
=
paddle
.
nn
.
functional
.
grid_sample
self
.
align_corners
=
True
self
.
align_corners
=
True
self
.
padding_mode
=
"zeros"
self
.
padding_mode
=
"zeros"
self
.
mode
=
"bilinear"
self
.
mode
=
"bilinear"
...
@@ -171,13 +172,14 @@ class TestGridSamplerOp(OpTest):
...
@@ -171,13 +172,14 @@ class TestGridSamplerOp(OpTest):
}
}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
self
.
check_output
()
self
.
check_output
(
check_eager
=
True
)
def
test_check_grad_normal
(
self
):
def
test_check_grad_normal
(
self
):
self
.
check_grad
([
'X'
,
'Grid'
],
self
.
check_grad
([
'X'
,
'Grid'
],
'Output'
,
'Output'
,
max_relative_error
=
0.01
,
max_relative_error
=
0.01
,
numeric_grad_delta
=
self
.
numeric_grad_delta
)
numeric_grad_delta
=
self
.
numeric_grad_delta
,
check_eager
=
True
)
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
x_shape
=
(
2
,
3
,
8
,
8
)
self
.
x_shape
=
(
2
,
3
,
8
,
8
)
...
...
python/paddle/nn/functional/vision.py
浏览文件 @
b470bd18
...
@@ -21,6 +21,7 @@ import numpy as np
...
@@ -21,6 +21,7 @@ import numpy as np
from
paddle
import
_C_ops
from
paddle
import
_C_ops
from
...device
import
is_compiled_with_rocm
from
...device
import
is_compiled_with_rocm
from
paddle
import
in_dynamic_mode
from
paddle
import
in_dynamic_mode
from
paddle.fluid.framework
import
in_dygraph_mode
from
paddle.framework
import
_non_static_mode
from
paddle.framework
import
_non_static_mode
__all__
=
[]
__all__
=
[]
...
@@ -272,7 +273,10 @@ def grid_sample(x,
...
@@ -272,7 +273,10 @@ def grid_sample(x,
x
.
stop_gradient
=
False
x
.
stop_gradient
=
False
grid
.
stop_gradient
=
False
grid
.
stop_gradient
=
False
if
in_dynamic_mode
():
if
in_dygraph_mode
():
return
_C_ops
.
final_state_grid_sample
(
x
,
grid
,
mode
,
padding_mode
,
align_corners
)
elif
in_dynamic_mode
():
attrs
=
(
'mode'
,
mode
,
'padding_mode'
,
padding_mode
,
'align_corners'
,
attrs
=
(
'mode'
,
mode
,
'padding_mode'
,
padding_mode
,
'align_corners'
,
align_corners
,
'use_cudnn'
,
use_cudnn
)
align_corners
,
'use_cudnn'
,
use_cudnn
)
out
=
getattr
(
_C_ops
,
'grid_sampler'
)(
x
,
grid
,
*
attrs
)
out
=
getattr
(
_C_ops
,
'grid_sampler'
)(
x
,
grid
,
*
attrs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录