Skip to content

Conversation

@zty-king
Copy link
Contributor

@zty-king zty-king commented Nov 5, 2025

PR Category

User Experience

PR Types

Others

Description

  • 当前调用这几个窗口函数时,使用的是paddle.audio.functional.get_window;为了和pytorch完全对齐,即使用torch.xxx_window调用,需要在外层封装一层。
  • 经查证一共pytorch共包含以下5个window函数:bartlett_window, blackman_window, hamming_window, hann_window, kaiser_window。均在get_window中实现,直接封装即可
    -以下是window函数与参数暴露情况的对应关系,同时加入了get_window进行对比:
image

@paddle-bot
Copy link

paddle-bot bot commented Nov 5, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Nov 5, 2025
@zty-king
Copy link
Contributor Author

zty-king commented Nov 6, 2025

./re-run all-failed

@codecov-commenter
Copy link

codecov-commenter commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@581ee0a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/audio/functional/window.py 89.74% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #76237   +/-   ##
==========================================
  Coverage           ?   90.00%           
==========================================
  Files              ?        2           
  Lines              ?       40           
  Branches           ?        0           
==========================================
  Hits               ?       36           
  Misses             ?        4           
  Partials           ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zty-king
Copy link
Contributor Author

zty-king commented Nov 8, 2025

/re-run all-failed

@zty-king
Copy link
Contributor Author

/re-run all-failed

@zty-king zty-king changed the title align_window_func_with_torch [API Compatibility] align_window_func_with_torch Nov 13, 2025
@zty-king zty-king changed the title [API Compatibility] align_window_func_with_torch align_window_func_with_torch Nov 13, 2025
@zty-king
Copy link
Contributor Author

zty-king commented Nov 13, 2025

中文文档Pr链接:PaddlePaddle/docs#7631

@zty-king
Copy link
Contributor Author

/re-run all-failed

@zhwesky2010 zhwesky2010 changed the title align_window_func_with_torch [API compatibility] support windows api Nov 17, 2025
Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

竞品支持的参数,除了layout、memory_format,其他都需要支持。

warnings.warn("layout only supports 'strided' in Paddle; ignored")

# device: accept PlaceLike strings like 'cpu', 'gpu:0', 'cuda:0'
if device 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.

这个你可以直接调 _get_paddle_place

参考下paddle.full、random是如何处理这几个参数的,可以复制过来

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的

@zty-king
Copy link
Contributor Author

zty-king commented Nov 17, 2025 via email

@@ -0,0 +1,179 @@
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

这个命名改一下:test_window.py

@zhwesky2010
Copy link
Contributor

@zty-king 没看到提交呢,没有git push吗

@zty-king
Copy link
Contributor Author

@zty-king 没看到提交呢,没有git push吗

昨天有点别的工作处理,已经修改,您看一下

set_tests_properties(test_legacy_loss_args PROPERTIES TIMEOUT 10)
set_tests_properties(test_activation_nn_grad PROPERTIES TIMEOUT 250)
set_tests_properties(test_empty_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_window PROPERTIES TIMEOUT 10)
Copy link
Contributor

Choose a reason for hiding this comment

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

这个地方能不要改不,会触发需要额外的approve

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的,已经去掉了

warnings.warn("layout only supports 'strided' in Paddle; ignored")

if in_dynamic_or_pir_mode():
device = (
Copy link
Contributor

Choose a reason for hiding this comment

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

你这后面没有对device做处理呢,paddle.full的kernel可以直接传递一个device,而这个并没有处理device。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

抱歉漏掉了,已更正

@zty-king
Copy link
Contributor Author

/re-run all-failed

raise RuntimeError(
f"Pinning memory is not supported for {device}"
)
w = paddle.to_tensor(w, place=device)
Copy link
Contributor

Choose a reason for hiding this comment

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

Tensor.to是不是好点?

)
w = paddle.to_tensor(w, place=device)
if pin_memory and paddle.in_dynamic_mode():
w = w.pin_memory()
Copy link
Contributor

Choose a reason for hiding this comment

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

这里还需要吗,上面已经设置了pinnedplace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image 我看full这里写了,不知道是不是有什么特殊兜底处理,就一起带过来了

zhwesky2010
zhwesky2010 previously approved these changes Nov 19, 2025
@zhwesky2010
Copy link
Contributor

@unittest.skipIf. 是否是必要的,触发了CI拦截

@zty-king
Copy link
Contributor Author

@unittest.skipIf. 是否是必要的,触发了CI拦截

这个确实需要,因为在纯CPU环境下,那个包含device为gpu的测试会报错,所以需要在纯CPU环境下需要跳过这条测试


@unittest.skipUnless(_has_cuda(), "GPU not available")
def test_hamming_device_gpu_pin_memory(self):
if paddle.is_compiled_with_cuda():
Copy link
Contributor

Choose a reason for hiding this comment

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

这里不是有判断吗,为什么单测还会报错。这个case改下吧。不支持的不用加。尽量不要skipif

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的,之前好像是在哪被CI拦截了,我再尝试一下

@zty-king
Copy link
Contributor Author

/re-run all-failed

1 similar comment
@zty-king
Copy link
Contributor Author

/re-run all-failed

Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhwesky2010 zhwesky2010 merged commit 311b737 into PaddlePaddle:develop Nov 20, 2025
160 of 170 checks passed
@zty-king zty-king deleted the align_window_func_with_torch branch November 23, 2025 13:58
@zhwesky2010
Copy link
Contributor

zhwesky2010 commented Nov 26, 2025

@zty-king 这个返回结果与torch不一致,无法通过PaConvert的测试:

FAILED tests/test_blackman_window.py::test_case_1 - AssertionError: API (torch.blackman_window): dtype mismatch, torch dtype is float32, paddle dtype is float64
FAILED tests/test_blackman_window.py::test_case_3 - AssertionError: API (torch.blackman_window): dtype mismatch, torch dtype is float32, paddle dtype is float64
FAILED tests/test_blackman_window.py::test_case_4 - AssertionError: API (torch.blackman_window): dtype mismatch, torch dtype is float32, paddle dtype is float64
FAILED tests/test_blackman_window.py::test_case_5 - AssertionError: API (torch.blackman_window): dtype mismatch, torch dtype is float32, paddle dtype is float64

@zty-king
Copy link
Contributor Author

zty-king commented Nov 26, 2025

@zty-king 这个返回结果与torch不一致,无法通过PaConvert的测试:

FAILED tests/test_blackman_window.py::test_case_1 - AssertionError: API (torch.blackman_window): dtype mismatch, torch dtype is float32, paddle dtype is float64
FAILED tests/test_blackman_window.py::test_case_3 - AssertionError: API (torch.blackman_window): dtype mismatch, torch dtype is float32, paddle dtype is float64
FAILED tests/test_blackman_window.py::test_case_4 - AssertionError: API (torch.blackman_window): dtype mismatch, torch dtype is float32, paddle dtype is float64
FAILED tests/test_blackman_window.py::test_case_5 - AssertionError: API (torch.blackman_window): dtype mismatch, torch dtype is float32, paddle dtype is float64

Done.
#76623

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants