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

weird macro expression value stft_kernel.cu #9922

Closed
doombeaker opened this issue Mar 2, 2023 · 1 comment · Fixed by #9924
Closed

weird macro expression value stft_kernel.cu #9922

doombeaker opened this issue Mar 2, 2023 · 1 comment · Fixed by #9924
Labels
bug community events from community

Comments

@doombeaker
Copy link
Contributor

Summary

我发现 stft_kernel.cu 文件中的代码默认情况下不会被编译,因此怀疑是条件宏出了问题。
于是做了以下修改:doombeaker@1a96e88

#define YCPRINTLOG printf("CUDA_VERSION >= 11000 is true, version: %d, runtime: %d\r\n", CUDA_VERSION, (CUDA_VERSION >= 11000));
#else
#define YCPRINTLOG printf("CUDA_VERSION >= 11000 is false, version: %d, runtime: %d\r\n", CUDA_VERSION, (CUDA_VERSION >= 11000));
#endif

然后再运行(见以下的最小复现代码),发现得到的结果是:

/runonewhisper$ python3 bug_report.py 
CUDA_VERSION >= 11000 is false, version: 11020, runtime: 1

也就是说条件宏确实走的 false 分支,但是运行时的表达式又是 true。

感觉非常诡异。

Code to reproduce bug

import oneflow as torch

audio = torch.randn(478214).to("cuda")
N_FFT = 400
HOP_LENGTH = 160
window = torch.randn(400).to("cuda")
stft = torch.stft(audio, N_FFT, HOP_LENGTH, window=window, return_complex=False)

System Information

(oneflow-dev-clang10-v2) yaochi@oneflow-22:~/runonewhisper$ python3 -m oneflow --doctor
path: ['/home/yaochi/oneflow/python/oneflow']
version: 0.9.1+cu112.git.9ff1e1e7f2
git_commit: 9ff1e1e7f2
cmake_build_type: RelWithDebInfo
rdma: False
mlir: True
@doombeaker doombeaker added bug community events from community labels Mar 2, 2023
@liujuncheng
Copy link
Collaborator

https://github.com/Oneflow-Inc/oneflow/blob/master/oneflow/user/kernels/stft_kernel.cu#L17

CUDA_VERSION 是在cuda.h中定义的,只能在include cuda.h 之后使用

mosout added a commit that referenced this issue Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug community events from community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants