Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion python/paddle/fluid/layers/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 2 additions & 1 deletion python/paddle/fluid/tests/unittests/test_grid_sampler_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import unittest
import numpy as np
import paddle.fluid.core as core
from op_test import OpTest


Expand Down Expand Up @@ -182,7 +183,7 @@ def initTestCase(self):
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):
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/fluid/tests/unittests/test_inplace_abn_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

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
Expand Down
5 changes: 3 additions & 2 deletions python/paddle/nn/functional/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个格式有点奇怪,为什么括号会单独一行?最好修正一下格式

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是pre-commit自动修改的,原本格式不是这样的

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以尝试pre-commit uninstall之后再提交,或者手动断行,类似这个样子

    while not (os.path.exists(DATA_OUT_PATH) and
               os.path.getsize(DATA_OUT_PATH) == BIN_FULLSIZE and BIN_TARGETHASH
               == hashlib.md5(open(DATA_OUT_PATH, 'rb').read()).hexdigest()):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

) and align_corners and mode == 'bilinear' and padding_mode == 'zeros':
use_cudnn = True
# CUDNN always computes gradients for all inputs
x.stop_gradient = False
Expand Down