未验证 提交 7c27541e 编写于 作者: Z zhulei 提交者: GitHub

[Rocm] fix tests of inplace_abn_op & grid_sampler_op (#32703)

* [Rocm] fix tests of inplace_abn_op & grid_sampler_op

* [Rocm] fix tests of inplace_abn_op & grid_sampler_op
上级 70eb435c
......@@ -13029,7 +13029,10 @@ def grid_sampler(x, grid, name=None):
out = helper.create_variable_for_type_inference(x.dtype)
ipts = {'X': x, 'Grid': grid}
helper.append_op(type='grid_sampler', inputs=ipts, outputs={'Output': out})
attrs = {'use_cudnn': False} if core.is_compiled_with_rocm() else {}
helper.append_op(
type='grid_sampler', inputs=ipts, outputs={'Output': out}, attrs=attrs)
return out
......
......@@ -14,6 +14,7 @@
import unittest
import numpy as np
import paddle.fluid.core as core
from op_test import OpTest
......@@ -182,7 +183,7 @@ class TestGridSamplerOp(OpTest):
self.align_corners = True
self.padding_mode = "zeros"
self.mode = "bilinear"
self.use_cudnn = True
self.use_cudnn = False if core.is_compiled_with_rocm() else True
class Case1(TestGridSamplerOp):
......
......@@ -27,7 +27,7 @@ import paddle.fluid.unique_name as unique_name
class TestInplaceANBOpTraining(unittest.TestCase):
def setUp(self):
self.dtype = np.float64
self.dtype = np.float32 if core.is_compiled_with_rocm() else np.float64
self.N = 4
self.C = 5
self.H = 7
......
......@@ -265,8 +265,9 @@ def grid_sample(x,
cudnn_version = get_cudnn_version()
use_cudnn = False
if (cudnn_version is not None
) and align_corners and mode == 'bilinear' and padding_mode == 'zeros':
if not core.is_compiled_with_rocm() and (
cudnn_version is not None
) and align_corners and mode == 'bilinear' and padding_mode == 'zeros':
use_cudnn = True
# CUDNN always computes gradients for all inputs
x.stop_gradient = False
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册