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

[fp16] support fp16 on temporal_shift #50919

Merged
merged 1 commit into from
Feb 27, 2023
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
25 changes: 25 additions & 0 deletions python/paddle/fluid/tests/unittests/test_temporal_shift_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,31 @@ def test_api(self):
x=input, seg_num=2, shift_ratio=0.2
)

def test_static_fp16_gpu(self):
if paddle.fluid.core.is_compiled_with_cuda():
place = paddle.CUDAPlace(0)
with paddle.static.program_guard(
paddle.static.Program(), paddle.static.Program()
):
input = np.random.random([4, 4, 112, 112]).astype("float16")

x = paddle.static.data(
name="x", shape=[4, 4, 112, 112], dtype="float16"
)

y = paddle.nn.functional.temporal_shift(
x=x, seg_num=2, shift_ratio=0.2
)

exe = paddle.static.Executor(place)
res = exe.run(
paddle.static.default_main_program(),
feed={
"x": input,
},
fetch_list=[y],
)

def test_error(self):
def attr_data_format():
input = paddle.randn([6, 4, 2, 2])
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/nn/functional/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def temporal_shift(x, seg_num, shift_ratio=0.25, name=None, data_format="NCHW"):
else:
helper = LayerHelper("temporal_shift", **locals())
check_variable_and_dtype(
x, 'x', ['float32', 'float64'], 'temporal_shift'
x, 'x', ['float16', 'float32', 'float64'], 'temporal_shift'
)
check_type(seg_num, 'seg_num', int, 'temporal_shift')
check_type(shift_ratio, 'shift_ratio', float, 'temporal_shift')
Expand Down