Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XPU] add grid sampler support. #71432

Merged
merged 6 commits into from
Mar 17, 2025
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
1 change: 1 addition & 0 deletions paddle/phi/backends/xpu/xpu3_op_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ XPUOpMap& get_kl3_ops() {
phi::DataType::FLOAT16,
phi::DataType::BFLOAT16,
phi::DataType::FLOAT32})},
{"grid_sampler", XPUKernelSet({phi::DataType::FLOAT32})},
{"grid_sampler_grad", XPUKernelSet({phi::DataType::FLOAT32})},
{"group_norm_silu_xpu",
XPUKernelSet({phi::DataType::FLOAT32, phi::DataType::FLOAT16})},
Expand Down
21 changes: 21 additions & 0 deletions test/xpu/test_grid_sampler_op_xpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from op_test_xpu import XPUOpTest

import paddle
from paddle.base import core

paddle.enable_static()

Expand Down Expand Up @@ -484,6 +485,10 @@ def initTestCase(self):
self.mode = "bilinear"

# 3d grid_sample_grad is not supported yet
@unittest.skipIf(
core.get_xpu_device_version(0) == core.XPUVersion.XPU3,
"grid_sample3d for XPU3 is not supported",
)
class TestGridSample3DBilinear(TestXPUGridSamplerOp):
def initTestCase(self):
self.x_shape = (2, 3, 5, 6, 7)
Expand All @@ -495,6 +500,10 @@ def initTestCase(self):

self.no_need_check_grad = True

@unittest.skipIf(
core.get_xpu_device_version(0) == core.XPUVersion.XPU3,
"grid_sample3d for XPU3 is not supported",
)
class TestGridSample3DNearest(TestXPUGridSamplerOp):
def initTestCase(self):
self.x_shape = (2, 3, 5, 6, 7)
Expand All @@ -506,6 +515,10 @@ def initTestCase(self):

self.no_need_check_grad = True

@unittest.skipIf(
core.get_xpu_device_version(0) == core.XPUVersion.XPU3,
"grid_sample3d for XPU3 is not supported",
)
class TestGridSample3DBorder(TestXPUGridSamplerOp):
def initTestCase(self):
self.x_shape = (2, 3, 5, 6, 7)
Expand All @@ -517,6 +530,10 @@ def initTestCase(self):

self.no_need_check_grad = True

@unittest.skipIf(
core.get_xpu_device_version(0) == core.XPUVersion.XPU3,
"grid_sample3d for XPU3 is not supported",
)
class TestGridSample3DReflection(TestXPUGridSamplerOp):
def initTestCase(self):
self.x_shape = (2, 3, 5, 6, 7)
Expand All @@ -528,6 +545,10 @@ def initTestCase(self):

self.no_need_check_grad = True

@unittest.skipIf(
core.get_xpu_device_version(0) == core.XPUVersion.XPU3,
"grid_sample3d for XPU3 is not supported",
)
class TestGridSample3DAlignCornersFalse(TestXPUGridSamplerOp):
def initTestCase(self):
self.x_shape = (2, 3, 5, 6, 7)
Expand Down
Loading