今天在 debug 调试 torch 代码时,发现每次进入 forward 函数前都会先跳进 _call_impl 和 _wrapped_call_impl 函数,一开始以为是 torch 开启了 compile 模式,找了半天把一些 compile 的代码注释掉后发现也没有用。最后想起来是在 .vscode 文件夹的 launch.json 添加了 "justMyCode": true
。这个选项默认是 false
,我之前改为 true
忘记关了。
仔细想想,如果真的是 torch compile 导致的,forward 里面的函数是进不去的。