shilei09
2021-02-10 15:57
采纳率: 50%
浏览 803

pytorch源码中“if torch._C._get_tracing_state():”怎么理解

 

 

 

    def _call_impl(self, *input, **kwargs):
        for hook in itertools.chain(
                _global_forward_pre_hooks.values(),
                self._forward_pre_hooks.values()):
            result = hook(self, input)
            if result is not None:
                if not isinstance(result, tuple):
                    result = (result,)
                input = result
        if torch._C._get_tracing_state():  # 我对这句话不理解,if中为什么没有使用输入的形参?
            result = self._slow_forward(*input, **kwargs)
        else:
            result = self.forward(*input, **kwargs)  # 错误提示跳转到了这里

3条回答 默认 最新

相关推荐 更多相似问题