File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -296,8 +296,13 @@ def _is_checkpoint_valid():
296296
297297
298298def variable (* args , ** kwargs ):
299- warnings .warn ("torch.autograd.variable(...) is deprecated, use torch.tensor(...) instead" )
300- return torch .tensor (* args , ** kwargs )
299+ raise RuntimeError ("torch.autograd.variable(...) is deprecated, use torch.tensor(...) instead" )
300+
301+ # Monkey patching variable.Variable to fix FX codegen. FX generates a call by roughly doing
302+ # f"{fn.__module__}.{fn.__name__}(...). This yields torch.autograd.variable.Variable(...) in the
303+ # output of an FX graph. Unfortunately the module name torch.autograd.variable is shadowed by the
304+ # deprecated function - variable(...).
305+ variable .Variable = Variable # type: ignore[attr-defined]
301306
302307if not torch ._C ._autograd_init ():
303308 raise RuntimeError ("autograd initialization failed" )
You can’t perform that action at this time.
0 commit comments